Skip to content

Commit

Permalink
commander: require local position for home
Browse files Browse the repository at this point in the history
This fixes (or at least works around) a race condition where the
`status_flags.condition_local_position_valid` is still `false` but the
`status_flags.condition_global_position_valid` is already `true`.

The way to reproduce it is t:
1. Poll home position to check if home is initialized
2. Send arm and takeoff command as soon as home is initialized

Then arming will succeed but takeoff will fail because there is a check
for `status_flags.condition_local_position_valid` in
`main_state_transition()` to enter TAKEOFF.
  • Loading branch information
julianoes authored and bkueng committed Sep 13, 2017
1 parent 19e7ba6 commit ee6a792
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/modules/commander/commander.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1264,8 +1264,8 @@ static void commander_set_home_position(orb_advert_t &homePub, home_position_s &
const vehicle_local_position_s &localPosition, const vehicle_global_position_s &globalPosition,
const vehicle_attitude_s &attitude)
{
//Need global position fix to be able to set home
if (!status_flags.condition_global_position_valid) {
//Need global and local position fix to be able to set home
if (!status_flags.condition_global_position_valid || !status_flags.condition_local_position_valid) {
return;
}

Expand Down

1 comment on commit ee6a792

@Stifael
Copy link
Contributor

Choose a reason for hiding this comment

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

interesting:
hopefully things like that are gone once we switched to local

Please sign in to comment.