From 6e4ca482bd27f8fdc3ec2a54ad6d32e7dbc3b2a0 Mon Sep 17 00:00:00 2001 From: ahiuchingau <20424172+ahiuchingau@users.noreply.github.com> Date: Tue, 19 Sep 2023 22:49:55 -0400 Subject: [PATCH] fix simulator --- .../simulation/brushed_motor_interrupt_driver.hpp | 4 ++-- include/motor-control/simulation/sim_motor_hardware_iface.hpp | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/include/motor-control/simulation/brushed_motor_interrupt_driver.hpp b/include/motor-control/simulation/brushed_motor_interrupt_driver.hpp index 7f1621329..fa9f75ddf 100644 --- a/include/motor-control/simulation/brushed_motor_interrupt_driver.hpp +++ b/include/motor-control/simulation/brushed_motor_interrupt_driver.hpp @@ -60,8 +60,8 @@ class BrushedMotorInterruptDriver { } handler.run_interrupt(); - } while (handler.motor_state == - brushed_motor_handler::ControlState::ACTIVE); + } while (iface.get_motor_state() == + BrushedMotorState::FORCE_CONTROLLING); LOG("Move completed. Stopping interrupt simulation.."); } } diff --git a/include/motor-control/simulation/sim_motor_hardware_iface.hpp b/include/motor-control/simulation/sim_motor_hardware_iface.hpp index 2a666a95f..2a8dd67cc 100644 --- a/include/motor-control/simulation/sim_motor_hardware_iface.hpp +++ b/include/motor-control/simulation/sim_motor_hardware_iface.hpp @@ -185,6 +185,9 @@ class SimBrushedMotorHardwareIface void disable_encoder() final {} void enable_encoder() final {} + void set_motor_state(BrushedMotorState state) final { motor_state = state; } + auto get_motor_state() -> BrushedMotorState final { return motor_state; } + private: bool stay_enabled = false; bool limit_switch_status = false; @@ -199,6 +202,7 @@ class SimBrushedMotorHardwareIface MoveMessageHardware _id; bool estop_detected = false; std::atomic cancel_request = false; + BrushedMotorState motor_state = BrushedMotorState::UNHOMED; motor_hardware::UsageEEpromConfig eeprom_config{ std::array{UsageRequestSet{ .eeprom_key = 0,