Skip to content

Commit

Permalink
Merge pull request #180 from ami-iit/flferretti-patch-2
Browse files Browse the repository at this point in the history
Refactor contact forces sum in `api.ode.system_velocity_dynamics`
  • Loading branch information
flferretti committed Jun 20, 2024
2 parents 0cfd5f7 + 69c77b1 commit a963649
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions src/jaxsim/api/ode.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,14 +150,11 @@ 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()))
mask = parent_link_index_of_collidable_points[:, jnp.newaxis] == jnp.arange(
model.number_of_links()
)

W_f_Li_terrain = mask.T @ W_f_Ci

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

0 comments on commit a963649

Please sign in to comment.