Skip to content
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions tests/data/assets/box_with_texture.mtl
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
newmtl texture_mat
Ns 250.000000
Ka 1.000000 1.000000 1.000000
Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000
Ni 1.450000
d 1.000000
illum 2
map_Kd ./grid.png
norm ./normal.png
map_Pr ./roughness.png
map_Pm ./metallic.png
38 changes: 38 additions & 0 deletions tests/data/assets/box_with_texture.obj
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
mtllib box_with_texture.mtl
o Cube
v 0.500000 0.500000 -0.500000
v 0.500000 -0.500000 -0.500000
v 0.500000 0.500000 0.500000
v 0.500000 -0.500000 0.500000
v -0.500000 0.500000 -0.500000
v -0.500000 -0.500000 -0.500000
v -0.500000 0.500000 0.500000
v -0.500000 -0.500000 0.500000
vn -0.0000 1.0000 -0.0000
vn -0.0000 -0.0000 1.0000
vn -1.0000 -0.0000 -0.0000
vn -0.0000 -1.0000 -0.0000
vn 1.0000 -0.0000 -0.0000
vn -0.0000 -0.0000 -1.0000
vt 0.625000 0.500000
vt 0.875000 0.500000
vt 0.875000 0.750000
vt 0.625000 0.750000
vt 0.375000 0.750000
vt 0.625000 1.000000
vt 0.375000 1.000000
vt 0.375000 0.000000
vt 0.625000 0.000000
vt 0.625000 0.250000
vt 0.375000 0.250000
vt 0.125000 0.500000
vt 0.375000 0.500000
vt 0.125000 0.750000
s 0
usemtl texture_mat
f 1/1/1 5/2/1 7/3/1 3/4/1
f 4/5/2 3/4/2 7/6/2 8/7/2
f 8/8/3 7/9/3 5/10/3 6/11/3
f 6/12/4 2/13/4 4/5/4 8/14/4
f 2/13/5 1/1/5 3/4/5 4/5/5
f 6/11/6 5/10/6 1/1/6 2/13/6
Binary file added tests/data/assets/metallic.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/data/assets/normal.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/data/assets/roughness.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions tests/data/assets/two_boxes.mtl
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,6 @@ Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000
Ni 1.450000
d 1.000000
Pr 0.3
Pm 0.05
illum 2
48 changes: 48 additions & 0 deletions tests/data/material_color.urdf
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?xml version="1.0"?>
<robot name="material_color">
<material name="red">
<color rgba="1 0 0 1"/>
</material>
<material name="green">
<color rgba="0 1 0 1"/>
</material>
<material name="opacity_half">
<color rgba="0.2 0.5 1 0.5"/>
</material>

<link name="link_box_red">
<visual>
<geometry>
<box size="0.5 0.5 0.5"/>
</geometry>
<material name="red"/>
</visual>
</link>
<link name="link_box_green">
<visual>
<geometry>
<box size="0.5 0.5 0.5"/>
</geometry>
<material name="green"/>
</visual>
</link>
<link name="link_box_opacity_half">
<visual>
<geometry>
<box size="0.5 0.5 0.5"/>
</geometry>
<material name="opacity_half"/>
</visual>
</link>

<joint name="joint_root" type="fixed">
<origin rpy="0 0 0" xyz="1 0 0"/>
<parent link="link_box_red"/>
<child link="link_box_green"/>
</joint>
<joint name="joint_box_green_opacity_half" type="fixed">
<origin rpy="0 0 0" xyz="1 0 0"/>
<parent link="link_box_green"/>
<child link="link_box_opacity_half"/>
</joint>
</robot>
24 changes: 24 additions & 0 deletions tests/data/material_mesh_color.urdf
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0"?>
<robot name="material_mesh_color">
<link name="link_box">
<visual>
<geometry>
<box size="0.5 0.5 0.5"/>
</geometry>
</visual>
</link>
<link name="link_obj">
<visual>
<geometry>
<!-- This obj file has two materials: green_mat and red_mat. -->
<mesh filename="assets/two_boxes.obj" scale="0.5 0.5 0.5"/>
</geometry>
</visual>
</link>

