Skip to content

Commit

Permalink
geofence: fix altitude change fence check
Browse files Browse the repository at this point in the history
When asking for an altitude change only, the current position needs to
be used, otherwise the geofence check is be skipped
  • Loading branch information
bresch authored and dagar committed Jul 7, 2023
1 parent 745fa37 commit afa085d
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/modules/navigator/navigator_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -257,8 +257,16 @@ void Navigator::run()
bool reposition_valid = true;

vehicle_global_position_s position_setpoint{};
position_setpoint.lat = cmd.param5;
position_setpoint.lon = cmd.param6;

if (PX4_ISFINITE(cmd.param5) && PX4_ISFINITE(cmd.param6)) {
position_setpoint.lat = cmd.param5;
position_setpoint.lon = cmd.param6;

} else {
position_setpoint.lat = get_global_position()->lat;
position_setpoint.lon = get_global_position()->lon;
}

position_setpoint.alt = PX4_ISFINITE(cmd.param7) ? cmd.param7 : get_global_position()->alt;

if (have_geofence_position_data) {
Expand Down

0 comments on commit afa085d

Please sign in to comment.