Skip to content

Commit

Permalink
Fallback to default soft contact model in ODEState
Browse files Browse the repository at this point in the history
  • Loading branch information
flferretti committed Jun 13, 2024
1 parent 630016b commit e480be6
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/jaxsim/api/ode_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,13 +219,16 @@ def build(
)

# Get the contact model from the `JaxSimModel`
prefix = type(model.contact_model).__name__.split("Contact")[0]
try:
prefix = type(model.contact_model).__name__.split("Contact")[0]
except AttributeError:
logging.warning(
"Unable to determine contact state class prefix. Using default soft contacts."
)
prefix = "Soft"

if prefix:
module_name = f"{prefix.lower()}_contacts"
class_name = f"{prefix.capitalize()}ContactsState"
else:
raise ValueError("Unable to determine contact state class prefix.")
module_name = f"{prefix.lower()}_contacts"
class_name = f"{prefix.capitalize()}ContactsState"

state_cls = importlib.import_module(f"jaxsim.rbda.{module_name}.{class_name}")

Expand Down

0 comments on commit e480be6

Please sign in to comment.