File tree 3 files changed +12
-8
lines changed
include/motor-control/core
3 files changed +12
-8
lines changed Original file line number Diff line number Diff line change @@ -151,6 +151,7 @@ class BrushedMotorInterruptHandler {
151
151
can::ids::ErrorCode::collision_detected);
152
152
report_position (pulses);
153
153
error_handled = true ;
154
+ hardware.set_motor_state (BrushedMotorState::UNHOMED);
154
155
}
155
156
} else if (motor_state != BrushedMotorState::UNHOMED) {
156
157
auto pulses = hardware.get_encoder_pulses ();
@@ -166,6 +167,7 @@ class BrushedMotorInterruptHandler {
166
167
motor_state == BrushedMotorState::FORCE_CONTROLLING
167
168
? can::ids::ErrorCode::labware_dropped
168
169
: can::ids::ErrorCode::collision_detected;
170
+ hardware.set_motor_state (BrushedMotorState::UNHOMED);
169
171
cancel_and_clear_moves (err);
170
172
report_position (pulses);
171
173
error_handled = true ;
@@ -198,8 +200,9 @@ class BrushedMotorInterruptHandler {
198
200
in_estop = true ;
199
201
cancel_and_clear_moves (can::ids::ErrorCode::estop_detected);
200
202
} else if (hardware.has_cancel_request ()) {
201
- if (!hardware.get_stay_enabled ()) {
202
- hardware.set_motor_state (BrushedMotorState::UNHOMED);
203
+ if (!hardware.get_stay_enabled () &&
204
+ hardware.get_motor_state () != BrushedMotorState::UNHOMED) {
205
+ hardware.set_motor_state (BrushedMotorState::STOPPED);
203
206
}
204
207
cancel_and_clear_moves (can::ids::ErrorCode::stop_requested,
205
208
can::ids::ErrorSeverity::warning);
Original file line number Diff line number Diff line change @@ -44,5 +44,6 @@ enum class BrushedMotorState : uint8_t {
44
44
UNHOMED = 0x0 ,
45
45
FORCE_CONTROLLING_HOME = 0x1 ,
46
46
FORCE_CONTROLLING = 0x2 ,
47
- POSITION_CONTROLLING = 0x3
48
- };
47
+ POSITION_CONTROLLING = 0x3 ,
48
+ STOPPED = 0x4
49
+ };
Original file line number Diff line number Diff line change @@ -526,10 +526,10 @@ SCENARIO("handler recovers from error state") {
526
526
test_objs.hw .request_cancel ();
527
527
test_objs.handler .run_interrupt ();
528
528
THEN (
529
- " motor state should become un-homed only if stay engaged is "
530
- " falsy " ) {
529
+ " motor state should become stopped only if stay engaged is "
530
+ " false " ) {
531
531
REQUIRE (test_objs.hw .get_motor_state () ==
532
- (!stay_engaged ? BrushedMotorState::UNHOMED
532
+ (!stay_engaged ? BrushedMotorState::STOPPED
533
533
: og_motor_state));
534
534
}
535
535
THEN (" a stop requested warning is issued" ) {
@@ -560,4 +560,4 @@ SCENARIO("handler recovers from error state") {
560
560
}
561
561
}
562
562
}
563
- }
563
+ }
You can’t perform that action at this time.
0 commit comments