Skip to content

Commit

Permalink
Add pytest fixture for simulation integrators
Browse files Browse the repository at this point in the history
  • Loading branch information
flferretti committed Feb 14, 2025
1 parent 7a76ec7 commit a2b3532
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
19 changes: 19 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

import jaxsim
import jaxsim.api as js
from jaxsim.api.model import Integrator


def pytest_addoption(parser):
Expand Down Expand Up @@ -127,6 +128,24 @@ def velocity_representation(request) -> jaxsim.VelRepr:
return request.param


@pytest.fixture(
scope="function",
params=[
pytest.param(Integrator.SemiImplicitEuler, id="semi_implicit_euler"),
pytest.param(Integrator.RungeKutta4, id="runge_kutta_4"),
],
)
def integrator(request) -> str:
"""
Fixture providing the integrator to use in the simulation.
Returns:
The integrator to use in the simulation.
"""

return request.param


@pytest.fixture(scope="session")
def batch_size(request) -> int:
"""
Expand Down
3 changes: 2 additions & 1 deletion tests/test_simulations.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ def run_simulation(


def test_simulation_with_relaxed_rigid_contacts(
jaxsim_model_box: js.model.JaxSimModel,
jaxsim_model_box: js.model.JaxSimModel, integrator
):

model = jaxsim_model_box
Expand All @@ -206,6 +206,7 @@ def test_simulation_with_relaxed_rigid_contacts(
model.kin_dyn_parameters.contact_parameters.enabled = tuple(
enabled_collidable_points_mask.tolist()
)
model.integrator = integrator

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

Expand Down

0 comments on commit a2b3532

Please sign in to comment.