Skip to content

Commit

Permalink
🚚 (BehaviorKit): Rename current BehaviorKit to BehaviorKitDeprecated
Browse files Browse the repository at this point in the history
  • Loading branch information
YannLocatelli committed Dec 14, 2023
1 parent 778bf10 commit 45bf26c
Show file tree
Hide file tree
Showing 16 changed files with 60 additions and 60 deletions.
2 changes: 1 addition & 1 deletion app/os/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ target_link_libraries(LekaOS
FileManagerKit
SerialNumberKit
FirmwareKit
BehaviorKit
BehaviorKitDeprecated
CorePwm
CoreMotor
VideoKit
Expand Down
2 changes: 1 addition & 1 deletion app/os/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,26 @@
# 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
)

if(${CMAKE_PROJECT_NAME} STREQUAL "LekaOSUnitTests")
leka_unit_tests_sources(
tests/BehaviorKit_test.cpp
tests/BehaviorKitDeprecated_test.cpp
)
endif()
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,107 +2,107 @@
// Copyright 2022 APF France handicap
// SPDX-License-Identifier: Apache-2.0

#include "BehaviorKit.h"
#include <fs_structure.hpp>

#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);
_motor_left.stop();
_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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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 {}
Expand All @@ -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;

Expand All @@ -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;

Expand All @@ -64,28 +64,28 @@ 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);

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);
Expand All @@ -100,35 +100,35 @@ 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);

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);

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);
Expand Down
2 changes: 1 addition & 1 deletion libs/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion libs/RobotKit/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ target_link_libraries(RobotKit
FileManagerKit
CoreMutex
VideoKit
BehaviorKit
BehaviorKitDeprecated
CommandKit
RFIDKit
ActivityKit
Expand Down
6 changes: 3 additions & 3 deletions libs/RobotKit/include/RobotController.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -52,7 +52,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),
Expand Down Expand Up @@ -590,7 +590,7 @@ class RobotController : public interface::RobotController
RFIDKit &_rfidkit;
ActivityKit &_activitykit;

BehaviorKit &_behaviorkit;
BehaviorKitDeprecated &_behaviorkit;
CommandKit &_cmdkit;

rtos::Thread _thread {};
Expand Down
4 changes: 2 additions & 2 deletions libs/RobotKit/tests/RobotController_test.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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};
Expand Down
2 changes: 1 addition & 1 deletion spikes/lk_activity_kit/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ target_sources(spike_lk_activity_kit
target_link_libraries(spike_lk_activity_kit
CoreTimeout
FileManagerKit
BehaviorKit
BehaviorKitDeprecated
CorePwm
CoreMotor
VideoKit
Expand Down
Loading

0 comments on commit 45bf26c

Please sign in to comment.