From c1acdc499460e86096a799ed2c284442f18a4491 Mon Sep 17 00:00:00 2001 From: Peter Barker Date: Fri, 8 Nov 2019 20:19:55 +1100 Subject: [PATCH] SITL: increase simulated rangefinder frequency to 5Hz --- libraries/SITL/SIM_SerialRangeFinder.cpp | 4 ++-- libraries/SITL/SIM_SerialRangeFinder.h | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/libraries/SITL/SIM_SerialRangeFinder.cpp b/libraries/SITL/SIM_SerialRangeFinder.cpp index 4655614af9..6e1eb4c4f4 100644 --- a/libraries/SITL/SIM_SerialRangeFinder.cpp +++ b/libraries/SITL/SIM_SerialRangeFinder.cpp @@ -61,9 +61,9 @@ uint16_t SerialRangeFinder::calculate_range_cm(float range_value) const void SerialRangeFinder::update(float range) { - // just send a chunk of data at 1Hz: + // just send a chunk of data at 5Hz: const uint32_t now = AP_HAL::millis(); - if (now - last_sent_ms < 1000) { + if (now - last_sent_ms < reading_interval_ms()) { return; } last_sent_ms = now; diff --git a/libraries/SITL/SIM_SerialRangeFinder.h b/libraries/SITL/SIM_SerialRangeFinder.h index b843408332..dfa9c8fb0d 100644 --- a/libraries/SITL/SIM_SerialRangeFinder.h +++ b/libraries/SITL/SIM_SerialRangeFinder.h @@ -36,6 +36,8 @@ public: virtual uint32_t packet_for_alt(uint16_t alt_cm, uint8_t *buffer, uint8_t buflen) = 0; + virtual uint16_t reading_interval_ms() const { return 200; } // 5Hz default + private: uint32_t last_sent_ms;