Ros does not receive data from MATLAB publishing topics

4 views (last 30 days)
I use ubuntu18.04 melodic ros and matlabR2021a.
My linux operate system IP is: 172.20.10.3
My windows operate system IP is: 172.20.10.11
First, in my linux operate system:
I set the
explore ROS_MASTER_URI = https://172.20.10.3:11311
explore ROS_HOST_NAME = 172.20.10.3
explore ROS_IP = 172.20.10.3
Then, I start the "roscore" in my linux.
Second, in my windows10 operate system:
I use the matlab and set
setenv('ROS_MASTER_URI','http://172.20.10.3:11311/')
setenv('ROS_HOSTNAME','172.20.10.11')
setenv('ROS_IP','172.20.10.11')
rosinit()
Then, in the matlab terminal, use
ros topic list
could see all the ros topic in the matlab terminal.
Then, I run the code in the matlab
chatterpub = rospublisher('/chatter',rostype.std_msgs_String)
chattermsg = rosmessage(chatterpub)
chattermsg.Data = 'hello world'
send(chatterpub,chattermsg)
pause(5)
in the ros terminal, i can see the topic '/chatter', when i use 'topic echo /chatter', the ros can't receive the data 'hello world'.
To sum up, i can see all the topic list and topic node in the matlab and ros, but ros can't receive the data from matlab.
How do i deal withe this problem?

Answers (1)

praguna manvi
praguna manvi on 29 Nov 2024 at 12:05
Hi @黄,
It seems you are unable to receive messages echoed from MATLAB using "rostopic." Here is a link to a useful discussion thread on a similar issue. You could troubleshoot by using regular "ping" in both directions and follow the detailed steps in the link below:

Community Treasure Hunt

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

Start Hunting!