Cannot echo messages coming from Matlab ROS2

18 visualizaciones (últimos 30 días)
Sergei Jegorov
Sergei Jegorov el 17 de Jul. de 2021
Comentada: Sergei Jegorov el 19 de Jul. de 2021
Greetings everyone,
I am trying to establish a connection between Matlab ROS2 generated nodes and nodes in ROS on the machine. Matlab with ROS2 Toolbox is running on the same machine as the ROS2 (both in Linux environment). Matlab is of version R2021a and ROS 2 is Foxy release.
I am able to send ros messages from ROS on Linux to Matlab and in Matlab they are successfully retrieved. However, it does not work the other way around. When I am publishing a message from Matlab, I can only see and verify that the topic exists using:
ros2 topic list
ros2 topic info /topic_1
But, there are no incoming messages on the Linux side, the ros2 echo shows nothing.
Additionally, I am unable to see any nodes that were generated by Matlab, when in Linux environment I use:
ros2 node list
What could possibly be the problem?
The ROS_DOMAIN_ID global variable on Linux environment to 0, the same as in Matlab ROS2.
The full code of Matlab is:
testNode1 = ros2node("/test1")
sub = ros2subscriber(testNode1,"topic_2")
% wait for 20 secs until message from Linux environment is received
msg = receive(sub, 20)
pub = ros2publisher(testNode1,"/topic_1","std_msgs/String");
pubMsg = ros2message("std_msgs/String");
pubMsg.data = 'Hello';
% publish 'Hello' 10 times to the /topic_1
for x = 1:10
send(pub,pubMsg)
disp('msg sent')
pause(1)
end

Respuesta aceptada

Cam Salzberger
Cam Salzberger el 19 de Jul. de 2021
Hello Sergei,
Please see this answer for up-to-date information on the Dashing-Foxy connectivity issue, and workarounds.
-Cam

Más respuestas (0)

Productos


Versión

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by