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:
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")
msg = receive(sub, 20)
pub = ros2publisher(testNode1,"/topic_1","std_msgs/String");
pubMsg = ros2message("std_msgs/String");
pubMsg.data = 'Hello';
for x = 1:10