From d5df351770d6d78a814518e5493229e422f82115 Mon Sep 17 00:00:00 2001 From: Hugo Pezziardi Date: Mon, 6 Mar 2023 09:59:37 +0100 Subject: [PATCH] :arrow_up: (IMUKit): IMUKit derive from interface --- app/os/main.cpp | 1 + libs/IMUKit/include/IMUKit.hpp | 17 ++++++---------- spikes/lk_command_kit/main.cpp | 1 + tests/unit/mocks/mocks/leka/IMUKit.hpp | 28 ++++++++++++++++++++++++++ 4 files changed, 36 insertions(+), 11 deletions(-) create mode 100644 tests/unit/mocks/mocks/leka/IMUKit.hpp diff --git a/app/os/main.cpp b/app/os/main.cpp index 3ac5081c44..aa65b7270b 100644 --- a/app/os/main.cpp +++ b/app/os/main.cpp @@ -47,6 +47,7 @@ #include "FlashNumberCounting.h" #include "FoodRecognition.h" #include "HelloWorld.h" +#include "IMUKit.hpp" #include "LedColorRecognition.h" #include "LedKit.h" #include "LedNumberCounting.h" diff --git a/libs/IMUKit/include/IMUKit.hpp b/libs/IMUKit/include/IMUKit.hpp index 44dc217529..0158757418 100644 --- a/libs/IMUKit/include/IMUKit.hpp +++ b/libs/IMUKit/include/IMUKit.hpp @@ -5,26 +5,21 @@ #pragma once #include "interface/LSM6DSOX.hpp" +#include "interface/libs/IMUKit.hpp" namespace leka { -struct EulerAngles { - float pitch; - float roll; - float yaw; -}; - -class IMUKit +class IMUKit : public interface::IMUKit { public: explicit IMUKit(interface::LSM6DSOX &lsm6dsox) : _lsm6dsox(lsm6dsox) {} void init(); - void start(); - void stop(); + void start() final; + void stop() final; - void setOrigin(); - [[nodiscard]] auto getEulerAngles() const -> EulerAngles; + void setOrigin() final; + [[nodiscard]] auto getEulerAngles() const -> EulerAngles final; private: void drdy_callback(interface::LSM6DSOX::SensorData data); diff --git a/spikes/lk_command_kit/main.cpp b/spikes/lk_command_kit/main.cpp index 8282dfe00c..248a1acc0b 100644 --- a/spikes/lk_command_kit/main.cpp +++ b/spikes/lk_command_kit/main.cpp @@ -32,6 +32,7 @@ #include "EventLoopKit.h" #include "FATFileSystem.h" #include "HelloWorld.h" +#include "IMUKit.hpp" #include "LedKit.h" #include "LogKit.h" #include "ReinforcerKit.h" diff --git a/tests/unit/mocks/mocks/leka/IMUKit.hpp b/tests/unit/mocks/mocks/leka/IMUKit.hpp new file mode 100644 index 0000000000..cb93b1b90f --- /dev/null +++ b/tests/unit/mocks/mocks/leka/IMUKit.hpp @@ -0,0 +1,28 @@ +// Leka - LekaOS +// Copyright 2023 APF France handicap +// SPDX-License-Identifier: Apache-2.0 + +#pragma once + +#include "gmock/gmock.h" +#include "interface/libs/IMUKit.hpp" + +namespace leka::mock { + +class IMUKit : public interface::IMUKit +{ + public: + MOCK_METHOD(void, start, (), (override)); + MOCK_METHOD(void, stop, (), (override)); + MOCK_METHOD(void, setOrigin, (), (override)); + MOCK_METHOD(EulerAngles, getEulerAngles, (), (const, override)); + + void onEulerAnglesReady(angles_ready_callback_t const &cb) override { angles_ready_callback = cb; } + + void call_angles_ready_callback(const EulerAngles &data) { angles_ready_callback(data); } + + private: + angles_ready_callback_t angles_ready_callback {}; +}; + +} // namespace leka::mock