From 4de7fa48af17e7850980b7959ceb1888a14b1bd7 Mon Sep 17 00:00:00 2001 From: Alessandro Croci Date: Tue, 4 Jun 2024 13:46:10 +0200 Subject: [PATCH 1/2] Maintain same terrain when reducing a model --- src/jaxsim/api/model.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/jaxsim/api/model.py b/src/jaxsim/api/model.py index a3a154268..0b255dbd3 100644 --- a/src/jaxsim/api/model.py +++ b/src/jaxsim/api/model.py @@ -338,6 +338,7 @@ def reduce( reduced_model = JaxSimModel.build( model_description=reduced_intermediate_description, model_name=model.name(), + terrain=model.terrain, ) # Store the origin of the model, in case downstream logic needs it From 2f47dad54783112f3ea2b49f450e00806cd307ed Mon Sep 17 00:00:00 2001 From: Alessandro Croci Date: Tue, 4 Jun 2024 13:46:10 +0200 Subject: [PATCH 2/2] Add terrain check in unit test `test_model_creation_and_reduction` --- tests/test_api_model.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/test_api_model.py b/tests/test_api_model.py index 88ea31d41..f903a9f64 100644 --- a/tests/test_api_model.py +++ b/tests/test_api_model.py @@ -93,6 +93,9 @@ def test_model_creation_and_reduction( # Check that all non-fixed joints are in the reduced model. assert set(reduced_joints) == set(model_reduced.joint_names()) + # Check that the reduce model maintain the same terrain of the full model. + assert model_full.terrain == model_reduced.terrain + # Build the data of the reduced model. data_reduced = js.data.JaxSimModelData.build( model=model_reduced,