Status: Ready
MuJoCo simulation using mujoco_ros2_control (ros-controls fork). MuJoCo converts the URDF to MJCF internally and runs physics + rendering in the ros2_control_node process.
Docker (recommended):
- Docker Desktop
Native ROS2:
- ROS2 Humble
mujoco_ros2_control(built from source -- see below)mujocopip package
cd simulation/so_arm_101_description
docker compose run mujocoThe Docker image builds mujoco_ros2_control from source automatically.
# Clone dependencies into your workspace
cd ~/ros2_ws/src
git clone --depth 1 https://github.com/ros-controls/ros2_control_cmake.git
git clone --depth 1 https://github.com/pal-robotics/mujoco_vendor.git
git clone --depth 1 https://github.com/ros-controls/mujoco_ros2_control.git
# Build
cd ~/ros2_ws
colcon build --packages-up-to mujoco_ros2_control so_arm_101_description
# Launch
source install/setup.bash
ros2 launch so_arm_101_description sim.launch.py sim:=mujoco- The plugin
mujoco_ros2_control/MujocoSystemInterfaceis selected viasim_backend:=mujoco - A custom node (
publish_mujoco_description) publishes the URDF to/mujoco_robot_description - The MuJoCo plugin reads the URDF, converts it to MJCF, and starts the simulation
- The
<mujoco><compiler meshdir=.../>tag in the URDF tells MuJoCo where to find collision meshes - A rendering window opens showing the simulation (1280x720, patched from full-screen default)
headless: Set totruefor headless mode (no rendering window)sim_speed_factor: Simulation speed multiplier (default: 1.0)
ros2 topic echo /joint_states --once
ros2 action send_goal /arm_controller/follow_joint_trajectory \
control_msgs/action/FollowJointTrajectory "{
trajectory: {
joint_names: [base_link_to_link1, link1_to_link2, link2_to_link3, link3_to_link4, link4_to_link5],
points: [{positions: [0.5, -0.5, 0.8, -0.3, 0.0], time_from_start: {sec: 2}}]
}
}"- OpenGL errors: Ensure GPU drivers are installed. For Docker, uncomment the NVIDIA GPU block in
docker-compose.yaml. - Window too large: The Docker image patches the window to 1280x720. For native installs, the MuJoCo window may be full-screen by default.
- No display: MuJoCo needs an X11 server for the rendering window. Use
headless:=truein the xacro if no display is available.