From 12290c27e654d01a81f427f1be3cb33ba39beb75 Mon Sep 17 00:00:00 2001 From: MaEtUgR Date: Thu, 12 Jul 2018 10:33:36 +0200 Subject: [PATCH] FlightTask: update global reference For the geo.h C library to convert between global and local frame we need an up to date global reference which is currently inside the vehicle_local_position message. --- src/lib/FlightTasks/tasks/FlightTask.cpp | 8 ++++++-- src/lib/FlightTasks/tasks/FlightTask.hpp | 1 + 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/lib/FlightTasks/tasks/FlightTask.cpp b/src/lib/FlightTasks/tasks/FlightTask.cpp index 163ce95c9a..dbe318b66d 100644 --- a/src/lib/FlightTasks/tasks/FlightTask.cpp +++ b/src/lib/FlightTasks/tasks/FlightTask.cpp @@ -1,5 +1,6 @@ #include "FlightTask.hpp" #include +#include constexpr uint64_t FlightTask::_timeout; // First index of empty_setpoint corresponds to time-stamp and requires a finite number. @@ -101,8 +102,11 @@ bool FlightTask::_evaluateVehicleLocalPosition() _dist_to_bottom = _sub_vehicle_local_position->get().dist_bottom; } - // estimator specified vehicle limits - + // global frame reference coordinates to enable conversions + if (_sub_vehicle_local_position->get().xy_global && _sub_vehicle_local_position->get().z_global) { + globallocalconverter_init(_sub_vehicle_local_position->get().ref_lat, _sub_vehicle_local_position->get().ref_lon, + _sub_vehicle_local_position->get().ref_alt, _sub_vehicle_local_position->get().ref_timestamp); + } // We don't check here if states are valid or not. // Validity checks are done in the sub-classes. diff --git a/src/lib/FlightTasks/tasks/FlightTask.hpp b/src/lib/FlightTasks/tasks/FlightTask.hpp index 9992d50a2e..abf6c9c653 100644 --- a/src/lib/FlightTasks/tasks/FlightTask.hpp +++ b/src/lib/FlightTasks/tasks/FlightTask.hpp @@ -44,6 +44,7 @@ #include #include #include +#include #include #include #include