Skip to content

Commit 1768081

Browse files
author
Thibault Poignonec
committed
update nullspace control
1 parent 3619fed commit 1768081

File tree

1 file changed

+20
-8
lines changed

1 file changed

+20
-8
lines changed

cartesian_vic_controller/src/rules/vanilla_cartesian_impedance_rule.cpp

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -255,11 +255,23 @@ bool VanillaCartesianImpedanceRule::compute_controls(
255255
auto error_position_nullspace = \
256256
vic_input_data.nullspace_desired_joint_positions - vic_input_data.joint_state_position;
257257
// 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+
}
263275
} else {
264276
// Pure (small) damping in nullspace for stability
265277
RCLCPP_WARN_THROTTLE(
@@ -283,9 +295,9 @@ bool VanillaCartesianImpedanceRule::compute_controls(
283295
// J_.transpose() * (vic_input_data.natural_cartesian_inertia * M_inv - I_) * F_ext;
284296
} else {
285297
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;
289301
}
290302

291303
// Gravity compensation

0 commit comments

Comments
 (0)