How to Create URDF from CAD Software
Overview
This document explains how to create a URDF file from SolidWorks models by using:
SolidWorks to URDF Exporter
scikit-robot’s
convert-urdf-meshcommand
SolidWorks to URDF Exporter This exporter helps convert SolidWorks assemblies into a format (3dxml) which is more easily processed to produce URDF-compatible mesh files.
scikit-robot ``convert-urdf-mesh`` A tool within the scikit-robot library that can convert 3D model files (like
.3dxml,.obj,.stl, etc.) into a URDF or mesh files (e.g.,.dae) suitable for ROS.
Coordinate Systems
.3dxml export: uses the overall assembly coordinate system from SolidWorks.
.stl export: uses each part’s or link’s local coordinate system.
convert-urdf-mesh provides an option for adjusting coordinates:
--force-zero-origin: Forces the origin to be the link’s local coordinate in the converted mesh files (e.g.,.dae). - Useful when your source is in the assembly coordinate system (like.3dxml). - Highly recommended if you plan to use these meshes in MuJoCo.
Installation
Install scikit-robot
pip install scikit-robot
or clone directly from GitHub if you need the latest updates:
git clone https://github.com/iory/scikit-robot.git
cd scikit-robot
pip install -e .
Install SolidWorks URDF Exporter
Obtain the plugin from the following link:
Follow the official instructions to install it into your SolidWorks environment.
Workflow
Export from SolidWorks
In SolidWorks, open your assembly.
Use the “SolidWorks to URDF Exporter” plugin to generate a
.3dxmlfile.
Convert to DAE (or STL) and Generate URDF
Run the scikit-robot command to convert
.3dxml(or other mesh formats) to.daeand generate a URDF automatically.Example usage:
convert-urdf-mesh <URDF_PATH> --output <OUTPUT_URDF_PATH>
This command outputs: - A set of mesh files (e.g.,
.dae) - A URDF file referencing those meshes
Verify URDF in ROS
Copy the generated URDF and mesh files into your ROS package.
Test in Rviz or another ROS-compatible viewer:
roslaunch urdf_tutorial display.launch model:=path/to/generated.urdf
Confirm the model loads and displays properly.
Usage with MuJoCo
MuJoCo typically requires meshes to be centered at their local origin.
Therefore, always use the
--force-zero-originoption when converting to ensure proper alignment.
convert-urdf-mesh <URDF_PATH> --output <OUTPUT_URDF_PATH> --force-zero-origin