MATLAB Answers

External ROS node can't communicate with simulink

32 views (last 30 days)
Mark Duntz
Mark Duntz on 13 Aug 2019
Commented: Ammar Nafie on 27 Aug 2021 at 11:24
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

Answers (2)

Cam Salzberger
Cam Salzberger on 14 Aug 2019
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.

Sign in to comment.

Ines Vujkovac
Ines Vujkovac on 8 Oct 2019
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!