Fail to list ros2 topics when ubuntu publish topics with same ros_domain_id and same subnet.

Env: Ubuntu 20.04 LTS VM; ROS2-Foxy; Middle DDS Implementation: Fast/Cyclone; Topics published by px4_ros_com.
When i set ros_domain_id=0 both in ubuntu and matlab, it seems that matlab or ubuntu local could list topics with same id. However, when i set ros_domain_id to non-zero value, matlab or ubuntu local could only list topics with id=0. For example, i set ros_domain_id to 25 and pulish topics of px4_msgs, matlab and ubuntu local with ros_domain_id = 0 can list topics instead of ros_domain_id = 25.

8 Commenti

How are you specifying the domain ID when you try to list topics? In Simulink or in MATLAB Command Window?
Have you tried both of these methods (for MATLAB):
setenv('ROS_DOMAIN_ID', '25')
ros2 topic list
and:
ros2 topic list DomainID 25
-Cam
Yes, i tried this method.
setenv('ROS_DOMAIN_ID', '25')
ros2 topic list
And i specified id in Matlab command window. Also i tried specified id in simulink and tragged a subscriber block to see topics in ros net. But.. no topics that it should list.
Then let's try to narrow down on the problem. Determine if the issue is specific to the domain even within MATLAB, or if it only applies to external nodes.
% Set up 2 networks
node0 = ros2node('/node_0', 0);
pub0 = ros2publisher(node0, '/topic_0', 'std_msgs/String');
node25 = ros2node('/node_25', 25);
pub25 = ros2publisher(node25, '/topic_25', 'std_msgs/String');
% Check if nodes and topics are visible
ros2('topic', 'list', 'DomainID', 0); % Dummy call - get the introspection node on 0
pause(5) % Wait for introspection node to pick up metacommunication
nodeList0 = ros2('node', 'list', 'DomainID', 0)
topicList0 = ros2('topic', 'list', 'DomainID', 0)
ros2('topic', 'list', 'DomainID', 25); % Dummy call
pause(5) % Wait for metacommunication
nodeList25 = ros2('node', 'list', 'DomainID', 25)
topicList25 = ros2('topic', 'list', 'DomainID', 25)
What are the results of running that code?
-Cam
>> node0 = ros2node('/node_0', 0);
pub0 = ros2publisher(node0, '/topic_0', 'std_msgs/String');
node25 = ros2node('/node_25', 25);
pub25 = ros2publisher(node25, '/topic_25', 'std_msgs/String');
>> ros2('topic', 'list', 'DomainID', 0);
/parameter_events
/rosout
/topic_0
>> nodeList0 = ros2('node', 'list', 'DomainID', 0)
nodeList0 =
1×1 cell 数组
{'/node_0'}
>> topicList0 = ros2('topic', 'list', 'DomainID', 0)
topicList0 =
3×1 cell 数组
{'/parameter_events'}
{'/rosout' }
{'/topic_0' }
>> ros2('topic', 'list', 'DomainID', 25);
/parameter_events
/rosout
/topic_25
>> nodeList25 = ros2('node', 'list', 'DomainID', 25)
nodeList25 =
1×1 cell 数组
{'/node_25'}
>> topicList25 = ros2('topic', 'list', 'DomainID', 25)
topicList25 =
3×1 cell 数组
{'/parameter_events'}
{'/rosout' }
{'/topic_25' }
The result shows that ros_domain_id work fine in matlab. Maybe the problem is in ubuntu vm.
Sounds like it. There are a couple of other posts I've made on ROS 2 communication issues. It's focused on Domain ID and subnet, but there are additional troubleshooting steps too. Give them a look and see if it resolves or helps narrow down on the problem:
-Cam
Yesterday i tested the normal nodes without PX4 on ubuntu vm and real system, the nornal nodes could work under the same and non-zero ROS_DOMAIN_ID, could list topics. And using the px4 to publish topics, ROS_DOMAIN_ID couldn't work fine, so i thought the problem may be caused by px4_ros_com? or something else about px4.
Sounds like it. Are you working off of this example, or using your own call to the PX4 software?
It's my own test. The example of px4 with ros2 in matlab, it tested before with ros_domain_id = 0, and worked fine, others id was same problem.

Accedi per commentare.

Risposte (1)

Hi Jingyu,
I hope you've found a solution to this issue. If not, please also feel free to also reach out to our techinical support team, and we can take a closer look.
For people who might face simimlar issue, as Cam pointed, you may also want to check the following to links to see if they can help resolving the issue or narrowing down the root cause:
Thanks,
Josh

Prodotti

Release

R2022a

Richiesto:

il 6 Mag 2022

Risposto:

il 10 Gen 2023

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by