-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enforce joint position limits #275
Conversation
3d94caa
to
21d6e3d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great! I remember that with the old OOP APIs, the position limits enforced in this way were quite delicate. Regardless, it's well worth to have the previous logic ported to the new functional APIs. Can you make sure that your logic matches the previous one (that was only considering the damping component)?
Check also the previous PR #22.
jaxsim/src/jaxsim/simulation/ode.py
Lines 138 to 155 in 43a4aed
# ===================== | |
# Joint position limits | |
# ===================== | |
if physics_model.dofs() > 0: | |
# Get the joint position limits | |
s_min, s_max = jnp.array( | |
[j.position_limit for j in physics_model.description.joints_dict.values()] | |
).T | |
# Get the spring/damper parameters of joint limits enforcement | |
k_damper = jnp.array(list(physics_model._joint_limit_damper.values())) | |
# Compute the joint torques that enforce joint limits | |
s = ode_state.physics_model.joint_positions | |
tau_min = jnp.where(s <= s_min, k_damper * (s_min - s), 0) | |
tau_max = jnp.where(s >= s_max, k_damper * (s_max - s), 0) | |
tau_limit = tau_max + tau_min |
36c7a2d
to
746fa1e
Compare
@diegoferigo in 6a7dba2 I've added a fix for single-joint models, would you mind taking a look at that as well? Thanks :) |
Co-authored-by: Diego Ferigo <[email protected]>
Co-authored-by: Diego Ferigo <[email protected]>
746fa1e
to
2afa7a5
Compare
This PR adds support to joint limit torques.
Example behaviour:
single_pendulum.mp4
MWE
📚 Documentation preview 📚: https://jaxsim--275.org.readthedocs.build//275/