From 0778c78068adc94ade265f205c383e360ab981d1 Mon Sep 17 00:00:00 2001 From: Filippo Luca Ferretti <102977828+flferretti@users.noreply.github.com> Date: Tue, 26 Mar 2024 14:56:37 +0100 Subject: [PATCH] Fix `api.contact.in_contact` The length of `links_in_contact` was always equal to number of links in the model --- src/jaxsim/api/contact.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/jaxsim/api/contact.py b/src/jaxsim/api/contact.py index 47650cf95..464f56917 100644 --- a/src/jaxsim/api/contact.py +++ b/src/jaxsim/api/contact.py @@ -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 @@ -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