Skip to content

Commit

Permalink
Fix RTL abort detection on stick change
Browse files Browse the repository at this point in the history
  • Loading branch information
LorenzMeier committed May 5, 2016
1 parent bbd2b76 commit 639a589
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/modules/commander/commander.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2267,7 +2267,7 @@ int commander_thread_main(int argc, char *argv[])
main_state_before_rtl == commander_state_s::MAIN_STATE_STAB)) {

// transition to previous state if sticks are increased
const float min_stick_change = 0.2;
const float min_stick_change = 0.2f;
if ((_last_sp_man.timestamp != sp_man.timestamp) &&
((fabsf(sp_man.x) - fabsf(_last_sp_man.x) > min_stick_change) ||
(fabsf(sp_man.y) - fabsf(_last_sp_man.y) > min_stick_change) ||
Expand Down Expand Up @@ -2982,11 +2982,14 @@ set_main_state_rc(struct vehicle_status_s *status_local, struct manual_control_s
(_last_sp_man.mode_slot == sp_man->mode_slot))) {

// update these fields for the geofence system
_last_sp_man.timestamp = sp_man->timestamp;
_last_sp_man.x = sp_man->x;
_last_sp_man.y = sp_man->y;
_last_sp_man.z = sp_man->z;
_last_sp_man.r = sp_man->r;

This comment has been minimized.

Copy link
@julianoes

julianoes May 5, 2016

Contributor

Please add a comment what this does and delete the outdated comment above.

if (!rtl_on) {
_last_sp_man.timestamp = sp_man->timestamp;
_last_sp_man.x = sp_man->x;
_last_sp_man.y = sp_man->y;
_last_sp_man.z = sp_man->z;
_last_sp_man.r = sp_man->r;
}

/* no timestamp change or no switch change -> nothing changed */
return TRANSITION_NOT_CHANGED;
Expand Down

1 comment on commit 639a589

@dagar
Copy link
Member

@dagar dagar commented on 639a589 May 5, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@LorenzMeier I think the issue with this is if your sticks are at an extreme when the failsafe triggers.

Please sign in to comment.