<joint name="joint_box_obj" type="fixed">
<origin rpy="0 0 0" xyz="1 0 0"/>
<parent link="link_box"/>
<child link="link_obj"/>
</joint>
</robot>
29 changes: 29 additions & 0 deletions tests/data/material_mesh_override.urdf
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?xml version="1.0"?>
<robot name="material_mesh_override">
<material name="blue">
<color rgba="0 0 1 1"/>
</material>
<link name="link_box">
<visual>
<geometry>
<box size="0.5 0.5 0.5"/>
</geometry>
</visual>
</link>
<link name="link_obj">
<visual>
<geometry>
<!-- This obj file has two materials: green_mat and red_mat. -->
<mesh filename="assets/two_boxes.obj" scale="0.5 0.5 0.5"/>
</geometry>
<!-- Override the material with blue. -->
<material name="blue"/>
</visual>
</link>

<joint name="joint_box_obj" type="fixed">
<origin rpy="0 0 0" xyz="1 0 0"/>
<parent link="link_box"/>
<child link="link_obj"/>
</joint>
</robot>
23 changes: 23 additions & 0 deletions tests/data/material_mesh_texture.urdf
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0"?>
<robot name="material_mesh_texture">
<link name="link_box">
<visual>
<geometry>
<box size="0.5 0.5 0.5"/>
</geometry>
</visual>
</link>
<link name="link_obj">
<visual>
<geometry>
<mesh filename="assets/box_with_texture.obj" scale="0.5 0.5 0.5"/>
</geometry>
</visual>
</link>

<joint name="joint_box_obj" type="fixed">
<origin rpy="0 0 0" xyz="1 0 0"/>
<parent link="link_box"/>
<child link="link_obj"/>
</joint>
</robot>
73 changes: 73 additions & 0 deletions tests/data/material_texture.urdf
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
<?xml version="1.0"?>
<robot name="material_texture">
<material name="texture_material">
<texture filename="assets/grid.png"/>
</material>
<material name="color_texture_material">
<color rgba="0.5 0.2 0.5 1.0"/>
<texture filename="assets/grid.png"/>
</material>

<link name="link_box">
<visual>
<geometry>
<box size="0.5 0.5 0.5"/>
</geometry>
<material name="texture_material"/>
</visual>
</link>
<link name="link_sphere">
<visual>
<geometry>
<sphere radius="0.5"/>
</geometry>
<material name="texture_material"/>
</visual>
</link>
<link name="link_cylinder">
<visual>
<geometry>
<cylinder radius="0.5" length="1.0"/>
</geometry>
<material name="texture_material"/>
</visual>
</link>

<link name="link_obj_texture">
<visual>
<geometry>
<mesh filename="assets/box.obj" scale="0.5 0.5 0.5"/>
</geometry>
<material name="texture_material"/>
</visual>
</link>
<link name="link_obj_color_texture">
<visual>
<geometry>
<mesh filename="assets/box.obj" scale="0.5 0.5 0.5"/>
</geometry>
<material name="color_texture_material"/>
</visual>
</link>

<joint name="joint_box_sphere" type="fixed">
<origin rpy="0 0 0" xyz="1 0 0"/>
<parent link="link_box"/>
<child link="link_sphere"/>
</joint>
<joint name="joint_sphere_cylinder" type="fixed">
<origin rpy="0 0 0" xyz="1 0 0"/>
<parent link="link_sphere"/>
<child link="link_cylinder"/>
</joint>
<joint name="joint_cylinder_obj_texture" type="fixed">
<origin rpy="0 0 0" xyz="1 0 0"/>
<parent link="link_cylinder"/>
<child link="link_obj_texture"/>
</joint>
<joint name="joint_cylinder_obj_color_texture" type="fixed">
<origin rpy="0 0 0" xyz="1 0 0"/>
<parent link="link_obj_texture"/>
<child link="link_obj_color_texture"/>
</joint>
</robot>
34 changes: 34 additions & 0 deletions tests/data/material_texture_name_duplication.urdf
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?xml version="1.0"?>
<robot name="material_texture_name_duplication">
<material name="texture_material">
<color rgba="1.0 1.0 1.0 1.0"/>
<texture filename="assets/grid.png"/>
</material>
<material name="texture_material_2">
<color rgba="1.0 1.0 1.0 1.0"/>
<texture filename="assets/textures/grid.png"/>
</material>

