Skip to content

Commit

Permalink
Update test_simulations.py
Browse files Browse the repository at this point in the history
Enable a subset of collidable points in SoftContacts, RigidContacts, and RelaxedRigidContacts
  • Loading branch information
xela-95 committed Oct 29, 2024
1 parent b7b1c48 commit 1c517cb
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions tests/test_simulations.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import jax
import jax.numpy as jnp
import numpy as np
import pytest

import jaxsim.api as js
Expand Down Expand Up @@ -261,6 +262,16 @@ def test_simulation_with_soft_contacts(
model.contact_model = jaxsim.rbda.contacts.SoftContacts.build(
terrain=model.terrain,
)
# Enable a subset of the collidable points.
enabled_collidable_points_mask = np.zeros(
len(model.kin_dyn_parameters.contact_parameters.body), dtype=bool
)
enabled_collidable_points_mask[[0, 1, 2, 3]] = True
model.kin_dyn_parameters.contact_parameters.enabled = tuple(
enabled_collidable_points_mask.tolist()
)

assert np.sum(model.kin_dyn_parameters.contact_parameters.enabled) == 4

# Initialize the maximum penetration of each collidable point at steady state.
max_penetration = 0.001
Expand Down Expand Up @@ -345,6 +356,16 @@ def test_simulation_with_rigid_contacts(
model.contact_model = jaxsim.rbda.contacts.RigidContacts.build(
terrain=model.terrain,
)
# Enable a subset of the collidable points.
enabled_collidable_points_mask = np.zeros(
len(model.kin_dyn_parameters.contact_parameters.body), dtype=bool
)
enabled_collidable_points_mask[[0, 1, 2, 3]] = True
model.kin_dyn_parameters.contact_parameters.enabled = tuple(
enabled_collidable_points_mask.tolist()
)

assert np.sum(model.kin_dyn_parameters.contact_parameters.enabled) == 4

# Initialize the maximum penetration of each collidable point at steady state.
# This model is rigid, so we expect (almost) no penetration.
Expand Down Expand Up @@ -387,6 +408,16 @@ def test_simulation_with_relaxed_rigid_contacts(
model.contact_model = jaxsim.rbda.contacts.RelaxedRigidContacts.build(
terrain=model.terrain,
)
# Enable a subset of the collidable points.
enabled_collidable_points_mask = np.zeros(
len(model.kin_dyn_parameters.contact_parameters.body), dtype=bool
)
enabled_collidable_points_mask[[0, 1, 2, 3]] = True
model.kin_dyn_parameters.contact_parameters.enabled = tuple(
enabled_collidable_points_mask.tolist()
)

assert np.sum(model.kin_dyn_parameters.contact_parameters.enabled) == 4

# Initialize the maximum penetration of each collidable point at steady state.
# This model is quasi-rigid, so we expect (almost) no penetration.
Expand Down

0 comments on commit 1c517cb

Please sign in to comment.