From 770188b932b8528df657a5eb45dd423560ff6af2 Mon Sep 17 00:00:00 2001 From: Yann Locatelli Date: Fri, 15 Dec 2023 18:04:06 +0100 Subject: [PATCH] Update spike --- spikes/lk_auto_charge/CMakeLists.txt | 1 + spikes/lk_auto_charge/main.cpp | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/spikes/lk_auto_charge/CMakeLists.txt b/spikes/lk_auto_charge/CMakeLists.txt index 3b7d6a4be4..08b8e02ced 100644 --- a/spikes/lk_auto_charge/CMakeLists.txt +++ b/spikes/lk_auto_charge/CMakeLists.txt @@ -28,6 +28,7 @@ target_link_libraries(spike_lk_auto_charge CoreI2C IMUKit BLEKit + BehaviorKit ) target_link_custom_leka_targets(spike_lk_auto_charge) diff --git a/spikes/lk_auto_charge/main.cpp b/spikes/lk_auto_charge/main.cpp index b291afa727..f7b0e5534f 100644 --- a/spikes/lk_auto_charge/main.cpp +++ b/spikes/lk_auto_charge/main.cpp @@ -10,6 +10,7 @@ #include "BLEServiceCommands.h" #include "BatteryKit.h" +#include "BehaviorKit.h" #include "CoreBattery.h" #include "CoreI2C.h" #include "CoreLSM6DSOX.hpp" @@ -24,6 +25,7 @@ #include "LogKit.h" #include "MathUtils.h" #include "SealStrategy.h" +#include "behaviors/AutochargeSeal.h" using namespace std::chrono; using namespace leka; @@ -100,6 +102,10 @@ auto service_commands = BLEServiceCommands {}; auto services = std::to_array({&service_commands}); auto blekit = BLEKit {}; +auto behavior_autocharge_seal = behavior::AutochargeSeal {motors::left::motor, motors::right::motor, imukit}; + +auto behavior_kit = BehaviorKit {event_loop}; + auto seal_strategy = SealStrategy {event_loop, timeout, battery::cells, motors::left::motor, motors::right::motor, imukit}; auto happy_toupie = HappyToupie {event_loop, timeout, battery::cells, motors::left::motor, motors::right::motor}; @@ -146,6 +152,11 @@ auto main() -> int service_commands.onCommandsReceived([](std::span _buffer) { runStrategy(_buffer[0]); }); blekit.init(); + auto behaviors = std::to_array({&behavior_autocharge_seal}); + behavior_kit.registerBehaviors(behaviors); + + behavior_kit.start(behavior_id::autocharge_seal); + while (true) { rtos::ThisThread::sleep_for(10min); }