Skip to content

Commit

Permalink
SDFormat -> MJCF: Set mesh scale (#111)
Browse files Browse the repository at this point in the history
Signed-off-by: Addisu Z. Taddese <addisu@openrobotics.org>
  • Loading branch information
azeey authored Aug 23, 2022
1 parent b535b80 commit 6b3fa2c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ def add_geometry(body, name, pose, sdf_geom):
file=mesh_file_path)
else:
geom.mesh = asset_loaded
geom.mesh.scale = su.vec3d_to_list(mesh_shape.scale())
else:
raise RuntimeError(
f"Encountered unsupported shape type {sdf_geom.type()}")
Expand Down
3 changes: 3 additions & 0 deletions sdformat_mjcf/tests/sdformat_to_mjcf/test_add_geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ def test_mesh(self):
mesh.set_uri("meshes/box.obj")
mesh.set_file_path(
os.path.join(get_resources_dir(), "box_obj", "model.sdf"))
mesh.set_scale(Vector3d(0.1, 0.2, 0.3))

geometry = sdf.Geometry()
geometry.set_mesh_shape(mesh)
Expand All @@ -135,6 +136,8 @@ def test_mesh(self):
self.assertEqual("mesh_shape", mj_geom.name)
self.assertEqual("mesh", mj_geom.type)
self.assertEqual(1, len(mujoco.asset.find_all('mesh')))
mj_mesh = mujoco.asset.mesh[0]
assert_allclose([0.1, 0.2, 0.3], mj_mesh.scale)

def test_plane(self):
plane = sdf.Plane()
Expand Down

0 comments on commit 6b3fa2c

Please sign in to comment.