@@ -2628,3 +2628,45 @@ def test_mesh_to_heightfield(tmp_path, show_viewer):
26282628 # speed is around 0
26292629 qvel = ball .get_dofs_velocity ()
26302630 assert_allclose (qvel , 0 , atol = 1e-2 )
2631+
2632+
2633+ @pytest .mark .required
2634+ @pytest .mark .parametrize ("backend" , [gs .cpu ])
2635+ def test_get_cartesian_space_variables (show_viewer , tol ):
2636+ scene = gs .Scene (
2637+ sim_options = gs .options .SimOptions (
2638+ gravity = (0.0 , 0.0 , 0.0 ),
2639+ ),
2640+ rigid_options = gs .options .RigidOptions (
2641+ # by default, enable_mujoco_compatibility=False
2642+ # the test will fail if enable_mujoco_compatibility=True
2643+ enable_mujoco_compatibility = False ,
2644+ ),
2645+ show_viewer = show_viewer ,
2646+ )
2647+
2648+ box = scene .add_entity (
2649+ gs .morphs .Box (
2650+ size = (1.0 , 1.0 , 1.0 ),
2651+ pos = (0.0 , 0.0 , 0.0 ),
2652+ )
2653+ )
2654+ scene .build ()
2655+
2656+ for _ in range (2 ):
2657+ for link in box .links :
2658+ force = torch .tensor (np .array ([0 , 0 , 0 ])).unsqueeze (0 )
2659+ acc = 50.0
2660+ force [0 , 0 ] = acc * link .inertial_mass
2661+ pos = link .get_pos ()
2662+ vel = link .get_vel ()
2663+
2664+ dof_vel = link .solver .get_dofs_velocity ()
2665+ dof_pos = link .solver .get_qpos ()
2666+
2667+ assert_allclose (dof_vel [:3 ], vel , atol = tol )
2668+ assert_allclose (dof_pos [:3 ], pos , atol = tol )
2669+
2670+ link .solver .apply_links_external_force (force , (link .idx ,), ref = "link_com" , local = False )
2671+
2672+ scene .step ()
0 commit comments