This ROS 2 package provides support for the Modulr Agent running on the Unitree Go2 robot. It includes nodes for motion control forwarding and video transmission over Zenoh DDS.
The package provides two main executables:
- fwd_motion: Forwards motion commands to the Unitree Go2 robot
- unitree_video: Streams video from the Unitree SDK over Zenoh DDS for efficient network transmission
- ROS 2 (Foxy is already installed on Go2)
- Unitree Go2 Edu with standard installation
- SSH access to Go2
- Wireless connection to the internet from Go2 (for remote operation)
- Dependencies:
unitree_go(Unitree ROS 2 messages, already installed on system)zmq(ZeroMQ)
Before installing this package, you may configure the Go2's bash environment to automatically load ROS 2 Foxy and the Unitree messages.
The default Unitree Go2 installation includes an interactive prompt in ~/.bashrc that asks you to choose between ROS Foxy and ROS Noetic. This may be replaced with automatic loading.
- SSH into your Go2 robot:
ssh unitree@<go2-ip-address>- Edit the
~/.bashrcfile:
nano ~/.bashrc- Find and replace the fishros initialization section. Replace this:
# >>> fishros initialize >>>
echo "ros:foxy(1) noetic(2) ?"
read choose
case $choose in
1) source /opt/ros/foxy/setup.bash;
source ~/cyclonedds_ws/install/setup.bash;
export RMW_IMPLEMENTATION=rmw_cyclonedds_cpp;
export CYCLONEDDS_URI=~/cyclonedds_ws/cyclonedds.xml;
export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH;;
2) source /opt/ros/noetic/setup.bash;;
esac
# <<< fishros initialize <<<With this:
# Choose foxy automatically
source ~/cyclonedds_ws/install/setup.bash;
export RMW_IMPLEMENTATION=rmw_cyclonedds_cpp;
export CYCLONEDDS_URI=~/cyclonedds_ws/cyclonedds.xml;
export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH;
# Load extra messages from unitree_go
source /unitree/module/graph_pid_ws/install/setup.bash-
Save and exit
-
Apply the changes:
source ~/.bashrcThis configuration ensures that ROS 2 Foxy and the Unitree Go2 messages are automatically loaded when you SSH into the robot.
- Clone the repository with submodules into a new ROS 2 workspace:
mkdir -p ~/local_ws/src
git clone --recursive https://github.com/ModulrCloud/modulr-unitree-go2.git ~/local_ws/src/modulr_unitree_go2Or if you already cloned it, initialize the submodules:
git submodule update --init --recursive- Install dependencies:
sudo apt-get install ros-$ROS_DISTRO-sensor-msgs- Build the package:
cd ~/local_ws
colcon build --packages-select modulr_unitree_go2
source install/setup.bashTo automatically launch the nodes when the Go2 boots up, you can install a systemd user service.
- Navigate to the package directory:
cd ~/local_ws/src/modulr_unitree_go2/systemd- Run the installation script:
./install_service.shThis will:
- Install the service file to
~/.config/systemd/user/ - Enable the service to start automatically on boot
- Enable user lingering (allows the service to run without an active login session)
Start the service immediately:
systemctl --user start modulr-unitree-go2.serviceStop the service:
systemctl --user stop modulr-unitree-go2.serviceCheck service status:
systemctl --user status modulr-unitree-go2.serviceView real-time logs:
journalctl --user -u modulr-unitree-go2.service -fDisable autostart:
systemctl --user disable modulr-unitree-go2.serviceRestart the service:
systemctl --user restart modulr-unitree-go2.serviceThe service file is located at systemd/modulr-unitree-go2.service and includes:
- Automatic restart on failure (with 5-second delay)
- Proper environment variable setup for ROS 2 and CycloneDDS
- Logging to systemd journal
If you need to customize the service (e.g., change environment variables or workspace paths), edit the service file and run:
systemctl --user daemon-reload
systemctl --user restart modulr-unitree-go2.serviceIt is recommended to launch all nodes at the same time using the bringup launch file:
ros2 launch modulr_unitree_go2 bringup.launch.pyThis will start all three nodes (fwd_motion, fwd_camera, and unitree_video) simultaneously for complete robot operation.
Forward motion commands to the robot:
ros2 run modulr_unitree_go2 fwd_motionThis node subscribes to motion command topics and forwards them to the Unitree Go2 robot using the Unitree SDK.
Stream video from the Unitree SDK over Zenoh DDS:
ros2 run modulr_unitree_go2 unitree_videoThis executable uses the Unitree SDK2 to capture video and stream it over ZMQ for low-latency network transmission.
modulr_unitree_go2/
├── CMakeLists.txt # Build configuration
├── package.xml # ROS 2 package metadata
├── README.md # This file
├── src/
│ ├── fwd_motion.cpp # Motion forwarding node
│ └── unitree_video.cpp # Video streaming via ZMQ
├── launch/ # ROS 2 launch files
│ └── bringup.launch.py # Main launch file for all nodes
├── systemd/ # Systemd service files
│ ├── modulr-unitree-go2.service # User service definition
│ └── install_service.sh # Service installation script
└── third_party/
└── unitree_sdk2/ # Unitree SDK2 submodule
This package includes the following third-party dependency as a git submodule:
- Unitree SDK2: Official SDK for Unitree robots
- Zenoh-C: Zenoh C library for Zenoh backend implementation
MIT-0
Michael Hart (Modulr) - michael@modulr.cloud
For issues, questions, or contributions, please contact the maintainer.