Tool to convert between SDFormat and MJCF
Project description
sdformat-mjcf
This Python package allows bidirectional conversion between SDFormat and MJCF to share worlds and robot models. We have created a command line tool to convert between these two formats. It takes as input an SDFormat file that works in Gazebo Sim and produces as output a MJCF file that works in Mujoco with approximately equivalent results; and vice versa.
Install sdformat-mjcf
To start development, create a python3 virtual environment, and upgrade pip.
python3 -m venv path/to/venv --system-site-packages
. path/to/venv/bin/activate
pip install -U pip
Install python3-gz-math7 and python3-sdformat13 from the
nightly repo. On macOS, add the osrf/simulation tap and install sdformat13:
brew tap osrf/simulation
brew install sdformat13
Install the sdformat-mjcf package
pip install sdformat-mjcf
Running tests
Simple run of test can be done by using:
python -m unittest
Tools for converting SDFormat to MJCF
Use the commnad line tool sdf2mjcf:
usage: sdf2mjcf [-h] input_file output_file
positional arguments:
input_file Path to input SDFormat file (World or Model)
output_file Desired path for the output MJCF file
optional arguments:
-h, --help show this help message and exit
To run the MJCF file in Mujoco, download a Mujoco release from https://github.com/deepmind/mujoco/releases, extract the contents and run
<path/to/mujoco>/bin/simulate output_file.xml
Suported features
- Models/Worlds
- Links
- Sensors
- Altimeter
- Camera
- Force torque
- IMU
- Joints
- Ball
- Continuous
- Fixed
- Prismatic
- Revolute
- Materials
Unsuported features
- Nested models
- Links with multiple parents and kinematic loops
- Revolute2 and Universal joints
<scene>element<physics>element- Models from Fuel
- Models contain URIs with schemes such as
model://orpackage://.
Other limitations:
- Collada (
.dae) meshes are not supported by Mujoco. Therefore, the user has to first convert each.daefile to.objor.stlfile using available tools such asblenderormeshlab. The SDFormat file has to then be updated to point to the converted mesh files instead of the.daefiles. - Mujoco does not support composite
.objfiles. However, users may process the output.objfiles with obj2mjcf to split them into individual.objfiles. - Only the diffuse texture from a PBR material is converted to MJCF. Other textures are not supported.
Tools for converting MJCF to SDFormat
Use the commnad line tool mjcf2sdf:
usage: mjcf2sdf [-h] [--export_world_plugins] input_file output_file
positional arguments:
input_file Path to input MJCF file
output_file Desired path for the output SDFormat file
optional arguments:
-h, --help show this help message and exit
--export_world_plugins
Export world plugins
If you are going to use the converted file in Gazebo Sim you should use the flag
--export_world_plugins to export some of the plugins that are required to make
the new world work properly in Gazebo Sim.
To run the SDFormat file in GazeboSim, follow these instructions to install Gazebo Sim
Suported features
- Bodies
- Geoms
- Sensors
- Camera
- Force torque
- IMU
- Joints
- Fixed
- Free
- Hinge
- Slide
- Materials
Unsuported features
- Tendon
- Generation of procedural textures
- Actuators
- Equality Constraints
- Collision filters
- hfields
- skins
option.timestep- Fitting of meshes with primitives, convex hulls or AABBs
- Settings that affect the constraint solver
- Lights that track or target objects
Other limitations:
- Only the values
xyzandXYZare supported forcompiler.eulerseq localcoordinates are assumed forcompiler.coordinate- Each kinematic tree in
<worldbody>is placed inside a<model>when converted to SDFormat. The<self_collide>element is always set to false for<model>s to avoid collisions between links connected by mulitple joints in series.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file sdformat_mjcf-0.1.2.tar.gz.
File metadata
- Download URL: sdformat_mjcf-0.1.2.tar.gz
- Upload date:
- Size: 29.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f331f387055a6e6ee30909a4914cf30359af941bc98e24d87e999d3f0eeef4d0
|
|
| MD5 |
b02529fbe681b220c42ddf202e35f4b9
|
|
| BLAKE2b-256 |
689fd37f880b6966b2d91d2e535aa49b8d76ab0f6006f0cab408e057fad9b089
|
File details
Details for the file sdformat_mjcf-0.1.2-py3-none-any.whl.
File metadata
- Download URL: sdformat_mjcf-0.1.2-py3-none-any.whl
- Upload date:
- Size: 44.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8d67afc5fdc45a181ed78f1875c472422c77dd8d7ce1068f5b76c07dda3cfdc4
|
|
| MD5 |
aef96acda12e827603e4af251a239a85
|
|
| BLAKE2b-256 |
7d9d49c9eeb1e90eceb4733a893ca87b61a8af18354ffd1a4ca927d95fc49c8e
|