@@ -2169,6 +2169,37 @@ def test_terrain_size(show_viewer, tol):
21692169 assert_allclose ((height_ref * 2.0 ), height_test , tol = tol )
21702170
21712171
2172+ @pytest .mark .required
2173+ @pytest .mark .parametrize ("backend" , [gs .cpu ])
2174+ def test_get_weld_constraints_basic (show_viewer , tol ):
2175+ scene = gs .Scene (show_viewer = show_viewer )
2176+
2177+ cube1 = scene .add_entity (gs .morphs .Box (size = (0.05 ,) * 3 , pos = (0.0 , 0.0 , 0.05 )))
2178+ cube2 = scene .add_entity (gs .morphs .Box (size = (0.05 ,) * 3 , pos = (0.2 , 0.0 , 0.05 )))
2179+
2180+ scene .build (n_envs = 1 )
2181+
2182+ rigid = scene .sim .rigid_solver
2183+
2184+ link_a = torch .tensor ([cube1 .base_link .idx ], dtype = gs .tc_int , device = gs .device )
2185+ link_b = torch .tensor ([cube2 .base_link .idx ], dtype = gs .tc_int , device = gs .device )
2186+
2187+ rigid .add_weld_constraint (link_a , link_b )
2188+ scene .step ()
2189+
2190+ welds = rigid .get_weld_constraints (as_tensor = True , to_torch = False )
2191+
2192+ env_id = 0 if "env" not in welds else int (welds ["env" ][0 ])
2193+
2194+ row = np .array (
2195+ [env_id , int (welds ["obj_a" ][0 ]), int (welds ["obj_b" ][0 ])],
2196+ dtype = np .int32 ,
2197+ )
2198+ ref = np .array ([0 , link_a .item (), link_b .item ()], dtype = np .int32 )
2199+
2200+ assert_allclose (row , ref , tol = tol )
2201+
2202+
21722203@pytest .mark .required
21732204@pytest .mark .parametrize ("backend" , [gs .cpu ])
21742205def test_urdf_parsing (show_viewer , tol ):
@@ -2302,37 +2333,6 @@ def test_urdf_mimic(show_viewer, tol):
23022333 assert_allclose (gs_qpos [- 1 ], gs_qpos [- 2 ], tol = tol )
23032334
23042335
2305- @pytest .mark .required
2306- @pytest .mark .merge_fixed_links (False )
2307- @pytest .mark .parametrize ("model_name" , ["pendulum" ])
2308- @pytest .mark .parametrize ("gs_solver" , [gs .constraint_solver .CG ])
2309- @pytest .mark .parametrize ("gs_integrator" , [gs .integrator .Euler ])
2310- def test_jacobian (gs_sim , tol ):
2311- pendulum = gs_sim .entities [0 ]
2312- angle = 0.7
2313- pendulum .set_qpos (np .array ([angle ], dtype = np .float64 ))
2314- gs_sim .scene .step ()
2315-
2316- link = pendulum .get_link ("PendulumArm_0" )
2317-
2318- p_local = np .array ([0.05 , - 0.02 , 0.12 ], dtype = np .float64 )
2319- J_o = pendulum .get_jacobian (link ).cpu ().numpy ()
2320- J_p = pendulum .get_jacobian (link , p_local ).cpu ().numpy ()
2321-
2322- c , s = np .cos (angle ), np .sin (angle )
2323- Rx = np .array ([[1 , 0 , 0 ], [0 , c , - s ], [0 , s , c ]], dtype = np .float64 )
2324- r_world = Rx @ p_local
2325- r_cross = np .array (
2326- [[0 , - r_world [2 ], r_world [1 ]], [r_world [2 ], 0 , - r_world [0 ]], [- r_world [1 ], r_world [0 ], 0 ]], dtype = np .float64
2327- )
2328-
2329- lin_o , ang_o = J_o [:3 , 0 ], J_o [3 :, 0 ]
2330- lin_expected = lin_o - r_cross @ ang_o
2331-
2332- assert_allclose (J_p [3 :, 0 ], ang_o , tol = tol )
2333- assert_allclose (J_p [:3 , 0 ], lin_expected , tol = tol )
2334-
2335-
23362336@pytest .mark .required
23372337@pytest .mark .parametrize ("backend" , [gs .cpu ])
23382338def test_gravity (show_viewer , tol ):
0 commit comments