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.
This commit is contained in:
MaEtUgR 2018-07-12 11:48:04 +02:00 committed by ChristophTobler
parent 12290c27e6
commit 7c068e47ab

View File

@ -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;