From 287253e527f3cdd145c0532fa608baee0d998bc8 Mon Sep 17 00:00:00 2001 From: Yann Locatelli Date: Wed, 13 Dec 2023 17:03:23 +0100 Subject: [PATCH] :truck: (BehaviorKit): Rename current BehaviorKit to BehaviorKitDeprecated --- app/os/CMakeLists.txt | 2 +- app/os/main.cpp | 2 +- .../CMakeLists.txt | 12 +++---- .../include/BehaviorKitDeprecated.h} | 6 ++-- .../source/BehaviorKitDeprecated.cpp} | 36 +++++++++---------- .../tests/BehaviorKitDeprecated_test.cpp} | 32 ++++++++--------- libs/CMakeLists.txt | 2 +- libs/RobotKit/CMakeLists.txt | 2 +- libs/RobotKit/include/RobotController.h | 6 ++-- libs/RobotKit/tests/RobotController_test.h | 4 +-- spikes/lk_activity_kit/CMakeLists.txt | 2 +- spikes/lk_activity_kit/main.cpp | 4 +-- spikes/lk_behavior_kit/CMakeLists.txt | 2 +- spikes/lk_behavior_kit/main.cpp | 4 +-- spikes/lk_command_kit/CMakeLists.txt | 2 +- tests/unit/CMakeLists.txt | 2 +- 16 files changed, 60 insertions(+), 60 deletions(-) rename libs/{BehaviorKit => BehaviorKitDeprecated}/CMakeLists.txt (50%) rename libs/{BehaviorKit/include/BehaviorKit.h => BehaviorKitDeprecated/include/BehaviorKitDeprecated.h} (82%) rename libs/{BehaviorKit/source/BehaviorKit.cpp => BehaviorKitDeprecated/source/BehaviorKitDeprecated.cpp} (71%) rename libs/{BehaviorKit/tests/BehaviorKit_test.cpp => BehaviorKitDeprecated/tests/BehaviorKitDeprecated_test.cpp} (75%) diff --git a/app/os/CMakeLists.txt b/app/os/CMakeLists.txt index 0e6ba00395..88ec154ff1 100644 --- a/app/os/CMakeLists.txt +++ b/app/os/CMakeLists.txt @@ -25,7 +25,7 @@ target_link_libraries(LekaOS FileManagerKit SerialNumberKit FirmwareKit - BehaviorKit + BehaviorKitDeprecated CorePwm CoreMotor VideoKit diff --git a/app/os/main.cpp b/app/os/main.cpp index 13f6636019..3ae0be1bb2 100644 --- a/app/os/main.cpp +++ b/app/os/main.cpp @@ -278,7 +278,7 @@ namespace motion::internal { auto motionkit = MotionKit {motors::left::motor, motors::right::motor, imukit, motion::internal::timeout}; -auto behaviorkit = BehaviorKit {videokit, ledkit, motors::left::motor, motors::right::motor}; +auto behaviorkit = BehaviorKitDeprecated {videokit, ledkit, motors::left::motor, motors::right::motor}; auto reinforcerkit = ReinforcerKit {videokit, ledkit, motionkit}; namespace command { diff --git a/libs/BehaviorKit/CMakeLists.txt b/libs/BehaviorKitDeprecated/CMakeLists.txt similarity index 50% rename from libs/BehaviorKit/CMakeLists.txt rename to libs/BehaviorKitDeprecated/CMakeLists.txt index 4366423873..907374d42e 100644 --- a/libs/BehaviorKit/CMakeLists.txt +++ b/libs/BehaviorKitDeprecated/CMakeLists.txt @@ -2,19 +2,19 @@ # Copyright 2022 APF France handicap # SPDX-License-Identifier: Apache-2.0 -add_library(BehaviorKit STATIC) +add_library(BehaviorKitDeprecated STATIC) -target_include_directories(BehaviorKit +target_include_directories(BehaviorKitDeprecated PUBLIC include ) -target_sources(BehaviorKit +target_sources(BehaviorKitDeprecated PRIVATE - source/BehaviorKit.cpp + source/BehaviorKitDeprecated.cpp ) -target_link_libraries(BehaviorKit +target_link_libraries(BehaviorKitDeprecated LedKit VideoKit CoreMotor @@ -22,6 +22,6 @@ target_link_libraries(BehaviorKit if(${CMAKE_PROJECT_NAME} STREQUAL "LekaOSUnitTests") leka_unit_tests_sources( - tests/BehaviorKit_test.cpp + tests/BehaviorKitDeprecated_test.cpp ) endif() diff --git a/libs/BehaviorKit/include/BehaviorKit.h b/libs/BehaviorKitDeprecated/include/BehaviorKitDeprecated.h similarity index 82% rename from libs/BehaviorKit/include/BehaviorKit.h rename to libs/BehaviorKitDeprecated/include/BehaviorKitDeprecated.h index cfb7b82fe7..1eccaf0295 100644 --- a/libs/BehaviorKit/include/BehaviorKit.h +++ b/libs/BehaviorKitDeprecated/include/BehaviorKitDeprecated.h @@ -10,11 +10,11 @@ namespace leka { -class BehaviorKit +class BehaviorKitDeprecated { public: - explicit BehaviorKit(interface::VideoKit &videokit, interface::LedKit &ledkit, interface::Motor &motor_left, - interface::Motor &motor_right) + explicit BehaviorKitDeprecated(interface::VideoKit &videokit, interface::LedKit &ledkit, + interface::Motor &motor_left, interface::Motor &motor_right) : _videokit(videokit), _ledkit(ledkit), _motor_left(motor_left), _motor_right(motor_right) { // nothing do to diff --git a/libs/BehaviorKit/source/BehaviorKit.cpp b/libs/BehaviorKitDeprecated/source/BehaviorKitDeprecated.cpp similarity index 71% rename from libs/BehaviorKit/source/BehaviorKit.cpp rename to libs/BehaviorKitDeprecated/source/BehaviorKitDeprecated.cpp index 776fa5b97e..51d35709dd 100644 --- a/libs/BehaviorKit/source/BehaviorKit.cpp +++ b/libs/BehaviorKitDeprecated/source/BehaviorKitDeprecated.cpp @@ -2,52 +2,52 @@ // Copyright 2022 APF France handicap // SPDX-License-Identifier: Apache-2.0 -#include "BehaviorKit.h" #include #include "rtos/ThisThread.h" +#include "BehaviorKitDeprecated.h" #include "LedKitAnimations.h" namespace leka { using namespace std::chrono; -void BehaviorKit::spinLeft(float speed) +void BehaviorKitDeprecated::spinLeft(float speed) { _motor_left.spin(Rotation::clockwise, speed); _motor_right.spin(Rotation::clockwise, speed); } -void BehaviorKit::spinRight(float speed) +void BehaviorKitDeprecated::spinRight(float speed) { _motor_left.spin(Rotation::counterClockwise, speed); _motor_right.spin(Rotation::counterClockwise, speed); } -void BehaviorKit::launching() +void BehaviorKitDeprecated::launching() { _videokit.displayImage(fs::home::img::system::robot_misc_splash_screen_large_400); } -void BehaviorKit::sleeping() +void BehaviorKitDeprecated::sleeping() { _ledkit.start(&led::animation::sleeping); _videokit.playVideoOnce(fs::home::vid::system::robot_system_sleep_yawn_then_sleep_no_eyebrows); } -void BehaviorKit::waiting() +void BehaviorKitDeprecated::waiting() { _ledkit.stop(); _videokit.playVideoOnRepeat(fs::home::vid::system::robot_system_idle_looking_top_right_left_no_eyebrows); } -void BehaviorKit::blinkOnCharge() +void BehaviorKitDeprecated::blinkOnCharge() { _ledkit.start(&led::animation::blink_on_charge); } -void BehaviorKit::lowBattery() +void BehaviorKitDeprecated::lowBattery() { _ledkit.stop(); _videokit.displayImage(fs::home::img::system::robot_battery_empty_must_be_charged); @@ -55,54 +55,54 @@ void BehaviorKit::lowBattery() _motor_right.stop(); } -void BehaviorKit::chargingEmpty() +void BehaviorKitDeprecated::chargingEmpty() { _videokit.displayImage(fs::home::img::system::robot_battery_charging_empty_red); } -void BehaviorKit::chargingLow() +void BehaviorKitDeprecated::chargingLow() { _videokit.displayImage(fs::home::img::system::robot_battery_charging_quarter_1_red); } -void BehaviorKit::chargingMedium() +void BehaviorKitDeprecated::chargingMedium() { _videokit.displayImage(fs::home::img::system::robot_battery_charging_quarter_2_orange); } -void BehaviorKit::chargingHigh() +void BehaviorKitDeprecated::chargingHigh() { _videokit.displayImage(fs::home::img::system::robot_battery_charging_quarter_3_green); } -void BehaviorKit::chargingFull() +void BehaviorKitDeprecated::chargingFull() { _videokit.displayImage(fs::home::img::system::robot_battery_charging_quarter_4_green); } -void BehaviorKit::bleConnectionWithoutVideo() +void BehaviorKitDeprecated::bleConnectionWithoutVideo() { _ledkit.start(&led::animation::ble_connection); } -void BehaviorKit::bleConnectionWithVideo() +void BehaviorKitDeprecated::bleConnectionWithVideo() { _ledkit.start(&led::animation::ble_connection); _videokit.playVideoOnce(fs::home::vid::system::robot_system_ble_connection_wink_no_eyebrows); } -void BehaviorKit::working() +void BehaviorKitDeprecated::working() { _videokit.displayImage(fs::home::img::system::robot_face_smiling_slightly); } -void BehaviorKit::fileExchange() +void BehaviorKitDeprecated::fileExchange() { // TODO(@ladislas): add file exchange image _videokit.displayImage("/fs/home/img/system/robot-file_exchange.jpg"); } -void BehaviorKit::stop() +void BehaviorKitDeprecated::stop() { _ledkit.stop(); _videokit.stopVideo(); diff --git a/libs/BehaviorKit/tests/BehaviorKit_test.cpp b/libs/BehaviorKitDeprecated/tests/BehaviorKitDeprecated_test.cpp similarity index 75% rename from libs/BehaviorKit/tests/BehaviorKit_test.cpp rename to libs/BehaviorKitDeprecated/tests/BehaviorKitDeprecated_test.cpp index 76ac9973d2..22e7978f02 100644 --- a/libs/BehaviorKit/tests/BehaviorKit_test.cpp +++ b/libs/BehaviorKitDeprecated/tests/BehaviorKitDeprecated_test.cpp @@ -2,7 +2,7 @@ // Copyright 2022 APF France handicap // SPDX-License-Identifier: Apache-2.0 -#include "BehaviorKit.h" +#include "BehaviorKitDeprecated.h" #include "LedKitAnimations.h" #include "gmock/gmock.h" @@ -21,10 +21,10 @@ MATCHER_P(isSameAnimation, expected_animation_type, "") return is_same; } -class BehaviorKitTest : public ::testing::Test +class BehaviorKitDeprecatedTest : public ::testing::Test { protected: - BehaviorKitTest() : behaviorkit(mock_videokit, mock_ledkit, mock_motor_left, mock_motor_right) {}; + BehaviorKitDeprecatedTest() : behaviorkit(mock_videokit, mock_ledkit, mock_motor_left, mock_motor_right) {}; // void SetUp() override {} // void TearDown() override {} @@ -36,15 +36,15 @@ class BehaviorKitTest : public ::testing::Test mock::CoreMotor mock_motor_left {}; mock::CoreMotor mock_motor_right {}; - BehaviorKit behaviorkit; + BehaviorKitDeprecated behaviorkit; }; -TEST_F(BehaviorKitTest, initialization) +TEST_F(BehaviorKitDeprecatedTest, initialization) { ASSERT_NE(&behaviorkit, nullptr); } -TEST_F(BehaviorKitTest, spinLeftAnySpeed) +TEST_F(BehaviorKitDeprecatedTest, spinLeftAnySpeed) { auto expected_speed = 0.7; @@ -54,7 +54,7 @@ TEST_F(BehaviorKitTest, spinLeftAnySpeed) behaviorkit.spinLeft(expected_speed); } -TEST_F(BehaviorKitTest, spinRightAnySpeed) +TEST_F(BehaviorKitDeprecatedTest, spinRightAnySpeed) { auto expected_speed = 0.3; @@ -64,13 +64,13 @@ TEST_F(BehaviorKitTest, spinRightAnySpeed) behaviorkit.spinRight(expected_speed); } -TEST_F(BehaviorKitTest, launching) +TEST_F(BehaviorKitDeprecatedTest, launching) { EXPECT_CALL(mock_videokit, displayImage); behaviorkit.launching(); } -TEST_F(BehaviorKitTest, sleeping) +TEST_F(BehaviorKitDeprecatedTest, sleeping) { EXPECT_CALL(mock_videokit, playVideoOnce); EXPECT_CALL(mock_ledkit, start(isSameAnimation(&led::animation::sleeping))).Times(1); @@ -78,14 +78,14 @@ TEST_F(BehaviorKitTest, sleeping) behaviorkit.sleeping(); } -TEST_F(BehaviorKitTest, waiting) +TEST_F(BehaviorKitDeprecatedTest, waiting) { EXPECT_CALL(mock_ledkit, stop); EXPECT_CALL(mock_videokit, playVideoOnRepeat); behaviorkit.waiting(); } -TEST_F(BehaviorKitTest, batteryBehaviors) +TEST_F(BehaviorKitDeprecatedTest, batteryBehaviors) { EXPECT_CALL(mock_videokit, displayImage).Times(6); EXPECT_CALL(mock_ledkit, stop); @@ -100,7 +100,7 @@ TEST_F(BehaviorKitTest, batteryBehaviors) behaviorkit.chargingFull(); } -TEST_F(BehaviorKitTest, bleConnectionWithoutVideo) +TEST_F(BehaviorKitDeprecatedTest, bleConnectionWithoutVideo) { EXPECT_CALL(mock_videokit, playVideoOnce).Times(0); EXPECT_CALL(mock_ledkit, start(isSameAnimation(&led::animation::ble_connection))).Times(1); @@ -108,7 +108,7 @@ TEST_F(BehaviorKitTest, bleConnectionWithoutVideo) behaviorkit.bleConnectionWithoutVideo(); } -TEST_F(BehaviorKitTest, bleConnectionWithVideo) +TEST_F(BehaviorKitDeprecatedTest, bleConnectionWithVideo) { EXPECT_CALL(mock_videokit, playVideoOnce); EXPECT_CALL(mock_ledkit, start(isSameAnimation(&led::animation::ble_connection))).Times(1); @@ -116,19 +116,19 @@ TEST_F(BehaviorKitTest, bleConnectionWithVideo) behaviorkit.bleConnectionWithVideo(); } -TEST_F(BehaviorKitTest, working) +TEST_F(BehaviorKitDeprecatedTest, working) { EXPECT_CALL(mock_videokit, displayImage); behaviorkit.working(); } -TEST_F(BehaviorKitTest, fileExchange) +TEST_F(BehaviorKitDeprecatedTest, fileExchange) { EXPECT_CALL(mock_videokit, displayImage); behaviorkit.fileExchange(); } -TEST_F(BehaviorKitTest, stop) +TEST_F(BehaviorKitDeprecatedTest, stop) { EXPECT_CALL(mock_ledkit, stop); EXPECT_CALL(mock_videokit, stopVideo); diff --git a/libs/CMakeLists.txt b/libs/CMakeLists.txt index f498e76cf5..c70dc14560 100644 --- a/libs/CMakeLists.txt +++ b/libs/CMakeLists.txt @@ -4,7 +4,7 @@ add_subdirectory(${LIBS_DIR}/ActivityKit) add_subdirectory(${LIBS_DIR}/BatteryKit) -add_subdirectory(${LIBS_DIR}/BehaviorKit) +add_subdirectory(${LIBS_DIR}/BehaviorKitDeprecated) add_subdirectory(${LIBS_DIR}/BLEKit) add_subdirectory(${LIBS_DIR}/ColorKit) add_subdirectory(${LIBS_DIR}/CommandKit) diff --git a/libs/RobotKit/CMakeLists.txt b/libs/RobotKit/CMakeLists.txt index 2d03e705f8..fa7378d7d0 100644 --- a/libs/RobotKit/CMakeLists.txt +++ b/libs/RobotKit/CMakeLists.txt @@ -26,7 +26,7 @@ target_link_libraries(RobotKit FileManagerKit CoreMutex VideoKit - BehaviorKit + BehaviorKitDeprecated CommandKit RFIDKit ActivityKit diff --git a/libs/RobotKit/include/RobotController.h b/libs/RobotKit/include/RobotController.h index 86f5c04d51..e93afeefcf 100644 --- a/libs/RobotKit/include/RobotController.h +++ b/libs/RobotKit/include/RobotController.h @@ -19,7 +19,7 @@ #include "ActivityKit.h" #include "BatteryKit.h" -#include "BehaviorKit.h" +#include "BehaviorKitDeprecated.h" #include "CommandKit.h" #include "ConfigKit.h" #include "CoreMutex.h" @@ -54,7 +54,7 @@ class RobotController : public interface::RobotController SerialNumberKit &serialnumberkit, interface::FirmwareUpdate &firmware_update, interface::Motor &motor_left, interface::Motor &motor_right, interface::LED &ears, interface::LED &belt, interface::LedKit &ledkit, interface::LCD &lcd, - interface::VideoKit &videokit, BehaviorKit &behaviorkit, CommandKit &cmdkit, + interface::VideoKit &videokit, BehaviorKitDeprecated &behaviorkit, CommandKit &cmdkit, RFIDKit &rfidkit, ActivityKit &activitykit) : _timeout_state_internal(timeout_state_internal), _timeout_state_transition(timeout_state_transition), @@ -580,7 +580,7 @@ class RobotController : public interface::RobotController RFIDKit &_rfidkit; ActivityKit &_activitykit; - BehaviorKit &_behaviorkit; + BehaviorKitDeprecated &_behaviorkit; CommandKit &_cmdkit; rtos::Thread _thread {}; diff --git a/libs/RobotKit/tests/RobotController_test.h b/libs/RobotKit/tests/RobotController_test.h index 840c2f6eaa..24e299a0cf 100644 --- a/libs/RobotKit/tests/RobotController_test.h +++ b/libs/RobotKit/tests/RobotController_test.h @@ -10,7 +10,7 @@ #include "ble_mocks.h" #include "ActivityKit.h" -#include "BehaviorKit.h" +#include "BehaviorKitDeprecated.h" #include "CommandKit.h" #include "CoreBufferedSerial.h" #include "CorePwm.h" @@ -99,7 +99,7 @@ class RobotControllerTest : public testing::Test mock::CoreLCD mock_lcd {}; mock::VideoKit mock_videokit {}; - BehaviorKit bhvkit {mock_videokit, mock_ledkit, mock_motor_left, mock_motor_right}; + BehaviorKitDeprecated bhvkit {mock_videokit, mock_ledkit, mock_motor_left, mock_motor_right}; CoreBufferedSerial serial {RFID_UART_TX, RFID_UART_RX, 57600}; CoreRFIDReaderCR95HF reader {serial}; diff --git a/spikes/lk_activity_kit/CMakeLists.txt b/spikes/lk_activity_kit/CMakeLists.txt index d551bd3a0f..476f9b47d0 100644 --- a/spikes/lk_activity_kit/CMakeLists.txt +++ b/spikes/lk_activity_kit/CMakeLists.txt @@ -17,7 +17,7 @@ target_sources(spike_lk_activity_kit target_link_libraries(spike_lk_activity_kit CoreTimeout FileManagerKit - BehaviorKit + BehaviorKitDeprecated CorePwm CoreMotor VideoKit diff --git a/spikes/lk_activity_kit/main.cpp b/spikes/lk_activity_kit/main.cpp index 453d817223..cd1a844b59 100644 --- a/spikes/lk_activity_kit/main.cpp +++ b/spikes/lk_activity_kit/main.cpp @@ -10,7 +10,7 @@ #include "rtos/Thread.h" #include "ActivityKit.h" -#include "BehaviorKit.h" +#include "BehaviorKitDeprecated.h" #include "ChooseReinforcer.h" #include "CoreBufferedSerial.h" #include "CoreDMA2D.hpp" @@ -209,7 +209,7 @@ namespace motion::internal { auto motionkit = MotionKit {motors::left::motor, motors::right::motor, imukit, motion::internal::timeout}; -auto behaviorkit = BehaviorKit {videokit, ledkit, motors::left::motor, motors::right::motor}; +auto behaviorkit = BehaviorKitDeprecated {videokit, ledkit, motors::left::motor, motors::right::motor}; auto reinforcerkit = ReinforcerKit {videokit, ledkit, motionkit}; namespace rfid { diff --git a/spikes/lk_behavior_kit/CMakeLists.txt b/spikes/lk_behavior_kit/CMakeLists.txt index 346086848f..b5e0ae0976 100644 --- a/spikes/lk_behavior_kit/CMakeLists.txt +++ b/spikes/lk_behavior_kit/CMakeLists.txt @@ -15,7 +15,7 @@ target_sources(spike_lk_behavior_kit ) target_link_libraries(spike_lk_behavior_kit - BehaviorKit + BehaviorKitDeprecated CorePwm EventLoopKit ) diff --git a/spikes/lk_behavior_kit/main.cpp b/spikes/lk_behavior_kit/main.cpp index 5eb6f7c0c8..0ac9f0a5dc 100644 --- a/spikes/lk_behavior_kit/main.cpp +++ b/spikes/lk_behavior_kit/main.cpp @@ -7,7 +7,7 @@ #include "drivers/HighResClock.h" #include "rtos/ThisThread.h" -#include "BehaviorKit.h" +#include "BehaviorKitDeprecated.h" #include "CoreDMA2D.hpp" #include "CoreDSI.hpp" #include "CoreFont.hpp" @@ -172,7 +172,7 @@ namespace display { } // namespace display -auto behaviorkit = BehaviorKit {display::videokit, leds::kit, motors::left::motor, motors::right::motor}; +auto behaviorkit = BehaviorKitDeprecated {display::videokit, leds::kit, motors::left::motor, motors::right::motor}; auto hello = HelloWorld {}; } // namespace diff --git a/spikes/lk_command_kit/CMakeLists.txt b/spikes/lk_command_kit/CMakeLists.txt index 1e9bf3303a..1b04d02f8c 100644 --- a/spikes/lk_command_kit/CMakeLists.txt +++ b/spikes/lk_command_kit/CMakeLists.txt @@ -19,7 +19,7 @@ target_link_libraries(spike_lk_command_kit CoreMotor CorePwm CoreSPI - BehaviorKit + BehaviorKitDeprecated CommandKit LedKit VideoKit diff --git a/tests/unit/CMakeLists.txt b/tests/unit/CMakeLists.txt index ac790e5550..d5af3a081d 100644 --- a/tests/unit/CMakeLists.txt +++ b/tests/unit/CMakeLists.txt @@ -281,7 +281,7 @@ leka_register_unit_tests_for_driver(CoreVideo) # Register libraries leka_register_unit_tests_for_library(ActivityKit) leka_register_unit_tests_for_library(BatteryKit) -leka_register_unit_tests_for_library(BehaviorKit) +leka_register_unit_tests_for_library(BehaviorKitDeprecated) leka_register_unit_tests_for_library(BLEKit) leka_register_unit_tests_for_library(ColorKit) leka_register_unit_tests_for_library(CommandKit)