Browse Source

FlightTaskAutoLine: distance to bottom depending on the mode

sbg
Dennis Mannhart 7 years ago committed by Lorenz Meier
parent
commit
93ebb60b84
  1. 11
      src/lib/FlightTasks/tasks/FlightTaskAutoLine.cpp

11
src/lib/FlightTasks/tasks/FlightTaskAutoLine.cpp

@ -55,11 +55,15 @@ bool FlightTaskAutoLine::update() @@ -55,11 +55,15 @@ bool FlightTaskAutoLine::update()
bool follow_line = _type == WaypointType::loiter || _type == WaypointType::position;
bool follow_line_prev = _type_previous == WaypointType::loiter || _type_previous == WaypointType::position;
// Altitude above ground from home or if not present
// the negation of the current position
// Altitude above ground is by default just the negation of the current local position in D-direction.
_alt_above_ground = -_position(2);
if (_sub_home_position->get().valid_alt) {
if (PX4_ISFINITE(_dist_to_bottom)) {
// We have a valid distance to ground measurement
_alt_above_ground = _dist_to_bottom;
} else if (_sub_home_position->get().valid_alt) {
// if home position is set, then altitude above ground is relative to the home position
_alt_above_ground = -_position(2) + _sub_home_position->get().z;
}
@ -388,7 +392,6 @@ void FlightTaskAutoLine::_generateAltitudeSetpoints() @@ -388,7 +392,6 @@ void FlightTaskAutoLine::_generateAltitudeSetpoints()
// check sign
const bool flying_upward = _destination(2) < _position(2);
// limit vertical downwards speed (positive z) close to ground
// for now we use the altitude above home and assume that we want to land at same height as we took off
float vel_limit = math::gradual(_alt_above_ground,

Loading…
Cancel
Save