@@ -243,6 +243,42 @@ def test_com(brbd):
243243 np .testing .assert_almost_equal (com_ddot .squeeze (), expected_com_ddot )
244244
245245
246+ @pytest .mark .parametrize ("brbd" , brbd_to_test )
247+ def test_zero_moment_point (brbd ):
248+ m = brbd .Model ("../../models/pyomecaman.bioMod" )
249+
250+ q = np .array ([0.1 , 0.1 , 0.1 , 0.3 , 0.3 , 0.3 , 0.3 , 0.3 , 0.3 , 0.3 , 0.3 , 0.3 , 0.3 ])
251+ q_dot = np .array ([1 , 1 , 1 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 ])
252+ q_ddot = np .array ([10 , 10 , 10 , 30 , 30 , 30 , 30 , 30 , 30 , 30 , 30 , 30 , 30 ])
253+ normal = np .array ([0 , 0 , 1 ])
254+ point = np .array ([0 , 0 , 0.1 ])
255+
256+ if brbd .backend == brbd .CASADI :
257+ from casadi import MX
258+
259+ q_sym = MX .sym ("q" , m .nbQ (), 1 )
260+ q_dot_sym = MX .sym ("q_dot" , m .nbQdot (), 1 )
261+ q_ddot_sym = MX .sym ("q_ddot" , m .nbQddot (), 1 )
262+
263+ zero_moment_point_func = brbd .to_casadi_func (
264+ "Compute_Zero_Moment_Point" ,
265+ m .CalcZeroMomentPoint ,
266+ q_sym ,
267+ q_dot_sym ,
268+ q_ddot_sym ,
269+ normal ,
270+ point ,
271+ )
272+ zero_moment_point = np .array (zero_moment_point_func (q , q_dot , q_ddot ))
273+
274+ elif brbd .backend == brbd .EIGEN3 :
275+ zero_moment_point = m .CalcZeroMomentPoint (q , q_dot , q_ddot , normal , point ).to_array ()
276+ else :
277+ raise NotImplementedError ("Backend not implemented in test" )
278+
279+ np .testing .assert_almost_equal (zero_moment_point .squeeze ()[2 ], point [2 ])
280+
281+
246282@pytest .mark .parametrize ("brbd" , brbd_to_test )
247283def test_set_vector3d (brbd ):
248284 m = brbd .Model ("../../models/pyomecaman.bioMod" )
0 commit comments