From 37db7d3bba965c379ac5e997661fa4930783daf3 Mon Sep 17 00:00:00 2001 From: CarlOlsson Date: Wed, 5 Feb 2020 07:12:54 +0100 Subject: [PATCH] ekf2: define max number of range finders seperate from max number of mutli uORB topics Signed-off-by: CarlOlsson --- src/modules/ekf2/ekf2_main.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/modules/ekf2/ekf2_main.cpp b/src/modules/ekf2/ekf2_main.cpp index 8f63c690f0..fb29e7abe8 100644 --- a/src/modules/ekf2/ekf2_main.cpp +++ b/src/modules/ekf2/ekf2_main.cpp @@ -253,7 +253,8 @@ private: bool _callback_registered{false}; // because we can have several distance sensor instances with different orientations - uORB::Subscription _range_finder_subs[ORB_MULTI_MAX_INSTANCES] {{ORB_ID(distance_sensor), 0}, {ORB_ID(distance_sensor), 1}, {ORB_ID(distance_sensor), 2}, {ORB_ID(distance_sensor), 3}}; + static constexpr int MAX_RNG_SENSOR_COUNT = 4; + uORB::Subscription _range_finder_subs[MAX_RNG_SENSOR_COUNT] {{ORB_ID(distance_sensor), 0}, {ORB_ID(distance_sensor), 1}, {ORB_ID(distance_sensor), 2}, {ORB_ID(distance_sensor), 3}}; int _range_finder_sub_index = -1; // index for downward-facing range finder subscription // because we can have multiple GPS instances @@ -1748,7 +1749,7 @@ void Ekf2::resetPreFlightChecks() int Ekf2::getRangeSubIndex() { - for (unsigned i = 0; i < ORB_MULTI_MAX_INSTANCES; i++) { + for (unsigned i = 0; i < MAX_RNG_SENSOR_COUNT; i++) { distance_sensor_s report{}; if (_range_finder_subs[i].update(&report)) {