@@ -296,11 +296,9 @@ def test_usd_parse(usd_filename):
296296
297297
298298@pytest .mark .required
299- def test_urdf_with_existing_glb ():
299+ def test_urdf_with_existing_glb (tmp_path , show_viewer ):
300300 assets = Path (gs .utils .get_assets_dir ())
301301 glb_path = assets / "usd" / "sneaker_airforce.glb"
302-
303- tmp_path = Path (__file__ ).parent
304302 urdf_path = tmp_path / "model.urdf"
305303 urdf_path .write_text (
306304 f"""<robot name="shoe">
@@ -309,8 +307,81 @@ def test_urdf_with_existing_glb():
309307 <geometry><mesh filename="{ glb_path } "/></geometry>
310308 </visual>
311309 </link>
312- </robot>"""
310+ </robot>
311+ """
312+ )
313+ scene = gs .Scene (
314+ show_viewer = show_viewer ,
315+ show_fps = False ,
316+ )
317+ scene .build ()
318+ scene .step ()
319+
320+
321+ @pytest .mark .required
322+ def test_urdf_with_float32_grayscale_glb (tmp_path , show_viewer ):
323+ glb_path = tmp_path / "gray.glb"
324+ img = np .random .rand (16 , 16 ).astype (np .float32 )
325+ vertices = np .array (
326+ [[- 0.5 , - 0.5 , 0.0 ], [0.5 , - 0.5 , 0.0 ], [0.5 , 0.5 , 0.0 ], [- 0.5 , 0.5 , 0.0 ]],
327+ dtype = np .float32 ,
328+ )
329+ faces = np .array ([[0 , 1 , 2 ], [0 , 2 , 3 ]], dtype = np .uint32 )
330+ mesh = trimesh .Trimesh (vertices , faces , process = False )
331+ mesh .visual = trimesh .visual .texture .TextureVisuals (
332+ uv = np .array ([[0 , 0 ], [1 , 0 ], [1 , 1 ], [0 , 1 ]], dtype = np .float32 ),
333+ material = trimesh .visual .material .SimpleMaterial (image = img ),
334+ )
335+ trimesh .Scene ([mesh ]).export (glb_path )
336+ urdf_path = tmp_path / "model_gray.urdf"
337+ urdf_path .write_text (
338+ f"""<robot name="gray">
339+ <link name="base">
340+ <visual>
341+ <geometry><mesh filename="{ glb_path } "/></geometry>
342+ </visual>
343+ </link>
344+ </robot>
345+ """
346+ )
347+ scene = gs .Scene (
348+ show_viewer = show_viewer ,
349+ show_fps = False ,
350+ )
351+ scene .build ()
352+ scene .step ()
353+
354+
355+ @pytest .mark .required
356+ def test_urdf_with_float64_two_channel_glb (tmp_path , show_viewer ):
357+ glb_path = tmp_path / "rg.glb"
358+ img = np .random .rand (16 , 16 , 2 ).astype (np .float64 )
359+ vertices = np .array (
360+ [[- 0.5 , - 0.5 , 0.0 ], [0.5 , - 0.5 , 0.0 ], [0.5 , 0.5 , 0.0 ], [- 0.5 , 0.5 , 0.0 ]],
361+ dtype = np .float32 ,
362+ )
363+ faces = np .array ([[0 , 1 , 2 ], [0 , 2 , 3 ]], dtype = np .uint32 )
364+ mesh = trimesh .Trimesh (vertices , faces , process = False )
365+ mesh .visual = trimesh .visual .texture .TextureVisuals (
366+ uv = np .array ([[0 , 0 ], [1 , 0 ], [1 , 1 ], [0 , 1 ]], dtype = np .float32 ),
367+ material = trimesh .visual .material .SimpleMaterial (image = img ),
368+ )
369+ trimesh .Scene ([mesh ]).export (glb_path )
370+
371+ urdf_path = tmp_path / "model_rg.urdf"
372+ urdf_path .write_text (
373+ f"""<robot name="rg">
374+ <link name="base">
375+ <visual>
376+ <geometry><mesh filename="{ glb_path } "/></geometry>
377+ </visual>
378+ </link>
379+ </robot>
380+ """
381+ )
382+ scene = gs .Scene (
383+ show_viewer = show_viewer ,
384+ show_fps = False ,
313385 )
314- scene = gs .Scene (show_viewer = False )
315386 scene .build ()
316387 scene .step ()
0 commit comments