Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

commander force offboard control update when first entering mode #12242

Merged
merged 3 commits into from
Jun 13, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions src/modules/commander/Commander.cpp
Original file line number Diff line number Diff line change
@@ -1486,8 +1486,19 @@ Commander::run()

sp_man_sub.update(&sp_man);

if (offboard_control_mode_sub.updated()) {
offboard_control_mode_s old = offboard_control_mode;
// if this is the first time entering OFFBOARD the subscription may not be active yet
bool force_offboard_update = false;

if (commander_state_s::MAIN_STATE_OFFBOARD) {
if (offboard_control_mode.timestamp == 0) {
offboard_control_mode_sub.forceInit();
force_offboard_update = true;
}
}

if (offboard_control_mode_sub.updated() || force_offboard_update) {

const offboard_control_mode_s old = offboard_control_mode;
offboard_control_mode_sub.copy(&offboard_control_mode);

if (old.ignore_thrust != offboard_control_mode.ignore_thrust ||
@@ -1499,13 +1510,16 @@ Commander::run()
old.ignore_velocity != offboard_control_mode.ignore_velocity ||
old.ignore_acceleration_force != offboard_control_mode.ignore_acceleration_force ||
old.ignore_alt_hold != offboard_control_mode.ignore_alt_hold) {

status_changed = true;
}
}

if (offboard_control_mode.timestamp != 0 &&
offboard_control_mode.timestamp + OFFBOARD_TIMEOUT > hrt_absolute_time()) {

if (status_flags.offboard_control_signal_lost) {

status_flags.offboard_control_signal_lost = false;
status_flags.offboard_control_loss_timeout = false;
status_changed = true;