Skip to content

Commit 150dd0b

Browse files
dakejahlAlexKlimaj
authored andcommitted
flight task auto: fix offtrack mission landing bug
During a mission the last waypoint is often a LAND. If the previous waypoint is not directly above the land waypoint the offtrack calculation is incorrect. This regression was introduced when the offtrack calculation switched from 2D to 3D.
1 parent 09eda9e commit 150dd0b

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/modules/flight_mode_manager/tasks/Auto/FlightTaskAuto.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -618,6 +618,7 @@ State FlightTaskAuto::_getCurrentState()
618618
const Vector3f u_prev_to_target = (_triplet_target - _triplet_prev_wp).unit_or_zero();
619619
const Vector3f prev_to_pos = _position - _triplet_prev_wp;
620620
const Vector3f pos_to_target = _triplet_target - _position;
621+
621622
// Calculate the closest point to the vehicle position on the line prev_wp - target
622623
_closest_pt = _triplet_prev_wp + u_prev_to_target * (prev_to_pos * u_prev_to_target);
623624

@@ -635,10 +636,9 @@ State FlightTaskAuto::_getCurrentState()
635636
// Previous is in front
636637
return_state = State::previous_infront;
637638

638-
} else if ((_position - _closest_pt).longerThan(_target_acceptance_radius)) {
639+
} else if (_type != WaypointType::land && (_position - _closest_pt).longerThan(_target_acceptance_radius)) {
639640
// Vehicle too far from the track
640641
return_state = State::offtrack;
641-
642642
}
643643

644644
return return_state;

0 commit comments

Comments
 (0)