Trying to connect to an active node [ROS2]

72 vues (au cours des 30 derniers jours)
JLepers
JLepers le 21 Déc 2019
Commenté : Pratyush Swain le 24 Oct 2023
I am trying to publish and subscribe between a Matlab Simulink model (using ROS toolbox) and a ROS2 package in a Linux environment. I am able to communicate between 2 Ubuntu Virtual machines so I though that it should work with Matlab as well. I am also able to ping between my computer and the virtual machine but when I try the 'ros2 topic list' in Matlab, I am not able to detect the active topic.
What could be the problem ?
Should Matlab not act like any other ROS2 environment ?
Thanks!
Edit: I didn't specify any Domain ID, but this should not be a problem because the whole netwerk should be able to find the active topic.
  3 commentaires
Olmer Garcia
Olmer Garcia le 9 Oct 2020
We have tested too with the same result)we can send information to simulink but we can not send information to ROS2 in ubuntu), we think that the version of Matlab is ros2 dashing.
Scott Nortman
Scott Nortman le 23 Fév 2021
Same issue here; downloaded the pre release 2021a and STILL can NOT work with Foxy...
This is crazy... Why so far behind??? Foxy was released in June 2020 and the 2021a version does not support it...
Mathworks needs to do better...

Connectez-vous pour commenter.

Réponses (1)

Cam Salzberger
Cam Salzberger le 3 Jan 2020
There are two different factors in determining what is and isn't within a ROS 2 network. The first is the domain ID, and the second is the subnet.
The domain ID is controlled by setting the "ROS_DOMAIN_ID" environment variable or (within MATLAB) by providing the domain ID as an argument. If not provided, and the environment variable is unset, MATLAB assumes the default domain ID of 0 should be used. This is the default domain used by Fast-RTPS, MATLAB's ROS 2 DDS implementation, but other DDS implementations may use a different default domain ID. It probably wouldn't hurt to set the same ROS_DOMAIN_ID value in your VM and on MATLAB, just to ensure they are on the same network.
To clarify, introspection functions (like "ros2 topic list") only apply within the specified domain ID. You cannot introspect into multiple ROS 2 networks at the same time.
The other factor, the subnet, is determined by the IP address and subnet mask of the machines themselves. By default, the subnet mask for a system is typically 255.255.255.0, meaning that the subnet is defined as all machines with an IP address that have the first three "segments" identical. So if your machine has IP address 192.34.17.36, and another has IP 192.34.17.128, then those are on the same subnet. However, a machine with IP 192.34.18.37 would not be on the same subnet.
Verify that both your host computer and your VM are on the same subnet (ipconfig on Windows, ifconfig on Unix). If they are not on the same subnet, you make ROS 2 consider them viable targets for inclusion in a network by creating a DEFAULT_FASTRTPS_PROFILES.xml file in your active directory, as detailed here. Make sure the domain ID specified in that file matches the one you use for your network, and you create the file on both machines.
Another issue we have seen with VMs is the Network Adapter connection setting used. Generally, if you are running MATLAB on the host computer that the VM is running on as well, we've seen NAT mode to work well (the VM should share an IP with the host computer, and therefore should be on the same subnet by default). However, if you have a VM running ROS 2, and want to connect to that network from a different physical machine (or multiple machines), you may need Bridged mode (which gives the VM its own IP, and makes it possible to not be on the same subnet).
Other suggested troubleshooting steps:
  • Ensure that you have sourced correctly the setup script from the ROS 2 install on the VM
  • !ping from within MATLAB the VM's IP address
  • Ping from the VM the host machine's IP address
  • Try both NAT and Bridged mode, regardless of your setup
  • Try creating a node on MATLAB, and see if "ros2 node list" on the VM is able to see it
  • After your first call in MATLAB to an introspection command ("ros2 ...") on a specific domain ID, give it a few seconds, and then try again. The introspection calls create an introspection node the first time they are used, and they may not have picked up all the meta-communication from the network when just created.
  • "Reset" the introspection node by calling it for a different (unrelated) domain ID, then call it again for the correct domain ID (repeat the point above if necessary).
Hope this helps give some clarity and next-steps.
-Cam
  4 commentaires
Olmer Garcia
Olmer Garcia le 16 Oct 2020
There exists some planning to support ros foxy? In our tests with ubuntu nodes with ros foxy communicate to nodes in matlab but matlab nodes does not communicate with the ubuntu nodes
Pratyush Swain
Pratyush Swain le 24 Oct 2023
hey @Olmer Garcia , was your ubuntu machine and machine containing matlab on the same subnet ? I am looking to set up communication between two different networks i.e my ubuntu machine in AWS and Matlab on my local system (I only need one way communication, i.e data published in ubuntu machine can be subscribed in matlab)
@Cam Salzberger, I also tried including the xml files as in the 'ros2 communication outside subnet' matlab documentation and further also tried setting up a ros discovery server.I am still able not able to subscribe to any topic in matlab that I publish in my ubuntu ec2 instance in AWS.
I will appreciate any sort of help here.
Thanks.

Connectez-vous pour commenter.

Produits


Version

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by