<link name="link_obj">
<visual>
<geometry>
<mesh filename="assets/box.obj" scale="0.5 0.5 0.5"/>
</geometry>
<material name="texture_material"/>
</visual>
</link>
<link name="link_obj2">
<visual>
<geometry>
<mesh filename="assets/box.obj" scale="0.5 0.5 0.5"/>
</geometry>
<material name="texture_material_2"/>
</visual>
</link>

<joint name="joint_obj" type="fixed">
<origin rpy="0 0 0" xyz="1 0 0"/>
<parent link="link_obj"/>
<child link="link_obj2"/>
</joint>
</robot>
4 changes: 4 additions & 0 deletions tests/data/test_displayname.urdf
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
<?xml version="1.0"?>
<!-- Using characters other than alphanumeric characters and '_' -->
<robot name="test_displayname">
<material name="material:red">
<color rgba="1.0 0.0 0.0 1.0"/>
</material>
<link name="link-box">
<visual>
<geometry>
Expand All @@ -21,6 +24,7 @@
<!-- Contains "Cube:Red" and "Cube:Green" as meshes. -->
<mesh filename="assets/name_test.obj" scale="0.5 0.5 0.5"/>
</geometry>
<material name="material:red"/>
</visual>
</link>

Expand Down
2 changes: 1 addition & 1 deletion tests/data/verifying_elements.urdf
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<material name="blue">
<color rgba="0.0 0.0 1.0 1"/>
</material>
<material name="black">
<material name="default">
<color /> <!-- To test the default value, no attribute is provided here. -->
</material>
<material name="texture">
Expand Down
16 changes: 14 additions & 2 deletions tests/testCli.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,22 @@ def test_run(self):
self.assertTrue((pathlib.Path(self.tmpDir()) / "simple-primitives.usda").exists())

def test_no_layer_structure(self):
model = "tests/data/simple_box.urdf"
model = "tests/data/material_mesh_texture.urdf"
robot_name = pathlib.Path(model).stem

# This is the process to check whether an existing folder will be removed.
textures_dir = pathlib.Path(self.tmpDir()) / "Textures"
if not textures_dir.exists():
textures_dir.mkdir(parents=True, exist_ok=True)
shutil.copy("tests/data/assets/grid.png", textures_dir / "foo.png")

with patch("sys.argv", ["urdf_usd_converter", model, self.tmpDir(), "--no-layer-structure"]):
self.assertEqual(run(), 0, f"Failed to convert {model}")
self.assertFalse((pathlib.Path(self.tmpDir()) / "Payload").exists())
self.assertFalse((pathlib.Path(self.tmpDir()) / f"{robot_name}.usda").exists())
self.assertTrue((pathlib.Path(self.tmpDir()) / f"{robot_name}.usdc").exists())
self.assertTrue((textures_dir / "grid.png").exists())
self.assertFalse((textures_dir / "foo.png").exists())

def test_no_physics_scene(self):
model = "tests/data/simple_box.urdf"
Expand Down Expand Up @@ -211,7 +220,10 @@ def test_conversion_warning_multiple_ros_packages_invalid(self):
patch("sys.argv", ["urdf_usd_converter", robot, str(output_dir), "--package", package_1]),
usdex.test.ScopedDiagnosticChecker(
self,
[(Tf.TF_DIAGNOSTIC_WARNING_TYPE, ".*Failed to convert mesh:.*")],
[
(Tf.TF_DIAGNOSTIC_WARNING_TYPE, ".*Failed to convert mesh:.*"),
(Tf.TF_DIAGNOSTIC_WARNING_TYPE, ".*Textures are not projection mapped for Cube, Sphere, and Cylinder:.*"),
],
level=usdex.core.DiagnosticsLevel.eWarning,
),
):
Expand Down
Loading
Loading