@@ -90,17 +90,17 @@ bool fastcat::Actuator::CheckStateMachineGainSchedulingCmds()
90
90
91
91
bool fastcat::Actuator::HandleNewCSPCmd (DeviceCmd& cmd)
92
92
{
93
- // Check that the command can be honored within FSM state
94
- if (!CheckStateMachineMotionCmds ()) {
93
+ // Validate the command arguments
94
+ if (PosExceedsCmdLimits (cmd.actuator_csp_cmd .target_position +
95
+ cmd.actuator_csp_cmd .position_offset ) ||
96
+ VelExceedsCmdLimits (cmd.actuator_csp_cmd .velocity_offset )) {
95
97
TransitionToState (ACTUATOR_SMS_FAULTED);
96
98
ERROR (" Act %s: %s" , name_.c_str (), " Failing CSP Command" );
97
99
return false ;
98
100
}
99
101
100
- // Validate the command arguments
101
- if (PosExceedsCmdLimits (cmd.actuator_csp_cmd .target_position +
102
- cmd.actuator_csp_cmd .position_offset ) ||
103
- VelExceedsCmdLimits (cmd.actuator_csp_cmd .velocity_offset )) {
102
+ // Check that the command can be honored within FSM state
103
+ if (!CheckStateMachineMotionCmds ()) {
104
104
TransitionToState (ACTUATOR_SMS_FAULTED);
105
105
ERROR (" Act %s: %s" , name_.c_str (), " Failing CSP Command" );
106
106
return false ;
@@ -121,16 +121,16 @@ bool fastcat::Actuator::HandleNewCSPCmd(DeviceCmd& cmd)
121
121
122
122
bool fastcat::Actuator::HandleNewCSVCmd (DeviceCmd& cmd)
123
123
{
124
- // Check that the command can be honored within FSM state
125
- if (!CheckStateMachineMotionCmds ()) {
124
+ // Validate command arguments
125
+ if (VelExceedsCmdLimits (cmd.actuator_csv_cmd .target_velocity +
126
+ cmd.actuator_csv_cmd .velocity_offset )) {
126
127
TransitionToState (ACTUATOR_SMS_FAULTED);
127
128
ERROR (" Act %s: %s" , name_.c_str (), " Failing CSV Command" );
128
129
return false ;
129
130
}
130
131
131
- // Validate command arguments
132
- if (VelExceedsCmdLimits (cmd.actuator_csv_cmd .target_velocity +
133
- cmd.actuator_csv_cmd .velocity_offset )) {
132
+ // Check that the command can be honored within FSM state
133
+ if (!CheckStateMachineMotionCmds ()) {
134
134
TransitionToState (ACTUATOR_SMS_FAULTED);
135
135
ERROR (" Act %s: %s" , name_.c_str (), " Failing CSV Command" );
136
136
return false ;
@@ -150,16 +150,16 @@ bool fastcat::Actuator::HandleNewCSVCmd(DeviceCmd& cmd)
150
150
151
151
bool fastcat::Actuator::HandleNewCSTCmd (DeviceCmd& cmd)
152
152
{
153
- // Check that the command can be honored within FSM state
154
- if (!CheckStateMachineMotionCmds ()) {
153
+ // Validate command arguments
154
+ if (CurrentExceedsCmdLimits (cmd.actuator_cst_cmd .target_torque_amps +
155
+ cmd.actuator_cst_cmd .torque_offset_amps )) {
155
156
TransitionToState (ACTUATOR_SMS_FAULTED);
156
157
ERROR (" Act %s: %s" , name_.c_str (), " Failing CST Command" );
157
158
return false ;
158
159
}
159
160
160
- // Validate command arguments
161
- if (CurrentExceedsCmdLimits (cmd.actuator_cst_cmd .target_torque_amps +
162
- cmd.actuator_cst_cmd .torque_offset_amps )) {
161
+ // Check that the command can be honored within FSM state
162
+ if (!CheckStateMachineMotionCmds ()) {
163
163
TransitionToState (ACTUATOR_SMS_FAULTED);
164
164
ERROR (" Act %s: %s" , name_.c_str (), " Failing CST Command" );
165
165
return false ;
@@ -178,13 +178,6 @@ bool fastcat::Actuator::HandleNewCSTCmd(DeviceCmd& cmd)
178
178
179
179
bool fastcat::Actuator::HandleNewProfPosCmd (DeviceCmd& cmd)
180
180
{
181
- // Check that the command can be honored within FSM state
182
- if (!CheckStateMachineMotionCmds ()) {
183
- TransitionToState (ACTUATOR_SMS_FAULTED);
184
- ERROR (" Act %s: %s" , name_.c_str (), " Failing Prof Pos Command" );
185
- return false ;
186
- }
187
-
188
181
double target_position = 0 ;
189
182
if (cmd.actuator_prof_pos_cmd .relative ) {
190
183
target_position = cmd.actuator_prof_pos_cmd .target_position +
@@ -203,6 +196,13 @@ bool fastcat::Actuator::HandleNewProfPosCmd(DeviceCmd& cmd)
203
196
return false ;
204
197
}
205
198
199
+ // Check that the command can be honored within FSM state
200
+ if (!CheckStateMachineMotionCmds ()) {
201
+ TransitionToState (ACTUATOR_SMS_FAULTED);
202
+ ERROR (" Act %s: %s" , name_.c_str (), " Failing Prof Pos Command" );
203
+ return false ;
204
+ }
205
+
206
206
// Only transition to disengaging if its needed
207
207
if (state_->actuator_state .servo_enabled ){
208
208
// Bypassing wait since brakes are disengaged
@@ -227,15 +227,15 @@ bool fastcat::Actuator::HandleNewProfPosCmd(DeviceCmd& cmd)
227
227
228
228
bool fastcat::Actuator::HandleNewProfVelCmd (DeviceCmd& cmd)
229
229
{
230
- // Check that the command can be honored within FSM state
231
- if (! CheckStateMachineMotionCmds ( )) {
230
+ if ( VelExceedsCmdLimits (cmd. actuator_prof_vel_cmd . target_velocity ) ||
231
+ AccExceedsCmdLimits (cmd. actuator_prof_vel_cmd . profile_accel )) {
232
232
TransitionToState (ACTUATOR_SMS_FAULTED);
233
233
ERROR (" Act %s: %s" , name_.c_str (), " Failing Prof Vel Command" );
234
234
return false ;
235
235
}
236
236
237
- if ( VelExceedsCmdLimits (cmd. actuator_prof_vel_cmd . target_velocity ) ||
238
- AccExceedsCmdLimits (cmd. actuator_prof_vel_cmd . profile_accel )) {
237
+ // Check that the command can be honored within FSM state
238
+ if (! CheckStateMachineMotionCmds ( )) {
239
239
TransitionToState (ACTUATOR_SMS_FAULTED);
240
240
ERROR (" Act %s: %s" , name_.c_str (), " Failing Prof Vel Command" );
241
241
return false ;
@@ -265,15 +265,15 @@ bool fastcat::Actuator::HandleNewProfVelCmd(DeviceCmd& cmd)
265
265
266
266
bool fastcat::Actuator::HandleNewProfTorqueCmd (DeviceCmd& cmd)
267
267
{
268
- // Check that the command can be honored within FSM state
269
- if (! CheckStateMachineMotionCmds ( )) {
268
+ if ( CurrentExceedsCmdLimits (
269
+ cmd. actuator_prof_torque_cmd . target_torque_amps )) {
270
270
TransitionToState (ACTUATOR_SMS_FAULTED);
271
271
ERROR (" Act %s: %s" , name_.c_str (), " Failing Prof Torque Command" );
272
272
return false ;
273
273
}
274
-
275
- if ( CurrentExceedsCmdLimits (
276
- cmd. actuator_prof_torque_cmd . target_torque_amps )) {
274
+
275
+ // Check that the command can be honored within FSM state
276
+ if (! CheckStateMachineMotionCmds ( )) {
277
277
TransitionToState (ACTUATOR_SMS_FAULTED);
278
278
ERROR (" Act %s: %s" , name_.c_str (), " Failing Prof Torque Command" );
279
279
return false ;
0 commit comments