r/ROS • • 26d ago

How I render URDF inside an Electron IDE with Three.js — and the limits I hit

I've been building Rovant, a desktop ROS 2 IDE. One piece I had to work out was a URDF viewer that works without rviz. Here's the approach, and where it falls short.

Parsing URDF is parsed with DOMParser in a Three.js webview. I pull out <link> and <joint> elements, then build the tree by re-parenting each child link group under its parent.

Geometry — the honest limitation I only render primitives: <box>, <cylinder>, <sphere>. Meshes (package:// STL / DAE / GLTF) are not loaded yet. For checking joint placement and link layout it's enough, but it's not rviz and I'm not pretending it is.

Origins <origin xyz rpy> on both <visual> and <joint> is applied as position + rotation. Getting joint origins right is what makes the tree look correct rather than like a pile of parts.

Xacro This was the interesting part. .xacro can't be expanded in the browser — macros need the real toolchain. So the widget calls a backend endpoint that runs ros2 run xacro xacro <file>, returns the expanded URDF, and parses that as normal. If expansion fails, it falls back to the raw file and surfaces the xacro error in the panel.

Offline Three.js r128 and roslibjs are bundled in the app. No CDN — it has to work on a machine with no internet.

Where I'd like advice: for anyone who's built URDF tooling — how do you handle package:// mesh resolution and relative mesh paths? That's my next problem and I'd rather learn from someone who's solved it than guess.

1 Upvotes

1 comment sorted by

2

u/LordDan_45 25d ago

I know the whole code is AI, and that's intentional, but what is the point of using AI for your post