1 #include "AP_RCProtocol_config.h"
3 #if AP_RCPROTOCOL_FDM_ENABLED
5 #include "AP_RCProtocol_FDM.h"
7 #include <AP_HAL/AP_HAL.h>
10 extern const AP_HAL::HAL
& hal
;
12 void AP_RCProtocol_FDM::update()
14 const auto sitl
= AP::sitl();
15 if (sitl
== nullptr) {
19 const auto &fdm
= sitl
->state
;
21 // see if there's fresh input. Until timestamps are worked out,
22 // just check for non-zero values:
23 if (fdm
.rcin_chan_count
== 0) {
27 // simulate RC input at 50Hz
28 if (AP_HAL::millis() - last_input_ms
< 20) {
32 last_input_ms
= AP_HAL::millis();
34 // scale from FDM 0-1 floats to PWM values
35 // these are the values that will be fed into the autopilot.
36 uint16_t pwm_input
[16];
37 const uint8_t count
= MIN(ARRAY_SIZE(pwm_input
), fdm
.rcin_chan_count
);
38 for (uint8_t i
=0; i
<count
; i
++) {
39 pwm_input
[i
] = 1000 + fdm
.rcin
[i
] * 1000;
50 #endif // AP_RCPROTOCOL_FDM_ENABLED