Browse Source

FlightTaskAuto: reference update only if refence altitude has not bee set.

sbg
Dennis Mannhart 7 years ago committed by Lorenz Meier
parent
commit
66d5f2ffd2
  1. 9
      src/lib/FlightTasks/tasks/FlightTaskAuto.cpp
  2. 2
      src/lib/FlightTasks/tasks/FlightTaskAuto.hpp

9
src/lib/FlightTasks/tasks/FlightTaskAuto.cpp

@ -177,10 +177,13 @@ bool FlightTaskAuto::_isFinite(const position_setpoint_s sp) @@ -177,10 +177,13 @@ bool FlightTaskAuto::_isFinite(const position_setpoint_s sp)
void FlightTaskAuto::_evaluateVehicleGlobalPosition()
{
FlightTask::_evaluateVehicleLocalPosition();
// check if reference has changed and update.
if (_sub_vehicle_local_position->get().ref_timestamp != _time_stamp_reference) {
// Only update if reference timestamp has changed AND no valid reference altitude
// is available.
// TODO: this needs to be revisited and needs a more clear implementation
if (_sub_vehicle_local_position->get().ref_timestamp != _time_stamp_reference &&
(_sub_vehicle_local_position->get().z_global && !PX4_ISFINITE(_reference_altitude))) {
map_projection_init(&_reference_position,
_sub_vehicle_local_position->get().ref_lat,
_sub_vehicle_local_position->get().ref_lon);

2
src/lib/FlightTasks/tasks/FlightTaskAuto.hpp

@ -92,7 +92,7 @@ private: @@ -92,7 +92,7 @@ private:
map_projection_reference_s _reference; /**< Reference frame from global to local. */
map_projection_reference_s _reference_position{}; /**< Structure used to project lat/lon setpoint into local frame. */
float _reference_altitude = 0.0f; /**< Altitude relative to ground. */
float _reference_altitude = NAN; /**< Altitude relative to ground. */
hrt_abstime _time_stamp_reference = 0; /**< time stamp when last reference update occured. */
bool _evaluateTriplets(); /**< Checks and sets triplets. */

Loading…
Cancel
Save