Connecting ROS 2 Nodes with husarnet-dds
utility
- Level: 🏜️ medium
- Compatible ROS distributions:
ROS 2 Humble
- Compatible RMW implementations:
rmw_fastrtps_cpp
,rmw_cyclonedds_cpp
Husarnet-DDS is a tool that automates the generation of DDS XML configuration files for Husarnet, compatible with both FastDDS and Cyclone DDS.
Examples
Host Setup
Husarnet ROS 2 Docker Base Images
If you use Docker, integrating Husarnet with our ROS 2 Docker images is even easier. The Husarnet-DDS tool is already preinstalled and automatically launched in the entrypoint.
For more information, visit https://github.com/husarnet/ros.
First, install Husarnet-DDS on each device in your Husarnet group (e.g., on your robot and your laptop) from the GitHub releases page. It is available for Linux, macOS, and Windows. For example, on Ubuntu:
RELEASE="v1.3.5"
ARCH="amd64"
sudo curl -L https://github.com/husarnet/husarnet-dds/releases/download/$RELEASE/husarnet-dds-linux-$ARCH -o /usr/local/bin/husarnet-dds
sudo chmod +x /usr/local/bin/husarnet-dds
Next, select the DDS implementation you want to use with your ROS 2 application. Husarnet-DDS supports both Fast DDS and Cyclone DDS.
On each device in your ROS 2 network (e.g., your robot and your laptop), set up the required environment variables according to the DDS implementation you've chosen.
- Fast DDS (Simple Discovery)
- Fast DDS (Discovery Server)
- Cyclone DDS
export RMW_IMPLEMENTATION=rmw_fastrtps_cpp
export FASTRTPS_DEFAULT_PROFILES_FILE=/var/tmp/husarnet-fastdds-simple.xml
husarnet-dds singleshot
For devices acting as a SERVER (using the my-server
Husarnet hostname referenced in the CLIENT configuration below):
export DISCOVERY_SERVER_PORT=11811
husarnet-dds singleshot
fast-discovery-server -i 0 -x /var/tmp/husarnet-dds/fastdds-ds-server.xml
For devices acting as a CLIENT:
export RMW_IMPLEMENTATION=rmw_fastrtps_cpp
export FASTRTPS_DEFAULT_PROFILES_FILE=/var/tmp/husarnet-fastdds-ds-client.xml
export ROS_DISCOVERY_SERVER=my-server:11811
husarnet-dds singleshot
export RMW_IMPLEMENTATION=rmw_cyclonedds_cpp
export CYCLONEDDS_URI=file:///var/tmp/husarnet-cyclone.xml
husarnet-dds singleshot
Docker Setup
You can also run the Docker-based demo (both on the same host and different hosts), by running Husarnet within the container:
👉 See the full husarnet-dds/simple-fastdds
example here.