@@ -307,6 +307,24 @@ def double_ball_pendulum():
307307 return mjcf
308308
309309
310+ @pytest .fixture (scope = "session" )
311+ def hinge_slide ():
312+ mjcf = ET .Element ("mujoco" , model = "hinge_slide" )
313+
314+ default = ET .SubElement (mjcf , "default" )
315+ ET .SubElement (default , "joint" , damping = "0.01" )
316+
317+ worldbody = ET .SubElement (mjcf , "worldbody" )
318+ base = ET .SubElement (worldbody , "body" , name = "pendulum" , pos = "0.15 0.0 0.0" )
319+ ET .SubElement (base , "joint" , name = "hinge" , type = "hinge" , axis = "0 1 0" , frictionloss = "0.08" )
320+ ET .SubElement (base , "geom" , name = "geom1" , type = "capsule" , size = "0.02" , fromto = "0.0 0.0 0.0 0.1 0.0 0.0" )
321+ link1 = ET .SubElement (base , "body" , name = "link1" , pos = "0.1 0.0 0.0" )
322+ ET .SubElement (link1 , "joint" , name = "slide" , type = "slide" , axis = "1 0 0" , frictionloss = "0.3" , stiffness = "200.0" )
323+ ET .SubElement (link1 , "geom" , name = "geom2" , type = "capsule" , size = "0.015" , fromto = "-0.1 0.0 0.0 0.1 0.0 0.0" )
324+
325+ return mjcf
326+
327+
310328@pytest .mark .required
311329@pytest .mark .parametrize ("model_name" , ["box_plan" ])
312330@pytest .mark .parametrize ("gs_solver" , [gs .constraint_solver .CG , gs .constraint_solver .Newton ])
@@ -332,6 +350,20 @@ def test_simple_kinematic_chain(gs_sim, mj_sim, tol):
332350 simulate_and_check_mujoco_consistency (gs_sim , mj_sim , num_steps = 200 , tol = tol )
333351
334352
353+ @pytest .mark .required
354+ @pytest .mark .parametrize ("model_name" , ["hinge_slide" ])
355+ @pytest .mark .parametrize ("gs_solver" , [gs .constraint_solver .CG , gs .constraint_solver .Newton ])
356+ @pytest .mark .parametrize ("gs_integrator" , [gs .integrator .implicitfast , gs .integrator .Euler ])
357+ @pytest .mark .parametrize ("backend" , [gs .cpu ])
358+ def test_frictionloss (gs_sim , mj_sim , tol ):
359+ qvel = np .array ([0.7 , - 0.9 ])
360+ simulate_and_check_mujoco_consistency (gs_sim , mj_sim , qvel = qvel , num_steps = 1000 , tol = 1e-7 )
361+
362+ # Check that final velocity is almost zero
363+ gs_qvel = gs_sim .rigid_solver .dofs_state .vel .to_numpy ()
364+ assert_allclose (gs_qvel , 0.0 , tol = 1e-2 )
365+
366+
335367# Disable Genesis multi-contact because it relies on discretized geometry unlike Mujoco
336368@pytest .mark .required
337369@pytest .mark .multi_contact (False )
@@ -2806,13 +2838,3 @@ def test_contype_conaffinity(show_viewer, tol):
28062838 assert_allclose (box1 .get_pos (), np .array ([0.0 , 0.0 , 0.25 ]), atol = 1e-3 )
28072839 assert_allclose (box2 .get_pos (), np .array ([0.0 , 0.0 , 0.75 ]), atol = 1e-3 )
28082840 assert_allclose (box3 .get_pos (), np .array ([0.0 , 0.0 , 0.75 ]), atol = 1e-3 )
2809-
2810-
2811- @pytest .mark .parametrize ("xml_path" , ["xml/frictionloss_pendulum.xml" ])
2812- @pytest .mark .parametrize ("gs_solver" , [gs .constraint_solver .CG , gs .constraint_solver .Newton ])
2813- @pytest .mark .parametrize ("gs_integrator" , [gs .integrator .Euler , gs .integrator .implicitfast ])
2814- @pytest .mark .parametrize ("backend" , [gs .cpu ])
2815- def test_frictionloss (gs_sim , mj_sim , tol ):
2816- qvel = np .array ([1.0 , - 1.0 ])
2817- tol = 1e-7 # TODO: I have to relax the tolerance a bit. Need to look closer why it differs from mujoco
2818- simulate_and_check_mujoco_consistency (gs_sim , mj_sim , qvel = qvel , num_steps = 1000 , tol = tol )
0 commit comments