
A C++ library bridging MuJoCo physics simulation with KDL for robot kinematics and dynamics.
Screenshots
Features
- Scene builder – compose MJCF robots, grippers, objects, and cameras into one MuJoCo scene via mjSpec, with ordered attachment chains and relative placement.
- Multi-robot – multiple robots with independent KDL chains in one simulation.
- KDL from the model – builds the KDL chain directly from the compiled MuJoCo model.
- Control – POSITION / TORQUE ports plus KDL FK, IK, RNEA, and ACHD solvers.
- Runtime environments – Env with reset hooks for task setup and replay.
- Interactive viewer – MuJoCo simulate UI with Frames / Trace / Perturb panels and overlay lines.
- Recording – interactive and headless EGL + ffmpeg MP4 capture.
- Python bindings – the same API from Python via pip install, returning PyKDL types.
Install
Ubuntu/Debian. Requires MuJoCo 3.9.0 (auto-downloaded), CMake >= 3.16, a C++20 compiler, and (for Python) Python >= 3.10. The secorolab Orocos KDL fork is built from source; the system KDL is never used.
Full details and every flag are in the installation guides:
System packages
sudo apt install cmake g++ git python3-dev python3-venv \
libeigen3-dev libglfw3-dev libgl-dev libegl-dev ffmpeg
C++ (CMake)
git clone https://github.com/vamsikalagaturu/mj_kdl_wrapper.git
# pin a release with --branch v0.1.0 (see Releases for the latest tag)
cd mj_kdl_wrapper
# configure (downloads MuJoCo, clones and builds the KDL fork; the menagerie
# flag fetches Menagerie models and copies bundled assets into the user cache
# at ~/.cache/mj_kdl_wrapper, which the examples and tests resolve from)
cmake -B build -DCMAKE_BUILD_TYPE=RelWithDebInfo -DMJ_KDL_FETCH_MENAGERIE=ON
# compile
cmake --build build --parallel $(nproc)
# optional install; self-contained, bundles KDL into the prefix
cmake --install build
# check: run the pick-and-place example
./build/src/examples/ex_pick
To share one KDL across several projects, set up a ws/ folder, build the fork once into ws/install, and point the wrapper (and any sibling) at it instead of bundling its own:
# Workspace folder with the two source trees
mkdir -p ws && cd ws
git clone -b feature/achd_fixed_joint \
https://github.com/secorolab/orocos_kinematics_dynamics.git
git clone https://github.com/vamsikalagaturu/mj_kdl_wrapper.git
# 1. Build the KDL fork once into ws/install
cmake -S orocos_kinematics_dynamics/orocos_kdl -B build/orocos_kdl \
-DCMAKE_INSTALL_PREFIX="$PWD/install" -DENABLE_TESTS=OFF
cmake --build build/orocos_kdl --parallel $(nproc)
cmake --install build/orocos_kdl
# 2. Build the wrapper against that shared KDL (bundles none of its own)
cmake -S mj_kdl_wrapper -B build/mj_kdl_wrapper \
-DCMAKE_INSTALL_PREFIX="$PWD/install" -DMJ_KDL_OROCOS_KDL_INSTALL_DIR="$PWD/install"
cmake --build build/mj_kdl_wrapper --parallel $(nproc)
cmake --install build/mj_kdl_wrapper
The standalone guide covers tests, custom MuJoCo/KDL, sharing one KDL across projects, and all CMake options.
Python
uv pip install "git+https://github.com/vamsikalagaturu/mj_kdl_wrapper.git"
# pin a release by appending @v0.1.0 to the URL (see Releases for the latest tag)
# fetch the MuJoCo Menagerie models and bundled assets into the user cache
mj-kdl-fetch-menagerie
Installing without a @tag tracks the main branch, which only advances at releases - so the default command above already installs the latest release.
Bundles MuJoCo, the KDL fork, and PyKDL. See the standalone guide for editable installs, Menagerie models, and build options.
The example scripts ship in the wheel. Copy them out, populate the cache, and run one (the scripts resolve models and bundled assets from the cache, so they run from anywhere):
# copy the bundled example scripts into ./mj_kdl_wrapper_examples
mj-kdl-fetch-examples
cd mj_kdl_wrapper_examples
# populate the user cache with Menagerie models and bundled assets
mj-kdl-fetch-menagerie
# check: run the pick-and-place example
python examples/ex_pick.py --gui
ROS 2 (colcon)
Tested on ROS 2 Jazzy and Lyrical. Build the secorolab KDL as its own workspace package, then the wrapper against it so the overlay shares one liborocos-kdl:
# Workspace with the KDL fork and the wrapper as sibling packages
mkdir -p ~/ros2_ws/src && cd ~/ros2_ws
git clone -b feature/achd_fixed_joint \
https://github.com/secorolab/orocos_kinematics_dynamics.git src/orocos_kinematics_dynamics
git clone https://github.com/vamsikalagaturu/mj_kdl_wrapper.git src/mj_kdl_wrapper
# pin a release with --branch v0.1.0 (see Releases for the latest tag)
# Use your distro: jazzy or lyrical
source /opt/ros/jazzy/setup.bash
# 1. Build the shared KDL package
colcon build --packages-select orocos_kdl --cmake-args -DENABLE_TESTS=OFF
source install/setup.bash
# 2. Build the wrapper against it (add -DMJ_KDL_FETCH_MENAGERIE=ON to fetch
# the Menagerie models needed by the examples and tests)
colcon build --packages-select mj_kdl_wrapper --cmake-args -DMJ_KDL_OROCOS_KDL_FROM_PACKAGE=ON
The ROS 2 guide covers the Python venv, the shared-KDL rationale, build ordering, and consuming it from your own nodes.
API
Examples
The example catalog lives in docs/examples.md. Every C++ src/examples/ex_*.cpp example has a same-name Python counterpart in python/examples/, including the named force-torque admittance demos: ex_admittance_ft, ex_admittance_ft_rnea, and ex_admittance_ft_achd.
Tests
ctest --test-dir build --output-on-failure
Tests resolve the Menagerie models and bundled assets from the user cache (~/.cache/mj_kdl_wrapper); -DMJ_KDL_FETCH_MENAGERIE=ON at configure populates it, and tests self-skip when it is empty. See test/README.md for the full list.
More Documentation
Assets
These ship in the repo and the wheel, and are copied into the user cache (~/.cache/mj_kdl_wrapper/assets) by -DMJ_KDL_FETCH_MENAGERIE=ON or mj-kdl-fetch-menagerie. Examples and tests resolve them from the cache via mj_kdl_examples::asset(...) (C++) and menagerie.asset_path(...) (Python).
| Path | Description |
| assets/robotiq_2f85/2f85.xml | Local Robotiq 2F-85 gripper asset used by examples/tests |
| assets/ft_sensor.xml | Local 6-axis force-torque sensor asset used by FT examples/tests |
| assets/table.xml | Table asset with authored table_top site |
| assets/mug.xml, assets/mug_table.xml | Pouring example assets |