From 2bfffbd603ce0aa68b2655db2778057b8fee322f Mon Sep 17 00:00:00 2001 From: Yann Locatelli Date: Thu, 15 Feb 2024 11:42:37 +0100 Subject: [PATCH 1/4] =?UTF-8?q?=F0=9F=9A=9A=20(imu):=20Move=20LSM6DSOX=20i?= =?UTF-8?q?nterface=20to=20interface/drivers?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- drivers/CoreIMU/include/CoreLSM6DSOX.hpp | 2 +- .../interface => include/interface/drivers}/LSM6DSOX.hpp | 0 libs/IMUKit/include/IMUKit.hpp | 2 +- tests/functional/tests/core_imu/utils.h | 2 +- tests/unit/mocks/mocks/leka/LSM6DSOX.h | 2 +- 5 files changed, 4 insertions(+), 4 deletions(-) rename {drivers/CoreIMU/include/interface => include/interface/drivers}/LSM6DSOX.hpp (100%) diff --git a/drivers/CoreIMU/include/CoreLSM6DSOX.hpp b/drivers/CoreIMU/include/CoreLSM6DSOX.hpp index 818cfd923d..8b1de271ee 100644 --- a/drivers/CoreIMU/include/CoreLSM6DSOX.hpp +++ b/drivers/CoreIMU/include/CoreLSM6DSOX.hpp @@ -8,9 +8,9 @@ #include "CoreEventQueue.h" #include "CoreInterruptIn.h" -#include "interface/LSM6DSOX.hpp" #include "interface/drivers/DeepSleepEnabled.h" #include "interface/drivers/I2C.h" +#include "interface/drivers/LSM6DSOX.hpp" #include "lsm6dsox_reg.h" namespace leka { diff --git a/drivers/CoreIMU/include/interface/LSM6DSOX.hpp b/include/interface/drivers/LSM6DSOX.hpp similarity index 100% rename from drivers/CoreIMU/include/interface/LSM6DSOX.hpp rename to include/interface/drivers/LSM6DSOX.hpp diff --git a/libs/IMUKit/include/IMUKit.hpp b/libs/IMUKit/include/IMUKit.hpp index ababcfb531..e7daff394a 100644 --- a/libs/IMUKit/include/IMUKit.hpp +++ b/libs/IMUKit/include/IMUKit.hpp @@ -4,7 +4,7 @@ #pragma once -#include "interface/LSM6DSOX.hpp" +#include "interface/drivers/LSM6DSOX.hpp" #include "interface/libs/IMUKit.hpp" namespace leka { diff --git a/tests/functional/tests/core_imu/utils.h b/tests/functional/tests/core_imu/utils.h index e2e829cfdf..2d2bbf63f0 100644 --- a/tests/functional/tests/core_imu/utils.h +++ b/tests/functional/tests/core_imu/utils.h @@ -10,7 +10,7 @@ #include "rtos/ThisThread.h" #include "boost/ut.hpp" -#include "interface/LSM6DSOX.hpp" +#include "interface/drivers/LSM6DSOX.hpp" inline auto values_did_change_over_time(leka::interface::LSM6DSOX &lsm6dsox) { diff --git a/tests/unit/mocks/mocks/leka/LSM6DSOX.h b/tests/unit/mocks/mocks/leka/LSM6DSOX.h index 5d0a21e80f..8885a512de 100644 --- a/tests/unit/mocks/mocks/leka/LSM6DSOX.h +++ b/tests/unit/mocks/mocks/leka/LSM6DSOX.h @@ -5,7 +5,7 @@ #pragma once #include "gmock/gmock.h" -#include "interface/LSM6DSOX.hpp" +#include "interface/drivers/LSM6DSOX.hpp" namespace leka::mock { From 2584723d733942cff32383ed16cf64f901e5ea94 Mon Sep 17 00:00:00 2001 From: Yann Locatelli Date: Thu, 15 Feb 2024 11:46:07 +0100 Subject: [PATCH 2/4] =?UTF-8?q?=F0=9F=9A=9A=20(imu):=20Rename=20LSM6DSOX?= =?UTF-8?q?=20interface=20to=20IMU?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- drivers/CoreIMU/include/CoreLSM6DSOX.hpp | 4 ++-- drivers/CoreIMU/source/CoreLSM6DSOX.cpp | 4 ++-- drivers/CoreIMU/tests/CoreLSM6DSOX_test.cpp | 2 +- include/interface/drivers/{LSM6DSOX.hpp => IMU.hpp} | 4 ++-- libs/IMUKit/include/IMUKit.hpp | 8 ++++---- libs/IMUKit/source/IMUKit.cpp | 12 ++++++------ libs/IMUKit/tests/IMUKit_test.cpp | 12 ++++++------ spikes/lk_sensors_imu_lsm6dsox/main.cpp | 2 +- .../main.cpp | 4 ++-- .../tests/core_imu/suite_core_lsm6dsox.cpp | 4 ++-- tests/functional/tests/core_imu/utils.h | 10 +++++----- tests/unit/mocks/mocks/leka/LSM6DSOX.h | 4 ++-- 12 files changed, 35 insertions(+), 35 deletions(-) rename include/interface/drivers/{LSM6DSOX.hpp => IMU.hpp} (95%) diff --git a/drivers/CoreIMU/include/CoreLSM6DSOX.hpp b/drivers/CoreIMU/include/CoreLSM6DSOX.hpp index 8b1de271ee..9b82a4569e 100644 --- a/drivers/CoreIMU/include/CoreLSM6DSOX.hpp +++ b/drivers/CoreIMU/include/CoreLSM6DSOX.hpp @@ -10,12 +10,12 @@ #include "CoreInterruptIn.h" #include "interface/drivers/DeepSleepEnabled.h" #include "interface/drivers/I2C.h" -#include "interface/drivers/LSM6DSOX.hpp" +#include "interface/drivers/IMU.hpp" #include "lsm6dsox_reg.h" namespace leka { -class CoreLSM6DSOX : public interface::LSM6DSOX, public interface::DeepSleepEnabled +class CoreLSM6DSOX : public interface::IMU, public interface::DeepSleepEnabled { public: explicit CoreLSM6DSOX(interface::I2C &i2c, CoreInterruptIn &drdy_irq); diff --git a/drivers/CoreIMU/source/CoreLSM6DSOX.cpp b/drivers/CoreIMU/source/CoreLSM6DSOX.cpp index 2396598e43..57ab9931d6 100644 --- a/drivers/CoreIMU/source/CoreLSM6DSOX.cpp +++ b/drivers/CoreIMU/source/CoreLSM6DSOX.cpp @@ -99,12 +99,12 @@ void CoreLSM6DSOX::onGyrDataReadyHandler(auto timestamp) void CoreLSM6DSOX::enableDeepSleep() { - setPowerMode(interface::LSM6DSOX::PowerMode::Off); + setPowerMode(interface::IMU::PowerMode::Off); } void CoreLSM6DSOX::disableDeepSleep() { - setPowerMode(interface::LSM6DSOX::PowerMode::Normal); + setPowerMode(interface::IMU::PowerMode::Normal); } auto CoreLSM6DSOX::read(uint8_t register_address, uint16_t number_bytes_to_read, uint8_t *p_buffer) -> int32_t diff --git a/drivers/CoreIMU/tests/CoreLSM6DSOX_test.cpp b/drivers/CoreIMU/tests/CoreLSM6DSOX_test.cpp index a63bcc635e..9a7a2098ee 100644 --- a/drivers/CoreIMU/tests/CoreLSM6DSOX_test.cpp +++ b/drivers/CoreIMU/tests/CoreLSM6DSOX_test.cpp @@ -67,7 +67,7 @@ TEST_F(CoreLSM6DSOXTest, setPowerMode) TEST_F(CoreLSM6DSOXTest, onGyrDRDY) { - MockFunction mock_callback; + MockFunction mock_callback; EXPECT_CALL(mocki2c, write).Times(AtLeast(1)); EXPECT_CALL(mocki2c, read).Times(AtLeast(1)); diff --git a/include/interface/drivers/LSM6DSOX.hpp b/include/interface/drivers/IMU.hpp similarity index 95% rename from include/interface/drivers/LSM6DSOX.hpp rename to include/interface/drivers/IMU.hpp index dc1bf18a39..71d70c798c 100644 --- a/include/interface/drivers/LSM6DSOX.hpp +++ b/include/interface/drivers/IMU.hpp @@ -10,10 +10,10 @@ namespace leka::interface { -class LSM6DSOX +class IMU { public: - virtual ~LSM6DSOX() = default; + virtual ~IMU() = default; enum class PowerMode { diff --git a/libs/IMUKit/include/IMUKit.hpp b/libs/IMUKit/include/IMUKit.hpp index e7daff394a..10a459cdc1 100644 --- a/libs/IMUKit/include/IMUKit.hpp +++ b/libs/IMUKit/include/IMUKit.hpp @@ -4,7 +4,7 @@ #pragma once -#include "interface/drivers/LSM6DSOX.hpp" +#include "interface/drivers/IMU.hpp" #include "interface/libs/IMUKit.hpp" namespace leka { @@ -12,7 +12,7 @@ namespace leka { class IMUKit : public interface::IMUKit { public: - explicit IMUKit(interface::LSM6DSOX &lsm6dsox) : _lsm6dsox(lsm6dsox) {} + explicit IMUKit(interface::IMU &imu) : _imu(imu) {} void init(); void start() final; @@ -23,9 +23,9 @@ class IMUKit : public interface::IMUKit [[nodiscard]] auto getEulerAngles() const -> EulerAngles final; private: - void drdy_callback(interface::LSM6DSOX::SensorData data); + void drdy_callback(interface::IMU::SensorData data); - interface::LSM6DSOX &_lsm6dsox; + interface::IMU &_imu; EulerAngles _euler_angles {}; angles_ready_callback_t _on_euler_angles_rdy_callback {}; }; diff --git a/libs/IMUKit/source/IMUKit.cpp b/libs/IMUKit/source/IMUKit.cpp index d1681c2691..740ffbf1e2 100644 --- a/libs/IMUKit/source/IMUKit.cpp +++ b/libs/IMUKit/source/IMUKit.cpp @@ -55,19 +55,19 @@ void IMUKit::init() FusionOffsetInitialise(&fusion::global_offset, fusion::kODR_HZ); } - auto on_drdy_callback = [this](const interface::LSM6DSOX::SensorData &data) { drdy_callback(data); }; + auto on_drdy_callback = [this](const interface::IMU::SensorData &data) { drdy_callback(data); }; - _lsm6dsox.registerOnGyDataReadyCallback(on_drdy_callback); + _imu.registerOnGyDataReadyCallback(on_drdy_callback); } void IMUKit::start() { - _lsm6dsox.setPowerMode(interface::LSM6DSOX::PowerMode::Normal); + _imu.setPowerMode(interface::IMU::PowerMode::Normal); } void IMUKit::stop() { - _lsm6dsox.setPowerMode(interface::LSM6DSOX::PowerMode::Off); + _imu.setPowerMode(interface::IMU::PowerMode::Off); } void IMUKit::setOrigin() @@ -88,10 +88,10 @@ void IMUKit::onEulerAnglesReady(angles_ready_callback_t const &callback) _on_euler_angles_rdy_callback = callback; } -void IMUKit::drdy_callback(const interface::LSM6DSOX::SensorData data) +void IMUKit::drdy_callback(const interface::IMU::SensorData data) { // ? Note: For a detailed explanation on the code below, checkout - // ? https://github.com/leka/LekaOS/tree/develop/spikes/lk_sensors_imu_lsm6dsox_fusion_calibration + // ? https://github.com/leka/LekaOS/tree/develop/spikes/lk_sensors_imu_imu_fusion_calibration fusion::timestamp_now = rtos::Kernel::Clock::now(); diff --git a/libs/IMUKit/tests/IMUKit_test.cpp b/libs/IMUKit/tests/IMUKit_test.cpp index 04b1692468..8d20ce7cfc 100644 --- a/libs/IMUKit/tests/IMUKit_test.cpp +++ b/libs/IMUKit/tests/IMUKit_test.cpp @@ -37,14 +37,14 @@ TEST_F(IMUKitTest, initialization) TEST_F(IMUKitTest, start) { - EXPECT_CALL(mock_lsm6dox, setPowerMode(interface::LSM6DSOX::PowerMode::Normal)).Times(1); + EXPECT_CALL(mock_lsm6dox, setPowerMode(interface::IMU::PowerMode::Normal)).Times(1); imukit.start(); } TEST_F(IMUKitTest, stop) { - EXPECT_CALL(mock_lsm6dox, setPowerMode(interface::LSM6DSOX::PowerMode::Off)).Times(1); + EXPECT_CALL(mock_lsm6dox, setPowerMode(interface::IMU::PowerMode::Off)).Times(1); imukit.stop(); } @@ -71,7 +71,7 @@ TEST_F(IMUKitTest, onDataReady) imukit.onEulerAnglesReady(mock_callback.AsStdFunction()); const auto data_initial = - interface::LSM6DSOX::SensorData {.xl = {.x = 0.F, .y = 0.F, .z = 0.F}, .gy = {.x = 0.F, .y = 0.F, .z = 0.F}}; + interface::IMU::SensorData {.xl = {.x = 0.F, .y = 0.F, .z = 0.F}, .gy = {.x = 0.F, .y = 0.F, .z = 0.F}}; EXPECT_CALL(mock_callback, Call); @@ -82,7 +82,7 @@ TEST_F(IMUKitTest, onDataReady) spy_kernel_addElapsedTimeToTickCount(80ms); const auto data_updated = - interface::LSM6DSOX::SensorData {.xl = {.x = 1.F, .y = 2.F, .z = 3.F}, .gy = {.x = 1.F, .y = 2.F, .z = 3.F}}; + interface::IMU::SensorData {.xl = {.x = 1.F, .y = 2.F, .z = 3.F}, .gy = {.x = 1.F, .y = 2.F, .z = 3.F}}; EXPECT_CALL(mock_callback, Call); @@ -100,7 +100,7 @@ TEST_F(IMUKitTest, onDataReadyEmptyEulerAngleCallback) imukit.onEulerAnglesReady({}); const auto data_initial = - interface::LSM6DSOX::SensorData {.xl = {.x = 0.F, .y = 0.F, .z = 0.F}, .gy = {.x = 0.F, .y = 0.F, .z = 0.F}}; + interface::IMU::SensorData {.xl = {.x = 0.F, .y = 0.F, .z = 0.F}, .gy = {.x = 0.F, .y = 0.F, .z = 0.F}}; mock_lsm6dox.call_drdy_callback(data_initial); @@ -109,7 +109,7 @@ TEST_F(IMUKitTest, onDataReadyEmptyEulerAngleCallback) spy_kernel_addElapsedTimeToTickCount(80ms); const auto data_updated = - interface::LSM6DSOX::SensorData {.xl = {.x = 1.F, .y = 2.F, .z = 3.F}, .gy = {.x = 1.F, .y = 2.F, .z = 3.F}}; + interface::IMU::SensorData {.xl = {.x = 1.F, .y = 2.F, .z = 3.F}, .gy = {.x = 1.F, .y = 2.F, .z = 3.F}}; mock_lsm6dox.call_drdy_callback(data_updated); diff --git a/spikes/lk_sensors_imu_lsm6dsox/main.cpp b/spikes/lk_sensors_imu_lsm6dsox/main.cpp index 554511ee4a..bc7451e4e9 100644 --- a/spikes/lk_sensors_imu_lsm6dsox/main.cpp +++ b/spikes/lk_sensors_imu_lsm6dsox/main.cpp @@ -42,7 +42,7 @@ auto main() -> int imu::lsm6dsox.setPowerMode(CoreLSM6DSOX::PowerMode::Off); - auto callback = [](const interface::LSM6DSOX::SensorData data) { + auto callback = [](const interface::IMU::SensorData data) { const auto &[xlx, xly, xlz] = data.xl; const auto &[gx, gy, gz] = data.gy; const auto timestamp = data.timestamp.time_since_epoch().count(); diff --git a/spikes/lk_sensors_imu_lsm6dsox_fusion_calibration/main.cpp b/spikes/lk_sensors_imu_lsm6dsox_fusion_calibration/main.cpp index f9aee3d5db..b142db74fb 100644 --- a/spikes/lk_sensors_imu_lsm6dsox_fusion_calibration/main.cpp +++ b/spikes/lk_sensors_imu_lsm6dsox_fusion_calibration/main.cpp @@ -48,14 +48,14 @@ namespace fusion { .rejectionTimeout = static_cast(5 * kODR_HZ), // ? # of samples in 5 seconds }; - interface::LSM6DSOX::SensorData::time_point_t timestamp_previous = {}; + interface::IMU::SensorData::time_point_t timestamp_previous = {}; auto global_offset = FusionOffset {}; constexpr auto CALIBRATION = bool {true}; // constexpr auto CALIBRATION = bool {false}; - void callback(const interface::LSM6DSOX::SensorData data) + void callback(const interface::IMU::SensorData data) { auto timestamp_now = data.timestamp; auto timestamp_now_us = std::chrono::microseconds {timestamp_now.time_since_epoch()}.count(); diff --git a/tests/functional/tests/core_imu/suite_core_lsm6dsox.cpp b/tests/functional/tests/core_imu/suite_core_lsm6dsox.cpp index ca848ed83a..558711c5bc 100644 --- a/tests/functional/tests/core_imu/suite_core_lsm6dsox.cpp +++ b/tests/functional/tests/core_imu/suite_core_lsm6dsox.cpp @@ -18,13 +18,13 @@ suite suite_lsm6dsox = [] { auto i2c = CoreI2C(PinName::SENSOR_IMU_TH_I2C_SDA, PinName::SENSOR_IMU_TH_I2C_SCL); auto drdy_irq = CoreInterruptIn {PinName::SENSOR_IMU_IRQ}; auto lsm6dsox = CoreLSM6DSOX {i2c, drdy_irq}; - auto sensor_data = leka::interface::LSM6DSOX::SensorData(); + auto sensor_data = leka::interface::IMU::SensorData(); "initialization"_test = [&] { expect(neq(&lsm6dsox, nullptr)); lsm6dsox.init(); - auto sensor_callback = [&](const leka::interface::LSM6DSOX::SensorData &data) { sensor_data = data; }; + auto sensor_callback = [&](const leka::interface::IMU::SensorData &data) { sensor_data = data; }; lsm6dsox.registerOnGyDataReadyCallback(sensor_callback); }; diff --git a/tests/functional/tests/core_imu/utils.h b/tests/functional/tests/core_imu/utils.h index 2d2bbf63f0..cbe25cf7ed 100644 --- a/tests/functional/tests/core_imu/utils.h +++ b/tests/functional/tests/core_imu/utils.h @@ -10,20 +10,20 @@ #include "rtos/ThisThread.h" #include "boost/ut.hpp" -#include "interface/drivers/LSM6DSOX.hpp" +#include "interface/drivers/IMU.hpp" -inline auto values_did_change_over_time(leka::interface::LSM6DSOX &lsm6dsox) +inline auto values_did_change_over_time(leka::interface::IMU &imu) { using namespace std::chrono; using namespace boost::ut; - auto sensor_data = leka::interface::LSM6DSOX::SensorData(); + auto sensor_data = leka::interface::IMU::SensorData(); auto i_batch = std::vector {}; auto f_batch = std::vector {}; - auto sensor_callback = [&](const leka::interface::LSM6DSOX::SensorData &data) { sensor_data = data; }; - lsm6dsox.registerOnGyDataReadyCallback(sensor_callback); + auto sensor_callback = [&](const leka::interface::IMU::SensorData &data) { sensor_data = data; }; + imu.registerOnGyDataReadyCallback(sensor_callback); for (auto i = 0; i < 10; ++i) { auto [xlx, xly, xlz] = sensor_data.xl; diff --git a/tests/unit/mocks/mocks/leka/LSM6DSOX.h b/tests/unit/mocks/mocks/leka/LSM6DSOX.h index 8885a512de..b4ed89c51e 100644 --- a/tests/unit/mocks/mocks/leka/LSM6DSOX.h +++ b/tests/unit/mocks/mocks/leka/LSM6DSOX.h @@ -5,11 +5,11 @@ #pragma once #include "gmock/gmock.h" -#include "interface/drivers/LSM6DSOX.hpp" +#include "interface/drivers/IMU.hpp" namespace leka::mock { -class LSM6DSOX : public interface::LSM6DSOX +class LSM6DSOX : public interface::IMU { public: MOCK_METHOD(void, init, (), (override)); From 63a01055478abdb2733f09b35cc4b14936dafa96 Mon Sep 17 00:00:00 2001 From: Yann Locatelli Date: Thu, 15 Feb 2024 11:52:26 +0100 Subject: [PATCH 3/4] =?UTF-8?q?=F0=9F=9A=9A=20(imu):=20Rename=20LSM6DSOX?= =?UTF-8?q?=20mock=20to=20IMU?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- libs/IMUKit/tests/IMUKit_test.cpp | 18 +++++++++--------- .../mocks/mocks/leka/{LSM6DSOX.h => IMU.h} | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) rename tests/unit/mocks/mocks/leka/{LSM6DSOX.h => IMU.h} (93%) diff --git a/libs/IMUKit/tests/IMUKit_test.cpp b/libs/IMUKit/tests/IMUKit_test.cpp index 8d20ce7cfc..e53e58cc3a 100644 --- a/libs/IMUKit/tests/IMUKit_test.cpp +++ b/libs/IMUKit/tests/IMUKit_test.cpp @@ -9,7 +9,7 @@ #include "gmock/gmock.h" #include "gtest/gtest.h" #include "mocks/leka/CoreI2C.h" -#include "mocks/leka/LSM6DSOX.h" +#include "mocks/leka/IMU.h" #include "stubs/leka/EventLoopKit.h" #include "stubs/mbed/InterruptIn.h" #include "stubs/mbed/Kernel.h" @@ -25,9 +25,9 @@ class IMUKitTest : public ::testing::Test void SetUp() override { imukit.init(); } // void TearDown() override {} - mock::LSM6DSOX mock_lsm6dox {}; + mock::IMU mock_imu {}; - IMUKit imukit {mock_lsm6dox}; + IMUKit imukit {mock_imu}; }; TEST_F(IMUKitTest, initialization) @@ -37,14 +37,14 @@ TEST_F(IMUKitTest, initialization) TEST_F(IMUKitTest, start) { - EXPECT_CALL(mock_lsm6dox, setPowerMode(interface::IMU::PowerMode::Normal)).Times(1); + EXPECT_CALL(mock_imu, setPowerMode(interface::IMU::PowerMode::Normal)).Times(1); imukit.start(); } TEST_F(IMUKitTest, stop) { - EXPECT_CALL(mock_lsm6dox, setPowerMode(interface::IMU::PowerMode::Off)).Times(1); + EXPECT_CALL(mock_imu, setPowerMode(interface::IMU::PowerMode::Off)).Times(1); imukit.stop(); } @@ -75,7 +75,7 @@ TEST_F(IMUKitTest, onDataReady) EXPECT_CALL(mock_callback, Call); - mock_lsm6dox.call_drdy_callback(data_initial); + mock_imu.call_drdy_callback(data_initial); const auto angles_initial = imukit.getEulerAngles(); @@ -86,7 +86,7 @@ TEST_F(IMUKitTest, onDataReady) EXPECT_CALL(mock_callback, Call); - mock_lsm6dox.call_drdy_callback(data_updated); + mock_imu.call_drdy_callback(data_updated); auto angles_updated = imukit.getEulerAngles(); @@ -102,7 +102,7 @@ TEST_F(IMUKitTest, onDataReadyEmptyEulerAngleCallback) const auto data_initial = interface::IMU::SensorData {.xl = {.x = 0.F, .y = 0.F, .z = 0.F}, .gy = {.x = 0.F, .y = 0.F, .z = 0.F}}; - mock_lsm6dox.call_drdy_callback(data_initial); + mock_imu.call_drdy_callback(data_initial); const auto angles_initial = imukit.getEulerAngles(); @@ -111,7 +111,7 @@ TEST_F(IMUKitTest, onDataReadyEmptyEulerAngleCallback) const auto data_updated = interface::IMU::SensorData {.xl = {.x = 1.F, .y = 2.F, .z = 3.F}, .gy = {.x = 1.F, .y = 2.F, .z = 3.F}}; - mock_lsm6dox.call_drdy_callback(data_updated); + mock_imu.call_drdy_callback(data_updated); auto angles_updated = imukit.getEulerAngles(); diff --git a/tests/unit/mocks/mocks/leka/LSM6DSOX.h b/tests/unit/mocks/mocks/leka/IMU.h similarity index 93% rename from tests/unit/mocks/mocks/leka/LSM6DSOX.h rename to tests/unit/mocks/mocks/leka/IMU.h index b4ed89c51e..bd44872e3c 100644 --- a/tests/unit/mocks/mocks/leka/LSM6DSOX.h +++ b/tests/unit/mocks/mocks/leka/IMU.h @@ -9,7 +9,7 @@ namespace leka::mock { -class LSM6DSOX : public interface::IMU +class IMU : public interface::IMU { public: MOCK_METHOD(void, init, (), (override)); From 2270bd0d9b25789d9d5a9c731615c93950948722 Mon Sep 17 00:00:00 2001 From: Yann Locatelli Date: Thu, 15 Feb 2024 11:55:26 +0100 Subject: [PATCH 4/4] =?UTF-8?q?=F0=9F=9A=9A=20(imu):=20Rename=20CoreLSM6DS?= =?UTF-8?q?OX=20to=20CoreIMU?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/os/main.cpp | 10 ++--- drivers/CoreIMU/CMakeLists.txt | 4 +- .../include/{CoreLSM6DSOX.hpp => CoreIMU.hpp} | 8 ++-- .../source/{CoreLSM6DSOX.cpp => CoreIMU.cpp} | 30 ++++++------- ...CoreLSM6DSOX_test.cpp => CoreIMU_test.cpp} | 44 +++++++++---------- libs/IMUKit/tests/IMUKit_test.cpp | 2 +- spikes/CMakeLists.txt | 8 ++-- spikes/lk_activity_kit/main.cpp | 8 ++-- spikes/lk_command_kit/main.cpp | 8 ++-- spikes/lk_imu_kit/main.cpp | 8 ++-- spikes/lk_motion_kit/main.cpp | 8 ++-- spikes/lk_reinforcer/main.cpp | 8 ++-- spikes/lk_sensors_imu/CMakeLists.txt | 22 ++++++++++ .../main.cpp | 14 +++--- .../CMakeLists.txt | 23 ++++++++++ .../main.cpp | 12 ++--- spikes/lk_sensors_imu_lsm6dsox/CMakeLists.txt | 22 ---------- .../CMakeLists.txt | 23 ---------- .../functional/tests/core_imu/CMakeLists.txt | 2 +- ...e_core_lsm6dsox.cpp => suite_core_imu.cpp} | 22 +++++----- .../tests/deep_sleep_imu/suite_imu.cpp | 4 +- .../tests/imu_kit/suite_imu_kit.cpp | 8 ++-- 22 files changed, 149 insertions(+), 149 deletions(-) rename drivers/CoreIMU/include/{CoreLSM6DSOX.hpp => CoreIMU.hpp} (81%) rename drivers/CoreIMU/source/{CoreLSM6DSOX.cpp => CoreIMU.cpp} (81%) rename drivers/CoreIMU/tests/{CoreLSM6DSOX_test.cpp => CoreIMU_test.cpp} (65%) create mode 100644 spikes/lk_sensors_imu/CMakeLists.txt rename spikes/{lk_sensors_imu_lsm6dsox => lk_sensors_imu}/main.cpp (77%) create mode 100644 spikes/lk_sensors_imu_fusion_calibration/CMakeLists.txt rename spikes/{lk_sensors_imu_lsm6dsox_fusion_calibration => lk_sensors_imu_fusion_calibration}/main.cpp (93%) delete mode 100644 spikes/lk_sensors_imu_lsm6dsox/CMakeLists.txt delete mode 100644 spikes/lk_sensors_imu_lsm6dsox_fusion_calibration/CMakeLists.txt rename tests/functional/tests/core_imu/{suite_core_lsm6dsox.cpp => suite_core_imu.cpp} (65%) diff --git a/app/os/main.cpp b/app/os/main.cpp index a7ebbd2458..001bb16e37 100644 --- a/app/os/main.cpp +++ b/app/os/main.cpp @@ -21,13 +21,13 @@ #include "CoreFont.hpp" #include "CoreGraphics.hpp" #include "CoreI2C.h" +#include "CoreIMU.hpp" #include "CoreInterruptIn.h" #include "CoreJPEG.hpp" #include "CoreJPEGModeDMA.hpp" #include "CoreLCD.hpp" #include "CoreLCDDriverOTM8009A.hpp" #include "CoreLL.h" -#include "CoreLSM6DSOX.hpp" #include "CoreLTDC.hpp" #include "CoreMCU.h" #include "CoreMotor.h" @@ -265,11 +265,11 @@ namespace imu { } // namespace internal - auto lsm6dsox = CoreLSM6DSOX(internal::i2c, internal::drdy_irq); + auto coreimu = CoreIMU(internal::i2c, internal::drdy_irq); } // namespace imu -auto imukit = IMUKit {imu::lsm6dsox}; +auto imukit = IMUKit {imu::coreimu}; namespace motion::internal { @@ -540,7 +540,7 @@ namespace deep_sleep { &motors::right::motor, &display::internal::corelcd, &rfid::reader, - &imu::lsm6dsox, + &imu::coreimu, }); } @@ -578,7 +578,7 @@ auto main() -> int commandkit.registerCommand(command::list); activitykit.registerActivities(activities::activities); - imu::lsm6dsox.init(); + imu::coreimu.init(); imukit.init(); robot::controller.initializeComponents(); diff --git a/drivers/CoreIMU/CMakeLists.txt b/drivers/CoreIMU/CMakeLists.txt index edad0f0d94..ff11bf7333 100644 --- a/drivers/CoreIMU/CMakeLists.txt +++ b/drivers/CoreIMU/CMakeLists.txt @@ -13,7 +13,7 @@ target_include_directories(CoreIMU target_sources(CoreIMU PRIVATE extern/source/lsm6dsox_reg.c - source/CoreLSM6DSOX.cpp + source/CoreIMU.cpp ) target_link_libraries(CoreIMU @@ -23,6 +23,6 @@ target_link_libraries(CoreIMU if(${CMAKE_PROJECT_NAME} STREQUAL "LekaOSUnitTests") leka_unit_tests_sources( - tests/CoreLSM6DSOX_test.cpp + tests/CoreIMU_test.cpp ) endif() diff --git a/drivers/CoreIMU/include/CoreLSM6DSOX.hpp b/drivers/CoreIMU/include/CoreIMU.hpp similarity index 81% rename from drivers/CoreIMU/include/CoreLSM6DSOX.hpp rename to drivers/CoreIMU/include/CoreIMU.hpp index 9b82a4569e..bed4d3f779 100644 --- a/drivers/CoreIMU/include/CoreLSM6DSOX.hpp +++ b/drivers/CoreIMU/include/CoreIMU.hpp @@ -15,10 +15,10 @@ namespace leka { -class CoreLSM6DSOX : public interface::IMU, public interface::DeepSleepEnabled +class CoreIMU : public interface::IMU, public interface::DeepSleepEnabled { public: - explicit CoreLSM6DSOX(interface::I2C &i2c, CoreInterruptIn &drdy_irq); + explicit CoreIMU(interface::I2C &i2c, CoreInterruptIn &drdy_irq); void init() final; @@ -33,9 +33,9 @@ class CoreLSM6DSOX : public interface::IMU, public interface::DeepSleepEnabled auto read(uint8_t register_address, uint16_t number_bytes_to_read, uint8_t *p_buffer) -> int32_t; auto write(uint8_t register_address, uint16_t number_bytes_to_write, uint8_t *p_buffer) -> int32_t; - static auto ptr_io_write(CoreLSM6DSOX *handle, uint8_t write_address, uint8_t *p_buffer, + static auto ptr_io_write(CoreIMU *handle, uint8_t write_address, uint8_t *p_buffer, uint16_t number_bytes_to_write) -> int32_t; - static auto ptr_io_read(CoreLSM6DSOX *handle, uint8_t read_address, uint8_t *p_buffer, + static auto ptr_io_read(CoreIMU *handle, uint8_t read_address, uint8_t *p_buffer, uint16_t number_bytes_to_read) -> int32_t; void onGyrDataReadyHandler(auto timestamp); diff --git a/drivers/CoreIMU/source/CoreLSM6DSOX.cpp b/drivers/CoreIMU/source/CoreIMU.cpp similarity index 81% rename from drivers/CoreIMU/source/CoreLSM6DSOX.cpp rename to drivers/CoreIMU/source/CoreIMU.cpp index 57ab9931d6..2a749aafeb 100644 --- a/drivers/CoreIMU/source/CoreLSM6DSOX.cpp +++ b/drivers/CoreIMU/source/CoreIMU.cpp @@ -2,11 +2,11 @@ // Copyright 2022 APF France handicap // SPDX-License-Identifier: Apache-2.0 -#include "CoreLSM6DSOX.hpp" +#include "CoreIMU.hpp" namespace leka { -CoreLSM6DSOX::CoreLSM6DSOX(interface::I2C &i2c, CoreInterruptIn &drdy_irq) : _i2c(i2c), _drdy_irq(drdy_irq) +CoreIMU::CoreIMU(interface::I2C &i2c, CoreInterruptIn &drdy_irq) : _i2c(i2c), _drdy_irq(drdy_irq) { // ? NOLINTNEXTLINE - allow reinterpret_cast as there are no alternatives _register_io_function.write_reg = reinterpret_cast(ptr_io_write); @@ -15,7 +15,7 @@ CoreLSM6DSOX::CoreLSM6DSOX(interface::I2C &i2c, CoreInterruptIn &drdy_irq) : _i2 _register_io_function.handle = static_cast(this); } -void CoreLSM6DSOX::init() +void CoreIMU::init() { _event_queue.dispatch_forever(); @@ -33,7 +33,7 @@ void CoreLSM6DSOX::init() setGyrDataReadyInterrupt(); } -void CoreLSM6DSOX::setPowerMode(PowerMode mode) +void CoreIMU::setPowerMode(PowerMode mode) { auto xl_power_mode = lsm6dsox_xl_hm_mode_t {}; auto gy_power_mode = lsm6dsox_g_hm_mode_t {}; @@ -71,12 +71,12 @@ void CoreLSM6DSOX::setPowerMode(PowerMode mode) lsm6dsox_gy_data_rate_set(&_register_io_function, gy_odr); } -void CoreLSM6DSOX::registerOnGyDataReadyCallback(drdy_callback_t const &callback) +void CoreIMU::registerOnGyDataReadyCallback(drdy_callback_t const &callback) { _on_gy_data_ready_callback = callback; } -void CoreLSM6DSOX::onGyrDataReadyHandler(auto timestamp) +void CoreIMU::onGyrDataReadyHandler(auto timestamp) { static constexpr auto _1k = float {1000.F}; @@ -97,17 +97,17 @@ void CoreLSM6DSOX::onGyrDataReadyHandler(auto timestamp) } } -void CoreLSM6DSOX::enableDeepSleep() +void CoreIMU::enableDeepSleep() { setPowerMode(interface::IMU::PowerMode::Off); } -void CoreLSM6DSOX::disableDeepSleep() +void CoreIMU::disableDeepSleep() { setPowerMode(interface::IMU::PowerMode::Normal); } -auto CoreLSM6DSOX::read(uint8_t register_address, uint16_t number_bytes_to_read, uint8_t *p_buffer) -> int32_t +auto CoreIMU::read(uint8_t register_address, uint16_t number_bytes_to_read, uint8_t *p_buffer) -> int32_t { // Send component address, without STOP condition auto ret = _i2c.write(_address, ®ister_address, 1, true); @@ -119,7 +119,7 @@ auto CoreLSM6DSOX::read(uint8_t register_address, uint16_t number_bytes_to_read, return ret; } -auto CoreLSM6DSOX::write(uint8_t register_address, uint16_t number_bytes_to_write, uint8_t *p_buffer) -> int32_t +auto CoreIMU::write(uint8_t register_address, uint16_t number_bytes_to_write, uint8_t *p_buffer) -> int32_t { if (number_bytes_to_write >= kMaxBufferLength) { return 1; @@ -131,19 +131,19 @@ auto CoreLSM6DSOX::write(uint8_t register_address, uint16_t number_bytes_to_writ return ret; } -auto CoreLSM6DSOX::ptr_io_write(CoreLSM6DSOX *handle, uint8_t write_address, uint8_t *p_buffer, - uint16_t number_bytes_to_write) -> int32_t +auto CoreIMU::ptr_io_write(CoreIMU *handle, uint8_t write_address, uint8_t *p_buffer, + uint16_t number_bytes_to_write) -> int32_t { return handle->write(write_address, number_bytes_to_write, p_buffer); } -auto CoreLSM6DSOX::ptr_io_read(CoreLSM6DSOX *handle, uint8_t read_address, uint8_t *p_buffer, - uint16_t number_bytes_to_read) -> int32_t +auto CoreIMU::ptr_io_read(CoreIMU *handle, uint8_t read_address, uint8_t *p_buffer, + uint16_t number_bytes_to_read) -> int32_t { return handle->read(read_address, number_bytes_to_read, p_buffer); } -void CoreLSM6DSOX::setGyrDataReadyInterrupt() +void CoreIMU::setGyrDataReadyInterrupt() { lsm6dsox_dataready_pulsed_t drdy_pulsed {LSM6DSOX_DRDY_PULSED}; lsm6dsox_data_ready_mode_set(&_register_io_function, drdy_pulsed); diff --git a/drivers/CoreIMU/tests/CoreLSM6DSOX_test.cpp b/drivers/CoreIMU/tests/CoreIMU_test.cpp similarity index 65% rename from drivers/CoreIMU/tests/CoreLSM6DSOX_test.cpp rename to drivers/CoreIMU/tests/CoreIMU_test.cpp index 9a7a2098ee..5f0136acca 100644 --- a/drivers/CoreIMU/tests/CoreLSM6DSOX_test.cpp +++ b/drivers/CoreIMU/tests/CoreIMU_test.cpp @@ -4,7 +4,7 @@ #include -#include "CoreLSM6DSOX.hpp" +#include "CoreIMU.hpp" #include "gtest/gtest.h" #include "mocks/leka/CoreI2C.h" #include "mocks/leka/EventQueue.h" @@ -16,24 +16,24 @@ using testing::_; using testing::AtLeast; using testing::MockFunction; -class CoreLSM6DSOXTest : public ::testing::Test +class CoreIMUTest : public ::testing::Test { protected: - CoreLSM6DSOXTest() = default; + CoreIMUTest() = default; void SetUp() override { EXPECT_CALL(mocki2c, write).Times(AtLeast(1)); EXPECT_CALL(mocki2c, read).Times(AtLeast(1)); - lsm6dsox.init(); + coreimu.init(); } // void TearDown() override {} mock::CoreI2C mocki2c {}; CoreInterruptIn drdy_irq {NC}; - CoreLSM6DSOX lsm6dsox {mocki2c, drdy_irq}; + CoreIMU coreimu {mocki2c, drdy_irq}; // ? Instantiation of mock::EventQueue is needed to setup the underlying stubs that will make the mock work // ? correctly. Without it UT are failing @@ -41,31 +41,31 @@ class CoreLSM6DSOXTest : public ::testing::Test mock::EventQueue _ {}; }; -TEST_F(CoreLSM6DSOXTest, initialization) +TEST_F(CoreIMUTest, initialization) { - ASSERT_NE(&lsm6dsox, nullptr); + ASSERT_NE(&coreimu, nullptr); } -TEST_F(CoreLSM6DSOXTest, setPowerMode) +TEST_F(CoreIMUTest, setPowerMode) { EXPECT_CALL(mocki2c, write).Times(AtLeast(1)); EXPECT_CALL(mocki2c, read).Times(AtLeast(1)); - lsm6dsox.setPowerMode(CoreLSM6DSOX::PowerMode::Off); + coreimu.setPowerMode(CoreIMU::PowerMode::Off); EXPECT_CALL(mocki2c, write).Times(AtLeast(1)); EXPECT_CALL(mocki2c, read).Times(AtLeast(1)); - lsm6dsox.setPowerMode(CoreLSM6DSOX::PowerMode::UltraLow); + coreimu.setPowerMode(CoreIMU::PowerMode::UltraLow); EXPECT_CALL(mocki2c, write).Times(AtLeast(1)); EXPECT_CALL(mocki2c, read).Times(AtLeast(1)); - lsm6dsox.setPowerMode(CoreLSM6DSOX::PowerMode::Normal); + coreimu.setPowerMode(CoreIMU::PowerMode::Normal); EXPECT_CALL(mocki2c, write).Times(AtLeast(1)); EXPECT_CALL(mocki2c, read).Times(AtLeast(1)); - lsm6dsox.setPowerMode(CoreLSM6DSOX::PowerMode::High); + coreimu.setPowerMode(CoreIMU::PowerMode::High); } -TEST_F(CoreLSM6DSOXTest, onGyrDRDY) +TEST_F(CoreIMUTest, onGyrDRDY) { MockFunction mock_callback; @@ -73,34 +73,34 @@ TEST_F(CoreLSM6DSOXTest, onGyrDRDY) EXPECT_CALL(mocki2c, read).Times(AtLeast(1)); EXPECT_CALL(mock_callback, Call).Times(1); - lsm6dsox.registerOnGyDataReadyCallback(mock_callback.AsStdFunction()); + coreimu.registerOnGyDataReadyCallback(mock_callback.AsStdFunction()); auto on_rise_callback = spy_InterruptIn_getRiseCallback(); on_rise_callback(); } -TEST_F(CoreLSM6DSOXTest, emptyOnGyrDrdyCallback) +TEST_F(CoreIMUTest, emptyOnGyrDrdyCallback) { - lsm6dsox.registerOnGyDataReadyCallback({}); + coreimu.registerOnGyDataReadyCallback({}); auto on_rise_callback = spy_InterruptIn_getRiseCallback(); on_rise_callback(); } -TEST_F(CoreLSM6DSOXTest, enableDeepSleep) +TEST_F(CoreIMUTest, enableDeepSleep) { EXPECT_CALL(mocki2c, write).Times(AtLeast(1)); EXPECT_CALL(mocki2c, read).Times(AtLeast(1)); - lsm6dsox.setPowerMode(CoreLSM6DSOX::PowerMode::Off); + coreimu.setPowerMode(CoreIMU::PowerMode::Off); - lsm6dsox.enableDeepSleep(); + coreimu.enableDeepSleep(); } -TEST_F(CoreLSM6DSOXTest, disableDeepSleep) +TEST_F(CoreIMUTest, disableDeepSleep) { EXPECT_CALL(mocki2c, write).Times(AtLeast(1)); EXPECT_CALL(mocki2c, read).Times(AtLeast(1)); - lsm6dsox.setPowerMode(CoreLSM6DSOX::PowerMode::Normal); + coreimu.setPowerMode(CoreIMU::PowerMode::Normal); - lsm6dsox.disableDeepSleep(); + coreimu.disableDeepSleep(); } diff --git a/libs/IMUKit/tests/IMUKit_test.cpp b/libs/IMUKit/tests/IMUKit_test.cpp index e53e58cc3a..cd83887f93 100644 --- a/libs/IMUKit/tests/IMUKit_test.cpp +++ b/libs/IMUKit/tests/IMUKit_test.cpp @@ -4,7 +4,7 @@ #include "IMUKit.hpp" -#include "CoreLSM6DSOX.hpp" +#include "CoreIMU.hpp" #include "ThisThread.h" #include "gmock/gmock.h" #include "gtest/gtest.h" diff --git a/spikes/CMakeLists.txt b/spikes/CMakeLists.txt index cc3bd94479..e2deb2c4b9 100644 --- a/spikes/CMakeLists.txt +++ b/spikes/CMakeLists.txt @@ -28,8 +28,8 @@ add_subdirectory(${SPIKES_DIR}/lk_qdac) add_subdirectory(${SPIKES_DIR}/lk_reinforcer) add_subdirectory(${SPIKES_DIR}/lk_rfid) add_subdirectory(${SPIKES_DIR}/lk_sensors_battery) -add_subdirectory(${SPIKES_DIR}/lk_sensors_imu_lsm6dsox) -add_subdirectory(${SPIKES_DIR}/lk_sensors_imu_lsm6dsox_fusion_calibration) +add_subdirectory(${SPIKES_DIR}/lk_sensors_imu) +add_subdirectory(${SPIKES_DIR}/lk_sensors_imu_fusion_calibration) add_subdirectory(${SPIKES_DIR}/lk_sensors_light) add_subdirectory(${SPIKES_DIR}/lk_sensors_microphone) add_subdirectory(${SPIKES_DIR}/lk_sensors_temperature_humidity) @@ -71,8 +71,8 @@ add_dependencies(spikes_leka spike_lk_reinforcer spike_lk_rfid spike_lk_sensors_battery - spike_lk_sensors_imu_lsm6dsox - spike_lk_sensors_imu_lsm6dsox_fusion_calibration + spike_lk_sensors_imu + spike_lk_sensors_imu_fusion_calibration spike_lk_sensors_light spike_lk_sensors_microphone spike_lk_sensors_temperature_humidity diff --git a/spikes/lk_activity_kit/main.cpp b/spikes/lk_activity_kit/main.cpp index 453d817223..cd563f9912 100644 --- a/spikes/lk_activity_kit/main.cpp +++ b/spikes/lk_activity_kit/main.cpp @@ -18,6 +18,7 @@ #include "CoreFont.hpp" #include "CoreGraphics.hpp" #include "CoreI2C.h" +#include "CoreIMU.hpp" #include "CoreInterruptIn.h" #include "CoreJPEG.hpp" #include "CoreJPEGModeDMA.hpp" @@ -25,7 +26,6 @@ #include "CoreLCD.hpp" #include "CoreLCDDriverOTM8009A.hpp" #include "CoreLL.h" -#include "CoreLSM6DSOX.hpp" #include "CoreLTDC.hpp" #include "CoreMotor.h" #include "CorePwm.h" @@ -195,11 +195,11 @@ namespace imu { } // namespace internal - auto lsm6dsox = CoreLSM6DSOX(internal::i2c, internal::drdy_irq); + auto coreimu = CoreIMU(internal::i2c, internal::drdy_irq); } // namespace imu -auto imukit = IMUKit {imu::lsm6dsox}; +auto imukit = IMUKit {imu::coreimu}; namespace motion::internal { @@ -276,7 +276,7 @@ auto main() -> int sd::init(); - imu::lsm6dsox.init(); + imu::coreimu.init(); imukit.init(); ledkit.init(); diff --git a/spikes/lk_command_kit/main.cpp b/spikes/lk_command_kit/main.cpp index 86c3bf1f79..f33ff82613 100644 --- a/spikes/lk_command_kit/main.cpp +++ b/spikes/lk_command_kit/main.cpp @@ -13,6 +13,7 @@ #include "CoreFont.hpp" #include "CoreGraphics.hpp" #include "CoreI2C.h" +#include "CoreIMU.hpp" #include "CoreJPEG.hpp" #include "CoreJPEGModeDMA.hpp" #include "CoreJPEGModePolling.hpp" @@ -20,7 +21,6 @@ #include "CoreLCDDriverOTM8009A.hpp" #include "CoreLED.h" #include "CoreLL.h" -#include "CoreLSM6DSOX.hpp" #include "CoreLTDC.hpp" #include "CoreMotor.h" #include "CorePwm.h" @@ -104,11 +104,11 @@ namespace internal { } // namespace internal -CoreLSM6DSOX lsm6dsox(internal::i2c, internal::drdy_irq); +CoreIMU coreimu(internal::i2c, internal::drdy_irq); } // namespace imu -auto imukit = IMUKit {imu::lsm6dsox}; +auto imukit = IMUKit {imu::coreimu}; namespace motion::internal { @@ -255,7 +255,7 @@ auto main() -> int display::internal::corelcd.turnOn(); cmdkit.registerCommand(command::list); - imu::lsm6dsox.init(); + imu::coreimu.init(); imukit.init(); turnOff(); diff --git a/spikes/lk_imu_kit/main.cpp b/spikes/lk_imu_kit/main.cpp index c93230c6ba..fc3c4fc594 100644 --- a/spikes/lk_imu_kit/main.cpp +++ b/spikes/lk_imu_kit/main.cpp @@ -5,7 +5,7 @@ #include "rtos/ThisThread.h" #include "CoreI2C.h" -#include "CoreLSM6DSOX.hpp" +#include "CoreIMU.hpp" #include "HelloWorld.h" #include "IMUKit.hpp" #include "LogKit.h" @@ -24,11 +24,11 @@ namespace imu { } // namespace internal - CoreLSM6DSOX lsm6dsox(internal::i2c, internal::drdy_irq); + CoreIMU coreimu(internal::i2c, internal::drdy_irq); } // namespace imu -IMUKit imukit(imu::lsm6dsox); +IMUKit imukit(imu::coreimu); } // namespace @@ -40,7 +40,7 @@ auto main() -> int HelloWorld hello; hello.start(); - imu::lsm6dsox.init(); + imu::coreimu.init(); imukit.stop(); imukit.init(); diff --git a/spikes/lk_motion_kit/main.cpp b/spikes/lk_motion_kit/main.cpp index 26ec4622ca..7b5b93e3ab 100644 --- a/spikes/lk_motion_kit/main.cpp +++ b/spikes/lk_motion_kit/main.cpp @@ -6,7 +6,7 @@ #include "CoreBufferedSerial.h" #include "CoreI2C.h" -#include "CoreLSM6DSOX.hpp" +#include "CoreIMU.hpp" #include "CoreMotor.h" #include "CorePwm.h" #include "CoreRFIDReaderCR95HF.h" @@ -65,11 +65,11 @@ namespace imu { } // namespace internal - CoreLSM6DSOX lsm6dsox(internal::i2c, internal::drdy_irq); + CoreIMU coreimu(internal::i2c, internal::drdy_irq); } // namespace imu -auto imukit = IMUKit {imu::lsm6dsox}; +auto imukit = IMUKit {imu::coreimu}; namespace motion::internal { @@ -131,7 +131,7 @@ auto main() -> int HelloWorld hello; hello.start(); - imu::lsm6dsox.init(); + imu::coreimu.init(); imukit.init(); rfidkit.init(); diff --git a/spikes/lk_reinforcer/main.cpp b/spikes/lk_reinforcer/main.cpp index ae6957ef85..763177c878 100644 --- a/spikes/lk_reinforcer/main.cpp +++ b/spikes/lk_reinforcer/main.cpp @@ -13,12 +13,12 @@ #include "CoreFont.hpp" #include "CoreGraphics.hpp" #include "CoreI2C.h" +#include "CoreIMU.hpp" #include "CoreJPEG.hpp" #include "CoreJPEGModeDMA.hpp" #include "CoreLCD.hpp" #include "CoreLED.h" #include "CoreLL.h" -#include "CoreLSM6DSOX.hpp" #include "CoreLTDC.hpp" #include "CoreMotor.h" #include "CorePwm.h" @@ -142,11 +142,11 @@ namespace imu { } // namespace internal - CoreLSM6DSOX lsm6dsox(internal::i2c, internal::drdy_irq); + CoreIMU coreimu(internal::i2c, internal::drdy_irq); } // namespace imu -auto imukit = IMUKit {imu::lsm6dsox}; +auto imukit = IMUKit {imu::coreimu}; namespace motion::internal { @@ -202,7 +202,7 @@ auto main() -> int ledkit.init(); videokit.initializeScreen(); - imu::lsm6dsox.init(); + imu::coreimu.init(); imukit.init(); rtos::ThisThread::sleep_for(3s); diff --git a/spikes/lk_sensors_imu/CMakeLists.txt b/spikes/lk_sensors_imu/CMakeLists.txt new file mode 100644 index 0000000000..308279084e --- /dev/null +++ b/spikes/lk_sensors_imu/CMakeLists.txt @@ -0,0 +1,22 @@ +# Leka - LekaOS +# Copyright 2022 APF France handicap +# SPDX-License-Identifier: Apache-2.0 + +add_mbed_executable(spike_lk_sensors_imu) + +target_include_directories(spike_lk_sensors_imu + PRIVATE + . +) + +target_sources(spike_lk_sensors_imu + PRIVATE + main.cpp +) + +target_link_libraries(spike_lk_sensors_imu + CoreIMU + CoreI2C +) + +target_link_custom_leka_targets(spike_lk_sensors_imu) diff --git a/spikes/lk_sensors_imu_lsm6dsox/main.cpp b/spikes/lk_sensors_imu/main.cpp similarity index 77% rename from spikes/lk_sensors_imu_lsm6dsox/main.cpp rename to spikes/lk_sensors_imu/main.cpp index bc7451e4e9..dd011ba1d7 100644 --- a/spikes/lk_sensors_imu_lsm6dsox/main.cpp +++ b/spikes/lk_sensors_imu/main.cpp @@ -7,7 +7,7 @@ #include "rtos/ThisThread.h" #include "CoreI2C.h" -#include "CoreLSM6DSOX.hpp" +#include "CoreIMU.hpp" #include "HelloWorld.h" #include "LogKit.h" @@ -25,7 +25,7 @@ namespace imu { } // namespace internal - CoreLSM6DSOX lsm6dsox(internal::i2c, internal::drdy_irq); + CoreIMU coreimu(internal::i2c, internal::drdy_irq); } // namespace imu @@ -38,9 +38,9 @@ auto main() -> int HelloWorld hello; hello.start(); - imu::lsm6dsox.init(); + imu::coreimu.init(); - imu::lsm6dsox.setPowerMode(CoreLSM6DSOX::PowerMode::Off); + imu::coreimu.setPowerMode(CoreIMU::PowerMode::Off); auto callback = [](const interface::IMU::SensorData data) { const auto &[xlx, xly, xlz] = data.xl; @@ -51,16 +51,16 @@ auto main() -> int timestamp, xlx, xly, xlz, gx, gy, gz); }; - imu::lsm6dsox.registerOnGyDataReadyCallback(callback); + imu::coreimu.registerOnGyDataReadyCallback(callback); while (true) { log_info("Setting normal power mode for 5s"); rtos::ThisThread::sleep_for(1s); - imu::lsm6dsox.setPowerMode(CoreLSM6DSOX::PowerMode::Normal); + imu::coreimu.setPowerMode(CoreIMU::PowerMode::Normal); rtos::ThisThread::sleep_for(5s); - imu::lsm6dsox.setPowerMode(CoreLSM6DSOX::PowerMode::Off); + imu::coreimu.setPowerMode(CoreIMU::PowerMode::Off); rtos::ThisThread::sleep_for(500ms); log_info("Turning off for 5s"); diff --git a/spikes/lk_sensors_imu_fusion_calibration/CMakeLists.txt b/spikes/lk_sensors_imu_fusion_calibration/CMakeLists.txt new file mode 100644 index 0000000000..ff06f2bb67 --- /dev/null +++ b/spikes/lk_sensors_imu_fusion_calibration/CMakeLists.txt @@ -0,0 +1,23 @@ +# Leka - LekaOS +# Copyright 2023 APF France handicap +# SPDX-License-Identifier: Apache-2.0 + +add_mbed_executable(spike_lk_sensors_imu_fusion_calibration) + +target_include_directories(spike_lk_sensors_imu_fusion_calibration + PRIVATE + . +) + +target_sources(spike_lk_sensors_imu_fusion_calibration + PRIVATE + main.cpp +) + +target_link_libraries(spike_lk_sensors_imu_fusion_calibration + CoreIMU + CoreI2C + Fusion +) + +target_link_custom_leka_targets(spike_lk_sensors_imu_fusion_calibration) diff --git a/spikes/lk_sensors_imu_lsm6dsox_fusion_calibration/main.cpp b/spikes/lk_sensors_imu_fusion_calibration/main.cpp similarity index 93% rename from spikes/lk_sensors_imu_lsm6dsox_fusion_calibration/main.cpp rename to spikes/lk_sensors_imu_fusion_calibration/main.cpp index b142db74fb..b80691cb6b 100644 --- a/spikes/lk_sensors_imu_lsm6dsox_fusion_calibration/main.cpp +++ b/spikes/lk_sensors_imu_fusion_calibration/main.cpp @@ -8,7 +8,7 @@ #include "rtos/ThisThread.h" #include "CoreI2C.h" -#include "CoreLSM6DSOX.hpp" +#include "CoreIMU.hpp" #include "LogKit.h" // ? Note the following code has been heavily inspired from: @@ -31,7 +31,7 @@ namespace imu { } // namespace internal - CoreLSM6DSOX lsm6dsox(internal::i2c, internal::drdy_irq); + CoreIMU coreimu(internal::i2c, internal::drdy_irq); } // namespace imu @@ -119,9 +119,9 @@ auto main() -> int rtos::ThisThread::sleep_for(1s); - imu::lsm6dsox.init(); + imu::coreimu.init(); - imu::lsm6dsox.setPowerMode(CoreLSM6DSOX::PowerMode::Off); + imu::coreimu.setPowerMode(CoreIMU::PowerMode::Off); // ? Initialise algorithms FusionAhrsInitialise(&fusion::ahrs); @@ -136,8 +136,8 @@ auto main() -> int rtos::ThisThread::sleep_for(1s); - imu::lsm6dsox.registerOnGyDataReadyCallback(fusion::callback); - imu::lsm6dsox.setPowerMode(CoreLSM6DSOX::PowerMode::Normal); + imu::coreimu.registerOnGyDataReadyCallback(fusion::callback); + imu::coreimu.setPowerMode(CoreIMU::PowerMode::Normal); while (true) { rtos::ThisThread::sleep_for(5s); diff --git a/spikes/lk_sensors_imu_lsm6dsox/CMakeLists.txt b/spikes/lk_sensors_imu_lsm6dsox/CMakeLists.txt deleted file mode 100644 index 6764b69af4..0000000000 --- a/spikes/lk_sensors_imu_lsm6dsox/CMakeLists.txt +++ /dev/null @@ -1,22 +0,0 @@ -# Leka - LekaOS -# Copyright 2022 APF France handicap -# SPDX-License-Identifier: Apache-2.0 - -add_mbed_executable(spike_lk_sensors_imu_lsm6dsox) - -target_include_directories(spike_lk_sensors_imu_lsm6dsox - PRIVATE - . -) - -target_sources(spike_lk_sensors_imu_lsm6dsox - PRIVATE - main.cpp -) - -target_link_libraries(spike_lk_sensors_imu_lsm6dsox - CoreIMU - CoreI2C -) - -target_link_custom_leka_targets(spike_lk_sensors_imu_lsm6dsox) diff --git a/spikes/lk_sensors_imu_lsm6dsox_fusion_calibration/CMakeLists.txt b/spikes/lk_sensors_imu_lsm6dsox_fusion_calibration/CMakeLists.txt deleted file mode 100644 index d7ae9518e5..0000000000 --- a/spikes/lk_sensors_imu_lsm6dsox_fusion_calibration/CMakeLists.txt +++ /dev/null @@ -1,23 +0,0 @@ -# Leka - LekaOS -# Copyright 2023 APF France handicap -# SPDX-License-Identifier: Apache-2.0 - -add_mbed_executable(spike_lk_sensors_imu_lsm6dsox_fusion_calibration) - -target_include_directories(spike_lk_sensors_imu_lsm6dsox_fusion_calibration - PRIVATE - . -) - -target_sources(spike_lk_sensors_imu_lsm6dsox_fusion_calibration - PRIVATE - main.cpp -) - -target_link_libraries(spike_lk_sensors_imu_lsm6dsox_fusion_calibration - CoreIMU - CoreI2C - Fusion -) - -target_link_custom_leka_targets(spike_lk_sensors_imu_lsm6dsox_fusion_calibration) diff --git a/tests/functional/tests/core_imu/CMakeLists.txt b/tests/functional/tests/core_imu/CMakeLists.txt index 49964ee343..125723efc3 100644 --- a/tests/functional/tests/core_imu/CMakeLists.txt +++ b/tests/functional/tests/core_imu/CMakeLists.txt @@ -10,7 +10,7 @@ register_functional_test( . SOURCES - suite_core_lsm6dsox.cpp + suite_core_imu.cpp LINK_LIBRARIES CoreI2C diff --git a/tests/functional/tests/core_imu/suite_core_lsm6dsox.cpp b/tests/functional/tests/core_imu/suite_core_imu.cpp similarity index 65% rename from tests/functional/tests/core_imu/suite_core_lsm6dsox.cpp rename to tests/functional/tests/core_imu/suite_core_imu.cpp index 558711c5bc..0e35296aef 100644 --- a/tests/functional/tests/core_imu/suite_core_lsm6dsox.cpp +++ b/tests/functional/tests/core_imu/suite_core_imu.cpp @@ -6,7 +6,7 @@ #include "./utils.h" #include "CoreI2C.h" -#include "CoreLSM6DSOX.hpp" +#include "CoreIMU.hpp" #include "tests/config.h" using namespace leka; @@ -14,33 +14,33 @@ using namespace std::chrono; using namespace boost::ut; using namespace boost::ut::bdd; -suite suite_lsm6dsox = [] { +suite suite_coreimu = [] { auto i2c = CoreI2C(PinName::SENSOR_IMU_TH_I2C_SDA, PinName::SENSOR_IMU_TH_I2C_SCL); auto drdy_irq = CoreInterruptIn {PinName::SENSOR_IMU_IRQ}; - auto lsm6dsox = CoreLSM6DSOX {i2c, drdy_irq}; + auto coreimu = CoreIMU {i2c, drdy_irq}; auto sensor_data = leka::interface::IMU::SensorData(); "initialization"_test = [&] { - expect(neq(&lsm6dsox, nullptr)); - lsm6dsox.init(); + expect(neq(&coreimu, nullptr)); + coreimu.init(); auto sensor_callback = [&](const leka::interface::IMU::SensorData &data) { sensor_data = data; }; - lsm6dsox.registerOnGyDataReadyCallback(sensor_callback); + coreimu.registerOnGyDataReadyCallback(sensor_callback); }; - scenario("lsm6dsox - power mode") = [&] { + scenario("imu - power mode") = [&] { given("powermode is set to off") = [&] { - lsm6dsox.setPowerMode(CoreLSM6DSOX::PowerMode::Off); + coreimu.setPowerMode(CoreIMU::PowerMode::Off); then("I expect imu data to not change over time") = [&] { - expect(not values_did_change_over_time(lsm6dsox)); + expect(not values_did_change_over_time(coreimu)); }; }; given("powermode is set to normal again") = [&] { - lsm6dsox.setPowerMode(CoreLSM6DSOX::PowerMode::Normal); + coreimu.setPowerMode(CoreIMU::PowerMode::Normal); - then("I expect imu data to change over time") = [&] { expect(values_did_change_over_time(lsm6dsox)); }; + then("I expect imu data to change over time") = [&] { expect(values_did_change_over_time(coreimu)); }; }; }; }; diff --git a/tests/functional/tests/deep_sleep_imu/suite_imu.cpp b/tests/functional/tests/deep_sleep_imu/suite_imu.cpp index 294e1a0154..ea9cae75f2 100644 --- a/tests/functional/tests/deep_sleep_imu/suite_imu.cpp +++ b/tests/functional/tests/deep_sleep_imu/suite_imu.cpp @@ -3,7 +3,7 @@ // SPDX-License-Identifier: Apache-2.0 #include "CoreI2C.h" -#include "CoreLSM6DSOX.hpp" +#include "CoreIMU.hpp" #include "tests/config.h" #include "tests/utils_sleep.h" @@ -14,7 +14,7 @@ using namespace boost::ut::bdd; auto i2c = CoreI2C {PinName::SENSOR_IMU_TH_I2C_SDA, PinName::SENSOR_IMU_TH_I2C_SCL}; auto drdy_irq = CoreInterruptIn {PinName::SENSOR_IMU_IRQ}; -auto coreimu = CoreLSM6DSOX {i2c, drdy_irq}; +auto coreimu = CoreIMU {i2c, drdy_irq}; suite suite_imu = [] { scenario("imu initialization") = [] { diff --git a/tests/functional/tests/imu_kit/suite_imu_kit.cpp b/tests/functional/tests/imu_kit/suite_imu_kit.cpp index 56363c3744..0d1c9ac29b 100644 --- a/tests/functional/tests/imu_kit/suite_imu_kit.cpp +++ b/tests/functional/tests/imu_kit/suite_imu_kit.cpp @@ -5,7 +5,7 @@ #include "rtos/ThisThread.h" #include "CoreI2C.h" -#include "CoreLSM6DSOX.hpp" +#include "CoreIMU.hpp" #include "IMUKit.hpp" #include "tests/config.h" @@ -28,10 +28,10 @@ suite suite_imu_kit = [] { auto i2c = CoreI2C(PinName::SENSOR_IMU_TH_I2C_SDA, PinName::SENSOR_IMU_TH_I2C_SCL); auto drdy_irq = CoreInterruptIn {PinName::SENSOR_IMU_IRQ}; - auto lsm6dsox = CoreLSM6DSOX {i2c, drdy_irq}; - auto imukit = IMUKit {lsm6dsox}; + auto coreimu = CoreIMU {i2c, drdy_irq}; + auto imukit = IMUKit {coreimu}; - lsm6dsox.init(); + coreimu.init(); "Initialization"_test = [&] { expect(neq(&imukit, nullptr));