Docker wrapper for the mocap4ros2_optitrack driver. A ROS 2 lifecycle node that streams OptiTrack motion capture data via the NatNet SDK. Runs on ROS 2 Jazzy.
- Docker
- docker compose
- vcstool:
sudo apt install vcstool
Clone all source repos and build the Docker image:
./setup.shThis will:
- Clone all ROS 2 workspace source repos into
files/src/ - Build the Docker image
Edit .env to set the container name, hostname, and ROS version if needed.
An example config files are provided:
mocap4r2_optitrack_driver_params.yaml— default config
Key parameters to update before launching:
| Parameter | Description |
|---|---|
server_address |
IP of the OptiTrack Motive PC |
local_address |
IP of the local machine running this container |
connection_type |
Unicast or Multicast |
publish_tf |
Enable TF publishing for rigid bodies |
publish_y_up_tf |
Publish static transform from ROS Z-up to OptiTrack Y-up frame |
rigid_bodies |
List of rigid body names (must match names set in Motive) |
# Allow GUI apps (RViz) to connect to the host display
xhost +local:docker
docker compose up -d
docker exec -it ros2-mocap-optitrack bashros2 launch mocap4r2_optitrack_driver optitrack2.launch.pyros2 lifecycle set /mocap4r2_optitrack_driver_node activate# Rigid body poses
ros2 topic echo /rigid_bodies
# TF transforms (requires publish_tf: true in config)
ros2 topic echo /tf
# Static Y-up transform (requires publish_y_up_tf: true in config)
ros2 topic echo /tf_staticWhen publish_tf: true, the driver publishes a TF transform for each rigid body listed under rigid_bodies in the config. The name field must exactly match the rigid body name as configured in Motive.
When publish_y_up_tf: true, a one-time static transform is published to bridge ROS's Z-up convention and OptiTrack's Y-up convention:
map (Z-up) → optitrack (Y-up) → <rigid_body_name>
ros2 run rviz2 rviz2