From 6bf19ebe23c76f2e9879054499d91cbee580bfec Mon Sep 17 00:00:00 2001 From: DanielePettenuzzo Date: Fri, 8 Apr 2022 11:02:55 +0200 Subject: [PATCH] gps global origin stream - make sure we can always send out the message at least once on request When requesting a message from a stream that is not active we start the stream with interval=0 and call the request method once. For all streams this works fine except the gps_global_origin. For this one the request method is actually overidden to throttle down the rate and not just send out the message. This will cause this message to never being sent on request if the stream is not active by default. --- src/modules/mavlink/streams/GPS_GLOBAL_ORIGIN.hpp | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/src/modules/mavlink/streams/GPS_GLOBAL_ORIGIN.hpp b/src/modules/mavlink/streams/GPS_GLOBAL_ORIGIN.hpp index 22802b9082..7f59f52c03 100644 --- a/src/modules/mavlink/streams/GPS_GLOBAL_ORIGIN.hpp +++ b/src/modules/mavlink/streams/GPS_GLOBAL_ORIGIN.hpp @@ -58,12 +58,8 @@ public: bool request_message(float param2, float param3, float param4, float param5, float param6, float param7) override { - if (_valid) { - _force_next_send = true; - return true; - } - - return false; + _force_next_send = true; + return send(); } private: @@ -75,15 +71,13 @@ private: double _ref_lat{static_cast(NAN)}; double _ref_lon{static_cast(NAN)}; float _ref_alt{NAN}; - - bool _valid{false}; bool _force_next_send{true}; bool send() override { - vehicle_local_position_s vehicle_local_position; + vehicle_local_position_s vehicle_local_position{}; - if (_vehicle_local_position_sub.update(&vehicle_local_position)) { + if (_force_next_send || _vehicle_local_position_sub.update(&vehicle_local_position)) { if (vehicle_local_position.xy_global && vehicle_local_position.z_global) { static constexpr double LLA_MIN_DIFF = 0.0000001; // ~11.132 mm at the equator @@ -107,7 +101,6 @@ private: _ref_alt = vehicle_local_position.ref_alt; _force_next_send = false; - _valid = true; return true; }