Skip to content

Commit

Permalink
Fix api.contact.in_contact
Browse files Browse the repository at this point in the history
The length of `links_in_contact` was always equal to number of links in the model
  • Loading branch information
flferretti committed Mar 26, 2024
1 parent 4fd2032 commit 0778c78
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/jaxsim/api/contact.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def in_contact(

link_names = link_names if link_names is not None else model.link_names()

if set(link_names) - set(model.link_names()) != set():
if (link_names := set(link_names)) and link_names.difference(model.link_names()):
raise ValueError("One or more link names are not part of the model")

from jaxsim.physics.algos.soft_contacts import collidable_points_pos_vel
Expand All @@ -124,7 +124,7 @@ def in_contact(
below_terrain,
jnp.zeros_like(below_terrain, dtype=bool),
).any()
)(jnp.arange(model.number_of_links()))
)(jnp.arange(len(link_names)))

return links_in_contact

Expand Down

0 comments on commit 0778c78

Please sign in to comment.