Advantech Robotic Suite/ROS DOMAIN ID

From ESS-WIKI
Revision as of 11:21, 31 May 2023 by Ray.zheng (talk | contribs)
Jump to: navigation, search

Introduction

ROS 2 uses for communication is DDS. In DDS, the primary mechanism for having different logical networks share a physical network is known as the Domain ID. ROS 2 nodes on the same domain can freely discover and send messages to each other, while ROS 2 nodes on different domains cannot. All ROS 2 nodes use domain ID 0 by default. To avoid interference between different groups of computers running ROS 2 on the same network, a different domain ID should be set for each group.

You'll have to set ROS domain ID while installation, for Advantech ROS2 Suite, you can choose a domain ID between 0 and 101, default is set 0.

Prerequisite

Please make sure that ROS2 Suite v1.3.0 or higher have been installed in your environment.

How to

Set ROS_DOMAIN_ID of the ROS2 suite application

Script for set ROS_DOMAIN_ID of the ROS2 suite application. Note: Currently, this function only supported in ROS2 Suite v1.3.0 on x86.

$ cd /usr/local/Advantech/ros
$ bash -i change-ros-domain-id.sh

Confirm whether the variable is modified successfully in host.

$ echo $ROS_DOMAIN_ID

Confirm whether the variable is modified successfully in container.

$ docker exec -it edge-ros2-foxy bash
$ echo $ROS_DOMAIN_ID


Set ROS_DOMAIN_ID in host manually

Please refer to Q&A : How to set ROS_DOMAIN_ID in host

Set ROS_DOMAIN_ID in docker container manually

Step1: Open docker-compose.yml

$ cd /usr/local/Advantech/ros/container/docker/docker-compose/<docker_container_name>
$ vim docker-compose.yml

Step2: Set ROS_DOMAIN_ID=<your_domain_id> in docker-compose.yml
Note: If you want to follow the host's ROS_DOMAIN_ID variable, please set ROS_DOMAIN_ID=${ROS_DOMAIN_ID}

.
.
.
   environment:
    - ROS_DOMAIN_ID=<your_domain_id>
.
.
.

Step3: Restart container for update environment variables of docker container

$ cd /usr/local/Advantech/ros/container/docker
$ ./stop.sh <docker_container_name>
$ ./launch.sh <docker_container_name>

Step4: Confirm whether the variable is modified successfully in container

$ docker exec -it <docker_container_name> bash
$ echo $ROS_DOMAIN_ID