From dd02c5ffe8dc602834a9553c860bffd8358af1b2 Mon Sep 17 00:00:00 2001 From: Michael Belyaev Date: Sat, 8 Jun 2024 18:40:11 +0100 Subject: [PATCH] plz be below 25 cmon --- lib/navigation/control/navigator.cpp | 13 ++++++++----- lib/navigation/control/navigator.hpp | 5 +++++ 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/lib/navigation/control/navigator.cpp b/lib/navigation/control/navigator.cpp index fb03720d..f415b972 100644 --- a/lib/navigation/control/navigator.cpp +++ b/lib/navigation/control/navigator.cpp @@ -200,16 +200,19 @@ bool Navigator::subscribeAndCheck(core::MqttTopic topic) return true; } +bool Navigator::subscribeToTopics() +{ + return subscribeAndCheck(core::MqttTopic::kKeyence) + && subscribeAndCheck(core::MqttTopic::kOpticalFlow) + && subscribeAndCheck(core::MqttTopic::kAccelerometer); +} + void Navigator::run() { publishStart(); // Subscribe to all required topics - if (!subscribeAndCheck(core::MqttTopic::kKeyence) - || !subscribeAndCheck(core::MqttTopic::kOpticalFlow) - || !subscribeAndCheck(core::MqttTopic::kAccelerometer)) { - return; - } + if (!subscribeToTopics()) { return; } while (true) { bool sensor_data_received = false; diff --git a/lib/navigation/control/navigator.hpp b/lib/navigation/control/navigator.hpp index 446d56a6..f3957ac4 100644 --- a/lib/navigation/control/navigator.hpp +++ b/lib/navigation/control/navigator.hpp @@ -70,6 +70,11 @@ class Navigator : public INavigator { */ bool subscribeAndCheck(core::MqttTopic topic); + /** + * @brief Subscribes to all necessary topics + */ + bool subscribeToTopics(); + private: core::ILogger &logger_; const core::ITimeSource &time_;