MATLAB Answers

External ROS node can't communicate with simulink

27 ビュー (過去 30 日間)
Mark Duntz
Mark Duntz 2019 年 8 月 13 日
回答済み: Ines Vujkovac 2019 年 10 月 8 日
I am trying to implement the simulink drone controller simulation with Gazebo shown in the Mathworks webinar "MATLAB and Simulink Robotics Arena: Simulating Quadcopter Missions"
I am able to get everything setup, but when I run the simulink controller, it does not affect the Gazebo simulation. Both ROS nodes are detecting each other, and the topics are running correctly. I have traced the problem to the communication between the Simulink controller and the Gazebo sim. Simulink is publishing messages but the Gazebo sim is not receiving them.
Does this have something to do wih the node IPs? I have tried all combinations I can think of.
When I execute rosnode info <simulink node>, I receive the communication error "ERROR: Communication with node[http:] failed!"
Any ideas? Thanks

回答 (2 件)

Cam Salzberger
Cam Salzberger 2019 年 8 月 14 日
Hey Mark,
I usually see this kind of issue going the other way (external nodes unable to send data to MATLAB/Simulink), but it's possible to happen the other direction as well. Try setting the ROS_IP environment variable on both sides of things (set to the IP address of the machine it is on). It needs to be set in MATLAB as well as in each terminal that runs any ROS nodes on the external machine. Then restart all the ROS nodes.
Also make sure that ROS_HOSTNAME is not set if trying ROS_IP. This helps to ensure that the IP address of the node is advertised correctly so that point-to-point communication between nodes is possible.
If that doesn't resolve the issue, here are some further steps:
  1. Can you check if you can do "rosnode ping <simulink node>" from the remote machine. If not, it may be a DNS resolution issue.
  2. See if you can publish messages from MATLAB to the remote machine, to see if it's just a simulink issue.
  3. Try a different message type (one of the std_msgs). It may be possible (though not likely) that there is some kind of message type difference that is causing ROS to drop the messages due to mismatched md5 checksums. This usually gives an error, but maybe Gazebo is silently catching it? If you need to update your built-in message types, here are the instructions.
  1 件のコメント
Mark Duntz
Mark Duntz 2019 年 8 月 15 日
Hi Cam,
Thank you for the help. I have the ROS_IPs set on both machines. The "rosnode ping <simulink node>" fails from the virtual machine. It says it is pinging with a 3sec timeout but immediately returns with a timeout message (definitely not 3sec).
I tried "rosnode('ping','/gazebo')" from MATLAB and it worked. Are you able to elaborate a little bit more on "DNS resolution issue"?
For the record, the normal terminal "ping <local host ROS_IP>" command works fine from the VM.
Thanks again for the help


Ines Vujkovac
Ines Vujkovac 2019 年 10 月 8 日
Hey Mark,
I realize this is already becoming an older post, and I hope you were able to resolve your issue, but just for anybody who is looking into it, it should just be a matter of allowing inbound rules for Matlab specifically. Even though your computer is allowing inbound connection, make sure Matlab isn't being blocked. All the needed settigns are in Advanced Settings for Firewall (I assume you are using WIndows)


Community Treasure Hunt

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

Start Hunting!

Translated by