FlightTask: introduce method for limits and adjust accordingly for all the tasks

This commit is contained in:
Dennis Mannhart
2018-04-18 11:20:51 +02:00
committed by Lorenz Meier
parent 73b4f452cc
commit 97be84b0e4
11 changed files with 111 additions and 73 deletions
+15 -3
View File
@@ -94,12 +94,13 @@ bool FlightTaskAuto::_evaluateTriplets()
}
_type = (WaypointType)_sub_triplet_setpoint->get().current.type;
// always update cruise speed since that can change without waypoint changes
_mc_cruise_speed = _sub_triplet_setpoint->get().current.cruising_speed;
if (!PX4_ISFINITE(_mc_cruise_speed) || (_mc_cruise_speed < 0.0f)) {
// use default
_mc_cruise_speed = _mc_cruise_default.get();
if (!PX4_ISFINITE(_mc_cruise_speed) || (_mc_cruise_speed < 0.0f) || (_mc_cruise_speed > _limits.speed_NE_max)) {
// use default limit
_mc_cruise_speed = _limits.speed_NE_max;
}
// get target waypoint.
@@ -184,3 +185,14 @@ void FlightTaskAuto::_evaluateVehicleGlobalPosition()
_time_stamp_reference = _sub_vehicle_local_position->get().ref_timestamp;
}
}
void FlightTaskAuto::_updateSetpointLimits()
{
FlightTask::_updateSetpointLimits();
// only adjust limits if the new limit is lower
if (_limits.speed_NE_max >= MPC_XY_CRUISE.get()) {
_limits.speed_NE_max = MPC_XY_CRUISE.get();
}
}