diff --git a/libs/RobotKit/include/RobotController.h b/libs/RobotKit/include/RobotController.h index affc92aea..0e194a3a5 100644 --- a/libs/RobotKit/include/RobotController.h +++ b/libs/RobotKit/include/RobotController.h @@ -477,7 +477,7 @@ class RobotController : public interface::RobotController } }); - auto on_low_battery = [this] { + _batterykit.onLowBattery([this] { if (!_batterykit.isCharging()) { _behaviorkit.lowBattery(); } @@ -485,8 +485,7 @@ class RobotController : public interface::RobotController if (_batterykit.level() == 0) { system_reset(); } - }; - _batterykit.onLowBattery(on_low_battery); + }); _batterykit.startEventHandler(); @@ -498,11 +497,9 @@ class RobotController : public interface::RobotController // Setup callbacks for each State Machine events - auto on_charge_did_start = [this]() { raise(event::charge_did_start {}); }; - _batterykit.onChargeDidStart(on_charge_did_start); + _batterykit.onChargeDidStart([this] { raise(event::charge_did_start {}); }); - auto on_charge_did_stop = [this]() { raise(event::charge_did_stop {}); }; - _batterykit.onChargeDidStop(on_charge_did_stop); + _batterykit.onChargeDidStop([this] { raise(event::charge_did_stop {}); }); _service_monitoring.onSoftReboot([] { system_reset(); }); @@ -512,7 +509,7 @@ class RobotController : public interface::RobotController std::ignore = _configkit.write(config_robot_name, robot_name); }); - auto on_commands_received = [this](std::span _buffer) { + _service_commands.onCommandsReceived([this](std::span _buffer) { raise(event::command_received {}); if (!isCharging()) { @@ -521,8 +518,7 @@ class RobotController : public interface::RobotController _cmdkit.push(std::span {_buffer.data(), std::size(_buffer)}); } - }; - _service_commands.onCommandsReceived(on_commands_received); + }); _service_file_exchange.onSetFileExchangeState([this](bool file_exchange_requested) { if (file_exchange_requested) { @@ -532,8 +528,7 @@ class RobotController : public interface::RobotController } }); - auto on_update_requested = [this]() { raise(event::update_requested {}); }; - _service_update.onUpdateRequested(on_update_requested); + _service_update.onUpdateRequested([this] { raise(event::update_requested {}); }); raise(event::setup_complete {}); }