Skip to content

Commit

Permalink
do that with all moves
Browse files Browse the repository at this point in the history
  • Loading branch information
ahiuchingau committed Nov 7, 2024
1 parent 16f3241 commit b39e28a
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions stm32-modules/include/flex-stacker/flex-stacker/motor_task.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,11 @@ class MotorTask {
auto visit_message(const messages::MoveMotorInStepsMessage& m,
Policy& policy) -> void {
static_cast<void>(policy);
auto error = all_motors_idle();
if (error != Error::NO_ERROR) {
send_ack_message(m.id, error);
return;
}
auto direction = m.steps > 0;
controller_from_id(m.motor_id)
.start_fixed_movement(m.id, direction, std::abs(m.steps), 0,
Expand All @@ -288,6 +293,11 @@ class MotorTask {
auto visit_message(const messages::MoveMotorInMmMessage& m, Policy& policy)
-> void {
static_cast<void>(policy);
auto error = all_motors_idle();
if (error != Error::NO_ERROR) {
send_ack_message(m.id, error);
return;
}
Controller& controller = controller_from_id(m.motor_id);
MotorState& state = motor_state(m.motor_id);
auto direction = m.mm > 0;
Expand All @@ -309,6 +319,11 @@ class MotorTask {
auto visit_message(const messages::MoveToLimitSwitchMessage& m,
Policy& policy) -> void {
static_cast<void>(policy);
auto error = all_motors_idle();
if (error != Error::NO_ERROR) {
send_ack_message(m.id, error);
return;
}
Controller& controller = controller_from_id(m.motor_id);
MotorState& state = motor_state(m.motor_id);
if (m.mm_per_second.has_value()) {
Expand Down

0 comments on commit b39e28a

Please sign in to comment.