Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AP_DDS: add param DDS_DOMAIN_ID #27258

Merged
merged 1 commit into from
Jul 20, 2024

Conversation

srmainwaring
Copy link
Contributor

@srmainwaring srmainwaring commented Jun 6, 2024

Add a param DDS_DOMAIN_ID.

This allows the ROS_DOMAIN_ID to be set to values other than the current default of 0, useful for managing multiple vehicles or keeping various ROS 2 running instances separated. The behaviour is backward compatible with a default of 0.

The range of valid domain ids is 0 to 232 (see: https://docs.ros.org/en/rolling/Concepts/About-Domain-ID.html)

Comment: the param should really be ROS_DOMAIN_ID to be consistent with usage with the ros2 cli, but as it's in the DDS_ param tree the name DDS_ROS_DOMAIN_ID would just be confusing.

Testing

Run the default UDP instance:

ros2 launch ardupilot_sitl sitl_dds_udp.launch.py transport:=udp4 synthetic_clock:=True wipe:=False model:=quad speedup:=1 slave:=0 instance:=0 defaults:=$(ros2 pkg prefix ardupilot_sitl)/share/ardupilot_sitl/config/default_params/copter.parm,$(ros2 pkg prefix ardupilot_sitl)/share/ardupilot_sitl/config/default_params/dds_udp.parm sim_address:=127.0.0.1 master:=tcp:127.0.0.1:5760 sitl:=127.0.0.1:5501

In a separate terminal start mavproxy and set the DDS_DOMAIN_ID to a different value:

$ mavproxy.py --master 127.0.0.1:14550 --console

> param set DDS_DOMAIN_ID 1
> param show DDS*
DDS_DOMAIN_ID    1.0
DDS_ENABLE       1.0         # Enabled
DDS_IP0          127.0
DDS_IP1          0.0
DDS_IP2          0.0
DDS_IP3          1.0
DDS_UDP_PORT     2019.0

Now restart the SITL instance prefixing with the ROS_DOMAIN_ID env variable set

ROS_DOMAIN_ID=1 ros2 launch ardupilot_sitl sitl_dds_udp.launch.py transport:=udp4 synthetic_clock:=True wipe:=False model:=quad speedup:=1 slave:=0 instance:=0 defaults:=$(ros2 pkg prefix ardupilot_sitl)/share/ardupilot_sitl/config/default_params/copter.parm,$(ros2 pkg prefix ardupilot_sitl)/share/ardupilot_sitl/config/default_params/dds_udp.parm sim_address:=127.0.0.1 master:=tcp:127.0.0.1:5760 sitl:=127.0.0.1:5501

Use the ros2 cli to inspect nodes:

# expect no nodes, as the default domain is 0
$ ros2 node list
# expect the ardupilot node in domain 1
$ ROS_DOMAIN_ID=1 ros2 node list
/ardupilot_dds

@srmainwaring srmainwaring requested a review from Ryanf55 June 6, 2024 09:54
@srmainwaring srmainwaring force-pushed the prs/prs-dds-domain-id branch from dc28ab1 to 883b216 Compare June 6, 2024 12:31
- Require reboot.
- Set DDS_DOMAIN_ID range: 0 to 232..

Signed-off-by: Rhys Mainwaring <[email protected]>
@srmainwaring srmainwaring force-pushed the prs/prs-dds-domain-id branch from 883b216 to 9cc25e1 Compare June 6, 2024 12:43
Copy link
Collaborator

@Ryanf55 Ryanf55 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, love it. Thanks!

Can we add a wiki change to mention the param?

@peterbarker peterbarker merged commit 5919ef6 into ArduPilot:master Jul 20, 2024
92 checks passed
@srmainwaring srmainwaring deleted the prs/prs-dds-domain-id branch July 20, 2024 09:30
@Ryanf55 Ryanf55 mentioned this pull request Aug 24, 2024
@rmackay9
Copy link
Contributor

this has been included in Copter-4.5.7-beta1 as part of PR #27919

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: 4.5.7-beta1
Status: Done
Development

Successfully merging this pull request may close these issues.

4 participants