From d637eb7b67559182f56d7c7f60290f64612a70a1 Mon Sep 17 00:00:00 2001 From: diegoferigo Date: Wed, 3 Apr 2024 09:34:07 +0200 Subject: [PATCH] Add test of api.link.bias_acceleration --- tests/test_api_link.py | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/tests/test_api_link.py b/tests/test_api_link.py index 62f84de38..1451e972e 100644 --- a/tests/test_api_link.py +++ b/tests/test_api_link.py @@ -157,3 +157,36 @@ def test_link_jacobians( v_WL_idt = kin_dyn.frame_velocity(frame_name=link_name) v_WL_js = js.link.velocity(model=model, data=data, link_index=link_idx) assert v_WL_js == pytest.approx(v_WL_idt), link_name + + +def test_link_bias_acceleration( + jaxsim_models_types: js.model.JaxSimModel, + velocity_representation: VelRepr, + prng_key: jax.Array, +): + + model = jaxsim_models_types + + key, subkey = jax.random.split(prng_key, num=2) + data = js.data.random_model_data( + model=model, + key=subkey, + velocity_representation=velocity_representation, + ) + + kin_dyn = utils_idyntree.build_kindyncomputations_from_jaxsim_model( + model=model, data=data + ) + + # ===== + # Tests + # ===== + + for name, index in zip( + model.link_names(), + js.link.names_to_idxs(model=model, link_names=model.link_names()), + ): + Jν_idt = kin_dyn.frame_bias_acc(frame_name=name) + Jν_js = js.link.bias_acceleration(model=model, data=data, link_index=index) + assert pytest.approx(Jν_idt) == Jν_js +