Skip to content

Commit 2c7f5d8

Browse files
Modified code to only check for SWITCHED ON as an error state once motion begins
1 parent c494a1c commit 2c7f5d8

3 files changed

Lines changed: 25 additions & 0 deletions

File tree

src/jsd/actuator.cc

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ fastcat::Actuator::Actuator()
2525
bool fastcat::Actuator::ConfigFromYaml(const YAML::Node& node)
2626
{
2727
actuator_sms_ = ACTUATOR_SMS_HALTED;
28+
elmo_state_machine_state_initialized_ = false;
29+
last_elmo_state_machine_state_ =
30+
JSD_ELMO_STATE_MACHINE_STATE_NOT_READY_TO_SWITCH_ON;
2831

2932
// monotonic_initialization_time_sec_ set by base class method
3033
// SetInitializationTime, which must be called prior to ConfigFromYaml
@@ -228,6 +231,10 @@ bool fastcat::Actuator::Read()
228231
{
229232
ElmoRead();
230233
PopulateState();
234+
if (!elmo_state_machine_state_initialized_) {
235+
last_elmo_state_machine_state_ = GetElmoStateMachineState();
236+
elmo_state_machine_state_initialized_ = true;
237+
}
231238
return true;
232239
}
233240

@@ -486,6 +493,10 @@ fastcat::FaultType fastcat::Actuator::Process()
486493
break;
487494
}
488495

496+
if (elmo_state_machine_state_initialized_) {
497+
last_elmo_state_machine_state_ = GetElmoStateMachineState();
498+
}
499+
489500
ElmoProcess();
490501
return retval;
491502
}

src/jsd/actuator.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,9 @@ class Actuator : public JsdDeviceBase
262262

263263
bool actuator_absolute_encoder_ = false;
264264
int32_t elmo_pos_offset_cnts_ = 1;
265+
bool elmo_state_machine_state_initialized_ = false;
266+
jsd_elmo_state_machine_state_t last_elmo_state_machine_state_ =
267+
JSD_ELMO_STATE_MACHINE_STATE_NOT_READY_TO_SWITCH_ON;
265268
RingBuffer<DeviceCmd> last_device_cmd_ = RingBuffer<DeviceCmd>(50);
266269
double csp_interpolation_offset_time_ = 0.0;
267270
size_t csp_cycles_delay_ = 4;

src/jsd/actuator_fsm_helpers.cc

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -547,6 +547,17 @@ bool fastcat::Actuator::IsMotionFaultConditionMet()
547547
return true;
548548
}
549549
auto elmo_state_machine_state = GetElmoStateMachineState();
550+
if (elmo_state_machine_state_initialized_ &&
551+
last_elmo_state_machine_state_ ==
552+
JSD_ELMO_STATE_MACHINE_STATE_OPERATION_ENABLED &&
553+
elmo_state_machine_state == JSD_ELMO_STATE_MACHINE_STATE_SWITCHED_ON) {
554+
ERROR("%s: Elmo drive state machine transitioned from OPERATION_ENABLED "
555+
"to SWITCHED_ON during motion",
556+
name_.c_str());
557+
fastcat_fault_ = ACTUATOR_FASTCAT_FAULT_INVALID_ELMO_SMS_DURING_MOTION;
558+
return true;
559+
}
560+
550561
if (elmo_state_machine_state ==
551562
JSD_ELMO_STATE_MACHINE_STATE_QUICK_STOP_ACTIVE ||
552563
elmo_state_machine_state ==

0 commit comments

Comments
 (0)