Skip to content

Commit

Permalink
fix(motor-control): add a state to the motor control that maintains t…
Browse files Browse the repository at this point in the history
…he difference between a never homed and a stopped gripper
  • Loading branch information
ryanthecoder committed Nov 15, 2024
1 parent 9b4907f commit a9aa868
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ class BrushedMotorInterruptHandler {
cancel_and_clear_moves(can::ids::ErrorCode::estop_detected);
} else if (hardware.has_cancel_request()) {
if (!hardware.get_stay_enabled()) {
hardware.set_motor_state(BrushedMotorState::UNHOMED);
hardware.set_motor_state(BrushedMotorState::STOPPED);
}
cancel_and_clear_moves(can::ids::ErrorCode::stop_requested,
can::ids::ErrorSeverity::warning);
Expand Down
5 changes: 3 additions & 2 deletions include/motor-control/core/types.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,6 @@ enum class BrushedMotorState : uint8_t {
UNHOMED = 0x0,
FORCE_CONTROLLING_HOME = 0x1,
FORCE_CONTROLLING = 0x2,
POSITION_CONTROLLING = 0x3
};
POSITION_CONTROLLING = 0x3,
STOPPED = 0x4
};
8 changes: 4 additions & 4 deletions motor-control/tests/test_brushed_motor_interrupt_handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -526,10 +526,10 @@ SCENARIO("handler recovers from error state") {
test_objs.hw.request_cancel();
test_objs.handler.run_interrupt();
THEN(
"motor state should become un-homed only if stay engaged is "
"falsy") {
"motor state should become stopped only if stay engaged is "
"false") {
REQUIRE(test_objs.hw.get_motor_state() ==
(!stay_engaged ? BrushedMotorState::UNHOMED
(!stay_engaged ? BrushedMotorState::STOPPED
: og_motor_state));
}
THEN("a stop requested warning is issued") {
Expand Down Expand Up @@ -560,4 +560,4 @@ SCENARIO("handler recovers from error state") {
}
}
}
}
}

0 comments on commit a9aa868

Please sign in to comment.