Skip to content

Commit

Permalink
Fix bad assumption: _position_setpoint is normally at _target
Browse files Browse the repository at this point in the history
  • Loading branch information
Julian Kent authored and bresch committed Jan 6, 2020
1 parent 603a993 commit 33702be
Showing 1 changed file with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,12 @@ float FlightTaskAutoLineSmoothVel::_getMaxXYSpeed() const

// constrain velocity to go to the position setpoint first if the position setpoint has been modified by an external source
// (eg. Obstacle Avoidance)
if ((pos_traj - _position_setpoint).longerThan(_target_acceptance_radius)) {
bool xy_valid = PX4_ISFINITE(_position_setpoint(0)) && PX4_ISFINITE(_position_setpoint(1));
bool xy_modified = xy_valid && Vector2f((_target - _position_setpoint).xy()).longerThan(FLT_EPSILON);
bool z_valid = PX4_ISFINITE(_position_setpoint(2));
bool z_modified = z_valid && fabsf((_target - _position_setpoint)(2)) > FLT_EPSILON;

if (xy_modified || z_modified) {
waypoints[1] = _position_setpoint;
waypoints[2] = _target;

Expand All @@ -220,7 +225,10 @@ float FlightTaskAutoLineSmoothVel::_getMaxZSpeed() const

// constrain velocity to go to the position setpoint first if the position setpoint has been modified by an external source
// (eg. Obstacle Avoidance)
if ((pos_traj - _position_setpoint).longerThan(_target_acceptance_radius)) {
bool z_valid = PX4_ISFINITE(_position_setpoint(2));
bool z_modified = z_valid && fabsf((_target - _position_setpoint)(2)) > FLT_EPSILON;

if (z_modified) {
z_setpoint = _position_setpoint(2);
}

Expand Down

0 comments on commit 33702be

Please sign in to comment.