Skip to content

Commit

Permalink
FlightTaskOrbit: only reapproach circle if center changed
Browse files Browse the repository at this point in the history
The condition that the vehicle is more than 3m away from the circle line
was too sloppy. That often happens when the radius is changed by sticks.
A reapproach is only necessary when the center is moved and that's only
possible through the orbit command.
  • Loading branch information
MaEtUgR committed Aug 12, 2019
1 parent 985db73 commit b243751
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/lib/FlightTasks/tasks/Orbit/FlightTaskOrbit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ bool FlightTaskOrbit::applyCommandParameters(const vehicle_command_s &command)
}
}

// perpendicularly approach the orbit circle again when new parameters get commanded
_in_circle_approach = true;

return ret;
}

Expand Down Expand Up @@ -179,12 +182,7 @@ bool FlightTaskOrbit::update()
setVelocity(v);

Vector2f center_to_position = Vector2f(_position) - _center;
const float distance_to_center = center_to_position.norm();

// perpendicularly approach the orbit circle if further away than 3 meters
if (!_in_circle_approach && !math::isInRange(distance_to_center, _r - 3.f, _r + 3.f)) {
_in_circle_approach = true;
}

if (_in_circle_approach) {
generate_circle_approach_setpoints();
Expand Down

0 comments on commit b243751

Please sign in to comment.