Skip to content

Variable Stiffness Controller#46

Merged
danielsanjosepro merged 9 commits intolearnsyslab:mainfrom
KAIST-IRiS-Haptics-Telerobotics:feature/variable-stiffness-impedance
Apr 2, 2026
Merged

Variable Stiffness Controller#46
danielsanjosepro merged 9 commits intolearnsyslab:mainfrom
KAIST-IRiS-Haptics-Telerobotics:feature/variable-stiffness-impedance

Conversation

@domrachev03
Copy link
Copy Markdown
Contributor

Runtime Variable Stiffness for Cartesian Impedance Controller

Summary

  • Add runtime variable stiffness support to CartesianController via a ROS2 topic

Motivation

Some modern learning-based approaches, such as Advanced Compliance Policy suggest extending the action space of the policy with stiffness prediction, for Variable Stiffness Controller. This could be easily supported by crisp_controllers as well with minimal changes. This PR does exactly that

Behaviour

This PR adds a topic-based override: publishing a std_msgs/Float64MultiArray with 6 elements to the target_stiffness topic immediately overrides the stiffness matrix. The pipeline is as follows:

  1. On startup, stiffness comes from parameters (existing behaviour, unchanged)
  2. When a message is published to target_stiffness, the controller clips impedance to bounds and switches to using the topic-provided stiffness
  3. The topic stiffness persists indefinitely until overridden by another message

Testing

From command line

# Set stiffness: [k_pos_x, k_pos_y, k_pos_z, k_rot_x, k_rot_y, k_rot_z]
ros2 topic pub --once /target_stiffness std_msgs/msg/Float64MultiArray \
  "{data: [900.0, 900.0, 900.0, 45.0, 45.0, 45.0]}"

# Lower stiffness for compliant behaviour
ros2 topic pub --once /target_stiffness std_msgs/msg/Float64MultiArray \
  "{data: [50.0, 50.0, 50.0, 5.0, 5.0, 5.0]}"

Parameters Added

variable_stiffness:
  enabled:       # bool, default false (unused — subscriber always created)
  topic:         # string, default "target_stiffness"

Notes

  • To use this functionality, we need to extend crisp_py by adding one more method to the robot class. The implementation is ready and tested, so if you're interested in adding this feature, we're ready to open PR in crisp_py as well
  • Special thanks to @lvjonok for participating in the discussion & preliminary review process.

Add ability to update Cartesian stiffness at runtime through a
std_msgs/Float64MultiArray topic (6 elements: diagonal stiffness).
Gated behind variable_stiffness.enabled parameter (default: false).
Uses RealtimeBuffer pattern consistent with existing target_wrench.
Damping remains parameter-controlled only.
Copy link
Copy Markdown
Collaborator

@danielsanjosepro danielsanjosepro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey! Thank you a lot for the addition. It is definitely a nice feature (better than calling params services to modify it). I just left a few comments but it definitely looks good :)

Comment thread src/cartesian_controller.cpp Outdated
Comment on lines +648 to +653
RCLCPP_INFO(get_node()->get_logger(),
"Variable stiffness received: [%.1f, %.1f, %.1f, %.1f, %.1f, %.1f]",
msg->data[0], msg->data[1], msg->data[2],
msg->data[3], msg->data[4], msg->data[5]);
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will spam messages if we are constantly changing stiffness, consider removing this or throttle it. Alternatively add a param to trigger logging

Comment thread src/cartesian_controller.yaml Outdated
Comment on lines +316 to +328
max_stiffness:
translational:
type: double
default_value: 900.0
description: "Maximum allowed translational stiffness value. Stiffness values above this will be clamped."
validation:
bounds<>: [0.0, 5000.0]
rotational:
type: double
default_value: 60.0
description: "Maximum allowed rotational stiffness value. Stiffness values above this will be clamped."
validation:
bounds<>: [0.0, 100.0]
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file already defines stiffness bounds (see a few lines above). The bounds here are below what we defined above. Probably it makes sense to call this variable_max_stiffness or something similar to not confuse it with the other one

@domrachev03
Copy link
Copy Markdown
Contributor Author

@danielsanjosepro thank you for your comments, I believe I've fixed both issues

@domrachev03
Copy link
Copy Markdown
Contributor Author

Hey, so what is the status of this PR? We've addressed your comments, so I wonder whether we could proceed further? Or should we make further changes?

@danielsanjosepro
Copy link
Copy Markdown
Collaborator

It lools good to me thanks for this!!

@danielsanjosepro danielsanjosepro merged commit 2fc192d into learnsyslab:main Apr 2, 2026
3 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants