Skip to content

Instantly share code, notes, and snippets.

@RishikesavanRamesh
Created August 21, 2024 07:59
Show Gist options
  • Select an option

  • Save RishikesavanRamesh/fdee0a61dc543367346802e88184355d to your computer and use it in GitHub Desktop.

Select an option

Save RishikesavanRamesh/fdee0a61dc543367346802e88184355d to your computer and use it in GitHub Desktop.
ROS 2 Unicast Configuration for FastDDS

Overview

This setup is designed for environments where multiple users share the same network, such as classrooms or office spaces. It addresses the issue of multicast-related disruptions in ROS 2 by enforcing unicast communication through FastDDS. By configuring ROS 2 to search for topic entities only within the loopback address and disabling multicast, this setup maintains network cleanliness and reliability.

While similar to the ROS_LOCALHOST_ONLY=1 configuration, this approach offers added flexibility. It allows for seamless integration with additional devices by configuring them manually, which is not feasible with ROS_LOCALHOST_ONLY.

# docker-compose.yml
services:
ros:
build: .
environment:
- FASTDDS_DEFAULT_PROFILES_FILE=/fastrtps_default_profiles.xml
- RMW_IMPLEMENTATION=rmw_fastrtps_cpp
- RMW_FASTRTPS_USE_QOS_FROM_XML=1
command: sleep infinity
# Dockerfile
FROM ros:humble
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get install -y \
ros-humble-demo-nodes-cpp \
iproute2 tmate tcpdump&& \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
RUN echo 'source /opt/ros/humble/setup.bash' >> ~/.bashrc
COPY <<EOF /fastrtps_default_profiles.xml
<?xml version="1.0" encoding="UTF-8" ?>
<profiles xmlns="http://www.eprosima.com/XMLSchemas/fastRTPS_Profiles">
<participant profile_name="disable_multicast" is_default_profile="true">
<rtps>
<builtin>
<metatrafficUnicastLocatorList>
<locator/>
</metatrafficUnicastLocatorList>
<initialPeersList>
<locator>
<udpv4>
<address>127.0.0.1</address>
</udpv4>
</locator>
</initialPeersList>
</builtin>
</rtps>
</participant>
</profiles>
EOF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment