Skip to content

Instantly share code, notes, and snippets.

@mikedh
Created March 7, 2019 20:54
Show Gist options
  • Save mikedh/ce09d1bf83767fefded25be519a61564 to your computer and use it in GitHub Desktop.
Save mikedh/ce09d1bf83767fefded25be519a61564 to your computer and use it in GitHub Desktop.

robot-gltf

Summary

An effort to replace ROS packages describing a robot (a directory structure with URDF, SRDF, OBJ-MTL-STL-salad) with a single GLTF 2.0 GLB file including URDF and SRDF descriptions in the "extras" field of the GLTF header.

Proposed Robot-GLTF Format

  • All geometry is put into a GLTF 2.0 .GLB file.
  • Nodes in GLTF scene description are not used, but can be defined for visualization
  • The URDF and SRDF descriptions are stored in the extras field of the GLTF header.
    • Using the extras field keeps us completely compliant with the spec.
    • XML is converted to native JSON using a reversible XML-JSON mapping.
      • One could also just dump the XML file as a string into the extras field, but that is pretty ugly. This way if new tools are being written, they can reference only the JSON format.
      • Implemented by xmltodict.
  • URDF mesh package://file_name references are a replaced by a GLTF geometry name.

Details

Why GLTF?

GLTF has emerged as a very popular alternative to other mesh and scene descriptions. It is incredibly easy and fast to parse (JSON header describing data in a binary blob), has a sensible hierarchical scene graph in the JSON header, and a great looking modern physically based material system. It has support in dozens-to-hundreds of libraries, as well as a coveted John Carmack endorsment.

Why not just use Collada?

Collada is an XML approach, also from Khronos group. Another way of stating this question is, "why do we have ROS packages instead of a single Collada file?". Reasons: the COLLADA spec is gigantic, the files are annoying and slow to parse, it half- assedly supports everything in the universe, is XML based, and has multiple very incompatible versions.

Robot-GLTF Design Goals

  • Replace ROS package (e.g. pr2_description, herb_description, etc) with a single .GLB file
  • No ROS dependency.
  • Allow the ecosystem of GLTF viewing and authoring tools (Blender, Maya, etc.) to use and edit it as a regular GLTF file.
  • Bidirection autogeneration: Given a ROS package, we should be able to generate the robot-gltf file, and given a robot-gltf file we should be able to generate a ROS package older tools can use without being totally re- written. We can design new tools to use it natively and incrementally replace old pipelines.
  • Eventually replace xacro with jinja2
  • pip install robot-gltf works on Windows, Linux, and Mac.

Problems Solved

  • OBJ files referencing materials that have to be found somewhere on the file system
  • Nice PBR materials included in the same file
  • Robot models can be exported from Solidworks and then textured and edited by visual artists using their existing workflow (Blender, etc).
  • Robots are in a single file, with no ROS dependencies and are fully multiplatform.
  • Doesn't require re- writing the whole ROS ecosystem.

Existing Format Overview

Robots in the ROS ecosystem are described in a ROS package, like pr2_description, herb_description, turtlebot_description, etc. The packages consist of a few things:

  • a directory structure including meshes of various types
  • URDF or SRDF files, which are an XML- based kinematics description
  • URDF.xacro files, a robotics- specific templating language

xacro2jinja: Xacro-Jinja2 transpiler

Xacro fills a need, but at its core it is a templating language that is only used by robotics researchers. Templating is not a robot specific problem, and there are a number of extremely active, well tested, widely deployed options. As a very approximate metric, Jinja2 has 5800 github stars and 1800 commits compared to xacro with 12 github stars and 384 commits. Jinja2 has Python and C++ implementations.

@gonzalocasas
Copy link

Very interesting! Is there any implementation of this in progress?

@awesomebytes
Copy link

Very interesting indeed!

@AwokeKnowing
Copy link

i love it

@sancelot
Copy link

This sounds realistic, since manipulation of robots involve some word / local transofrm availbale in the gltf apis.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment