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.
This commit is contained in:
DanielePettenuzzo 2022-04-08 11:02:55 +02:00 committed by Daniel Agar
parent 76116d79f9
commit 6bf19ebe23
1 changed files with 4 additions and 11 deletions

View File

@ -58,12 +58,8 @@ public:
bool request_message(float param2, float param3, float param4, float param5, float param6, float param7) override bool request_message(float param2, float param3, float param4, float param5, float param6, float param7) override
{ {
if (_valid) {
_force_next_send = true; _force_next_send = true;
return true; return send();
}
return false;
} }
private: private:
@ -75,15 +71,13 @@ private:
double _ref_lat{static_cast<double>(NAN)}; double _ref_lat{static_cast<double>(NAN)};
double _ref_lon{static_cast<double>(NAN)}; double _ref_lon{static_cast<double>(NAN)};
float _ref_alt{NAN}; float _ref_alt{NAN};
bool _valid{false};
bool _force_next_send{true}; bool _force_next_send{true};
bool send() override 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) { 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 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; _ref_alt = vehicle_local_position.ref_alt;
_force_next_send = false; _force_next_send = false;
_valid = true;
return true; return true;
} }