Skip to content

Commit

Permalink
Refactor contact forces sum in api.ode.system_velocity_dynamics
Browse files Browse the repository at this point in the history
Co-authored-by: Alessandro Croci <[email protected]>
  • Loading branch information
flferretti and xela-95 committed Jun 14, 2024
1 parent 5dd2692 commit f3e35b1
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions src/jaxsim/api/ode.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,14 +150,12 @@ def system_velocity_dynamics(
# Sum the forces of all collidable points rigidly attached to a body.
# Since the contact forces W_f_Ci are expressed in the world frame,
# we don't need any coordinate transformation.
W_f_Li_terrain = jax.vmap(
lambda nc: (
jnp.vstack(
jnp.equal(parent_link_index_of_collidable_points, nc).astype(int)
)
* W_f_Ci
).sum(axis=0)
)(jnp.arange(model.number_of_links()))
W_f_Li_terrain = jnp.where(
parent_link_index_of_collidable_points[:, jnp.newaxis]
== jnp.arange(model.number_of_links()),
W_f_Ci,
0.0,
).sum(axis=0)

# ====================
# Enforce joint limits
Expand Down

0 comments on commit f3e35b1

Please sign in to comment.