@@ -255,11 +255,23 @@ bool VanillaCartesianImpedanceRule::compute_controls(
255
255
auto error_position_nullspace = \
256
256
vic_input_data.nullspace_desired_joint_positions - vic_input_data.joint_state_position ;
257
257
// Add nullspace contribution to joint accelerations
258
- vic_command_data.joint_command_acceleration += nullspace_projection_ * M_inv_nullspace_ * (
259
- -D_nullspace_ * vic_input_data.joint_state_velocity +
260
- K_nullspace_ * error_position_nullspace +
261
- external_joint_torques_
262
- );
258
+ if (vic_input_data.has_external_torque_sensor ()) {
259
+ RCLCPP_DEBUG (logger_, " Cmd nullspace joint acc with external torques..." );
260
+ vic_command_data.joint_command_acceleration += nullspace_projection_ * M_inv_nullspace_ * (
261
+ -D_nullspace_ * vic_input_data.joint_state_velocity +
262
+ K_nullspace_ * error_position_nullspace +
263
+ external_joint_torques_
264
+ );
265
+ } else {
266
+ // Use natural joint space inertia
267
+ RCLCPP_DEBUG (
268
+ logger_,
269
+ " Cmd nullspace joint acc with natural joint inertia (no ext torque sensor)..." );
270
+ vic_command_data.joint_command_acceleration += nullspace_projection_ * (
271
+ -D_nullspace_ * vic_input_data.joint_state_velocity +
272
+ K_nullspace_ * error_position_nullspace
273
+ );
274
+ }
263
275
} else {
264
276
// Pure (small) damping in nullspace for stability
265
277
RCLCPP_WARN_THROTTLE (
@@ -283,9 +295,9 @@ bool VanillaCartesianImpedanceRule::compute_controls(
283
295
// J_.transpose() * (vic_input_data.natural_cartesian_inertia * M_inv - I_) * F_ext;
284
296
} else {
285
297
raw_joint_command_effort_ = \
286
- vic_input_data.natural_joint_space_inertia .diagonal ().asDiagonal ()
287
- * vic_command_data.joint_command_acceleration
288
- + J_.transpose () * F_ext;
298
+ vic_input_data.natural_joint_space_inertia .diagonal ().asDiagonal () *
299
+ vic_command_data.joint_command_acceleration +
300
+ J_.transpose () * F_ext;
289
301
}
290
302
291
303
// Gravity compensation
0 commit comments