-
Notifications
You must be signed in to change notification settings - Fork 17.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
AP_RCProtocol: add support for MAVLink receiver, handle RADIO_RC_CHAN…
…NELS message
- Loading branch information
Showing
6 changed files
with
93 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
|
||
#include "AP_RCProtocol_config.h" | ||
|
||
#if AP_RCPROTOCOL_MAVLINK_RADIO_ENABLED | ||
|
||
#include "AP_RCProtocol_MAVLinkRadio.h" | ||
|
||
void AP_RCProtocol_MAVLinkRadio::update_radio_rc_channels(const mavlink_radio_rc_channels_t* packet) | ||
{ | ||
const uint8_t count = MIN(packet->count, MAX_RCIN_CHANNELS); | ||
|
||
uint16_t rc_chan[MAX_RCIN_CHANNELS]; | ||
for (uint8_t i = 0; i < count; i++) { | ||
// The channel values are in centered 13 bit format. Range is [-4096,4096], center is 0. | ||
// According to specification, the conversion to PWM is x * 5/32 + 1500. | ||
rc_chan[i] = ((int32_t)packet->channels[i] * 5) / 32 + 1500; | ||
} | ||
|
||
bool failsafe = (packet->flags & RADIO_RC_CHANNELS_FLAGS_FAILSAFE); | ||
|
||
add_input(count, rc_chan, failsafe); | ||
} | ||
|
||
#endif // AP_RCPROTOCOL_MAVLINK_RADIO_ENABLED | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
|
||
#pragma once | ||
|
||
#include "AP_RCProtocol_config.h" | ||
|
||
#if AP_RCPROTOCOL_MAVLINK_RADIO_ENABLED | ||
|
||
#include "AP_RCProtocol.h" | ||
|
||
|
||
class AP_RCProtocol_MAVLinkRadio : public AP_RCProtocol_Backend { | ||
public: | ||
|
||
using AP_RCProtocol_Backend::AP_RCProtocol_Backend; | ||
|
||
// update from mavlink messages | ||
void update_radio_rc_channels(const mavlink_radio_rc_channels_t* packet) override; | ||
}; | ||
|
||
#endif // AP_RCPROTOCOL_MAVLINK_RADIO_ENABLED | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters