Skip to content

Prefer logging Asset3D over trimesh when possible #25

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[project]
name = "rerun-loader-urdf"
description = "Example of an executable data-loader plugin for the Rerun Viewer for URDF files."
version = "0.2.0"
version = "0.3.0"
requires-python = ">=3.10"
dependencies = [
"urdfdom-py",
Expand Down
18 changes: 11 additions & 7 deletions src/rerun_loader_urdf/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ def log_joint(self, entity_path: str, joint: urdf_parser.Joint, recording: rr.Re
def log_visual(self, entity_path: str, visual: urdf_parser.Visual, recording: rr.RecordingStream) -> None:
"""Log a URDF visual to Rerun."""
material = None
mesh_or_scene = None
if visual.material is not None:
if visual.material.color is None and visual.material.texture is None:
# use globally defined material
Expand All @@ -109,12 +110,15 @@ def log_visual(self, entity_path: str, visual: urdf_parser.Visual, recording: rr
if isinstance(visual.geometry, urdf_parser.Mesh):
resolved_path = self.root_filepath / resolve_ros_path(visual.geometry.filename)
mesh_scale = visual.geometry.scale
mesh_or_scene = trimesh.load_mesh(resolved_path)
if mesh_scale is not None:
if transform is not None:
transform.scale = mesh_scale
else:
transform = rr.Transform3D(scale=mesh_scale)

transform = rr.Transform3D(scale=mesh_scale)

recording.log(entity_path + f"/{resolved_path}", rr.Asset3D(path=resolved_path), transform)
if material is not None:
recording.log(
entity_path + f"/{resolved_path}", rr.Asset3D.from_fields(albedo_factor=material.color.rgba)
)

elif isinstance(visual.geometry, urdf_parser.Box):
mesh_or_scene = trimesh.creation.box(extents=visual.geometry.size)
elif isinstance(visual.geometry, urdf_parser.Cylinder):
Expand Down Expand Up @@ -145,7 +149,7 @@ def log_visual(self, entity_path: str, visual: urdf_parser.Visual, recording: rr
texture_path = resolve_ros_path(material.texture.filename)
mesh.visual = trimesh.visual.texture.TextureVisuals(image=Image.open(texture_path))
log_trimesh(entity_path + f"/{i}", mesh, transform, recording=recording)
else:
elif mesh_or_scene is not None:
mesh = mesh_or_scene
if material is not None and not isinstance(mesh.visual, trimesh.visual.texture.TextureVisuals):
if material.color is not None:
Expand Down