Package: sdformat-mjcf
sdformat-mjcfThis 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-mjcfTo start development, create a python3 virtual environment, and upgrade pip.python3-mvenvpath/to/venv--system-site-packages
.path/to/venv/bin/activate

pipinstall-UpipInstallpython3-gz-math7andpython3-sdformat13from thenightlyrepo. On macOS, add theosrf/simulationtap and installsdformat13:brew tap osrf/simulation
brew install sdformat13Install thesdformat-mjcfpackagepipinstallsdformat-mjcfRunning testsSimple run of test can be done by using:python -m unittestTools for converting SDFormat to MJCFUse the commnad line toolsdf2mjcf:usage:sdf2mjcf[-h]input_fileoutput_file

positionalarguments:input_filePathtoinputSDFormatfile(WorldorModel)output_fileDesiredpathfortheoutputMJCFfile

optionalarguments:-h,--helpshowthishelpmessageandexitTo run the MJCF file in Mujoco, download a Mujoco release fromhttps://github.com/deepmind/mujoco/releases,
extract the contents and run<path/to/mujoco>/bin/simulateoutput_file.xmlSuported featuresModels/WorldsLinksSensorsAltimeterCameraForce torqueIMUJointsBallContinuousFixedPrismaticRevoluteMaterialsUnsuported featuresNested modelsLinks with multiple parents and kinematic loopsRevolute2 and Universal joints<scene>element<physics>elementModels fromFuelModels contain URIs with schemes such asmodel://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 withobj2mjcfto 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 SDFormatUse the commnad line toolmjcf2sdf:usage:mjcf2sdf[-h][--export_world_plugins]input_fileoutput_file

positionalarguments:input_filePathtoinputMJCFfileoutput_fileDesiredpathfortheoutputSDFormatfile

optionalarguments:-h,--helpshowthishelpmessageandexit--export_world_pluginsExportworldpluginsIf you are going to use the converted file in Gazebo Sim you should use the flag--export_world_pluginsto 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, followthese instructions to install Gazebo SimSuported featuresBodiesGeomsSensorsCameraForce torqueIMUJointsFixedFreeHingeSlideMaterialsUnsuported featuresTendonGeneration of procedural texturesActuatorsEquality ConstraintsCollision filtershfieldsskinsoption.timestepFitting of meshes with primitives, convex hulls or AABBsSettings that affect the constraint solverLights that track or target objectsOther limitations:Only the valuesxyzandXYZare supported forcompiler.eulerseqlocalcoordinates are assumed forcompiler.coordinateEach 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.