aboutsummaryrefslogtreecommitdiff
path: root/src/modules/commander/commander.cpp
diff options
context:
space:
mode:
authorThomas Gubler <thomasgubler@gmail.com>2014-07-16 09:38:57 +0200
committerThomas Gubler <thomasgubler@gmail.com>2014-07-16 09:39:40 +0200
commit3c8927c42386a6528f120d04ec93f5ab9b453a5b (patch)
tree162af3bece7542ae5176e37e33bc5252785a96eb /src/modules/commander/commander.cpp
parent35a9dad998961c9f8aa5ab5d015cb4b3a642a9ce (diff)
downloadpx4-firmware-3c8927c42386a6528f120d04ec93f5ab9b453a5b.tar.gz
px4-firmware-3c8927c42386a6528f120d04ec93f5ab9b453a5b.tar.bz2
px4-firmware-3c8927c42386a6528f120d04ec93f5ab9b453a5b.zip
once offboard is set by mavlink command ignore RC mode
Diffstat (limited to 'src/modules/commander/commander.cpp')
-rw-r--r--src/modules/commander/commander.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/modules/commander/commander.cpp b/src/modules/commander/commander.cpp
index e9db923e6..cc68c4e36 100644
--- a/src/modules/commander/commander.cpp
+++ b/src/modules/commander/commander.cpp
@@ -621,11 +621,16 @@ bool handle_command(struct vehicle_status_s *status_local, const struct safety_s
res = main_state_transition(status_local, MAIN_STATE_OFFBOARD);
if (res == TRANSITION_DENIED) {
print_reject_mode(status_local, "OFFBOARD");
+ status_local->offboard_control_set_by_command = false;
+ } else {
+ /* Set flag that offboard was set via command, main state is not overridden by rc */
+ status_local->offboard_control_set_by_command = true;
}
} else {
/* If the mavlink command is used to enable or disable offboard control:
* switch back to previous mode when disabling */
res = main_state_transition(status_local, main_state_pre_offboard);
+ status_local->offboard_control_set_by_command = false;
}
}
break;
@@ -1749,6 +1754,11 @@ set_main_state_rc(struct vehicle_status_s *status_local, struct manual_control_s
/* set main state according to RC switches */
transition_result_t res = TRANSITION_DENIED;
+ /* if offboard is set allready by a mavlink command, abort */
+ if (status.offboard_control_set_by_command) {
+ return main_state_transition(status_local, MAIN_STATE_OFFBOARD);
+ }
+
/* offboard switch overrides main switch */
if (sp_man->offboard_switch == SWITCH_POS_ON) {
res = main_state_transition(status_local, MAIN_STATE_OFFBOARD);