Cannot echo messages coming from Matlab ROS2
조회 수: 20 (최근 30일)
이전 댓글 표시
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
댓글 수: 0
채택된 답변
Cam Salzberger
2021년 7월 19일
Hello Sergei,
Please see this answer for up-to-date information on the Dashing-Foxy connectivity issue, and workarounds.
-Cam
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Specialized Messages에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!