Browse Source

FlightTaskOrbit: fix acceleration limit inverting velocity

The formula only calculated the absolute value of the velocity and
the sign (rotation direction) got lost in that case.
sbg
MaEtUgR 7 years ago committed by ChristophTobler
parent
commit
7c068e47ab
  1. 4
      src/lib/FlightTasks/tasks/FlightTaskOrbit.cpp

4
src/lib/FlightTasks/tasks/FlightTaskOrbit.cpp

@ -60,9 +60,9 @@ bool FlightTaskOrbit::applyCommandParameters(const vehicle_command_s &command) @@ -60,9 +60,9 @@ bool FlightTaskOrbit::applyCommandParameters(const vehicle_command_s &command)
bool FlightTaskOrbit::setRadius(const float r)
{
if (math::isInRange(r, _radius_min, _radius_max)) {
// radius is more important than velocity for safety
// small radius is more important than high velocity for safety
if (!checkAcceleration(r, _v, _acceleration_max)) {
_v = sqrtf(_acceleration_max * r);
_v = math::sign(_v) * sqrtf(_acceleration_max * r);
}
_r = r;

Loading…
Cancel
Save