From 4358c82dbbffd54713301bf2b8d1121c76a9f03c Mon Sep 17 00:00:00 2001 From: Yann Locatelli Date: Thu, 15 Feb 2024 11:55:26 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=9A=20(imu):=20Rename=20CoreLSM6DSOX?= =?UTF-8?q?=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 478f9000fa..e684802c12 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));