aboutsummaryrefslogtreecommitdiff
path: root/src/modules/mavlink/mavlink_messages.cpp
diff options
context:
space:
mode:
authorAnton Babushkin <anton.babushkin@me.com>2014-08-13 19:46:35 +0200
committerAnton Babushkin <anton.babushkin@me.com>2014-08-13 19:46:35 +0200
commit54a6e66adafb7cca710bab3dc9e9c78c8b2390e8 (patch)
tree2d474b8164a8e6e274fd85ccd7a93b4ab5902259 /src/modules/mavlink/mavlink_messages.cpp
parent54fc6aa6788a125b387926a45023844daa42ec48 (diff)
downloadpx4-firmware-54a6e66adafb7cca710bab3dc9e9c78c8b2390e8.tar.gz
px4-firmware-54a6e66adafb7cca710bab3dc9e9c78c8b2390e8.tar.bz2
px4-firmware-54a6e66adafb7cca710bab3dc9e9c78c8b2390e8.zip
mavlink: in HIL_CONTROLS send 0 for disabled channels
Diffstat (limited to 'src/modules/mavlink/mavlink_messages.cpp')
-rw-r--r--src/modules/mavlink/mavlink_messages.cpp21
1 files changed, 13 insertions, 8 deletions
diff --git a/src/modules/mavlink/mavlink_messages.cpp b/src/modules/mavlink/mavlink_messages.cpp
index c10be77b5..f292605c9 100644
--- a/src/modules/mavlink/mavlink_messages.cpp
+++ b/src/modules/mavlink/mavlink_messages.cpp
@@ -1333,7 +1333,7 @@ protected:
}
for (unsigned i = 0; i < 8; i++) {
- if (mavlink_base_mode & MAV_MODE_FLAG_SAFETY_ARMED) {
+ if (act.output[i] > PWM_LOWEST_MIN / 2) {
if (i < n) {
/* scale PWM out 900..2100 us to 0..1 for rotors */
out[i] = (act.output[i] - PWM_LOWEST_MIN) / (PWM_HIGHEST_MAX - PWM_LOWEST_MIN);
@@ -1344,7 +1344,7 @@ protected:
}
} else {
- /* send 0 when disarmed */
+ /* send 0 when disarmed and for disabled channels */
out[i] = 0.0f;
}
}
@@ -1353,15 +1353,20 @@ protected:
/* fixed wing: scale throttle to 0..1 and other channels to -1..1 */
for (unsigned i = 0; i < 8; i++) {
- if (i != 3) {
- /* scale PWM out 900..2100 us to -1..1 for normal channels */
- out[i] = (act.output[i] - pwm_center) / ((PWM_HIGHEST_MAX - PWM_LOWEST_MIN) / 2);
+ if (act.output[i] > PWM_LOWEST_MIN / 2) {
+ if (i != 3) {
+ /* scale PWM out 900..2100 us to -1..1 for normal channels */
+ out[i] = (act.output[i] - pwm_center) / ((PWM_HIGHEST_MAX - PWM_LOWEST_MIN) / 2);
+
+ } else {
+ /* scale PWM out 900..2100 us to 0..1 for throttle */
+ out[i] = (act.output[i] - PWM_LOWEST_MIN) / (PWM_HIGHEST_MAX - PWM_LOWEST_MIN);
+ }
} else {
- /* scale PWM out 900..2100 us to 0..1 for throttle */
- out[i] = (act.output[i] - PWM_LOWEST_MIN) / (PWM_HIGHEST_MAX - PWM_LOWEST_MIN);
+ /* set 0 for disabled channels */
+ out[i] = 0.0f;
}
-
}
}