I have now also tested using the Car IP instead of the hostname for the ROS_MASTER_URI, it didn't change anything. Also I pinged the matlab global node from the rosnode list, every ping returned.
Why doesn't Simulink receive data from a remote ROS Master eventhough Matlab does?
5 views (last 30 days)
Show older comments
Hello,
I am currently setting up a remote ROS setup for autonomous driving. So far everything was implemented in ROS but for the controllers and visuals I decided to use Simulink and Matlab.
The connection is via ethernet, the car and the PC running Matlab both use Ubuntu and have the ROS_IP and ROS_MASTER_URI configurated in the .bashrc file as it was often pointed out. I always only used the ROS_IP and ROS_MASTER_URI, never Hostname. The edited lines look as follows:
export ROS_MASTER_URI=http://Car_Hostname:11311
export ROS_IP=Matlabpc_IP
source /opt/ros/noetic/setup.bash
The launch file, which also creates the ROS Master, is then started via ssh on the car. A Matlab file then connects to the network via:
setenv('ROS_MASTER_URI','http://Car_Hostname:11311');
setenv('ROS_IP','Matlabpc_IP');
rosinit
The names are substitutes for the IP and the HOSTNAME used. I used the Hostname in the ROS_MASTER_URI because it didn't work when I put in the IP address of the car.
After launching the Matlab file, I successfully can see all the Rostopics and when i echo them, the data is what it should be. I can also use the data for further calculations and write new topics. The only problem I have is that it just doesn't work in Simulink. I set up the hardware configurations, put in the board specifications and tested if a connection to the ROS network is there. Everytime I tried the test function it said that the connection was successful to the Master, pings were successfull and catkin_ws was found. Yet whenever I try to use the ROS tools to either read or write a topic, no data goes out of comes in. The topics generated in Simulink are listed among the topics and rostopic info also fits but there is just no data.
I am using Matlab R2023a, ROS noetic, the Matlab PC is Ubuntu 20.04 and the car runs on Ubuntu 18.04 on a Jetson. The problems only occurred after I switched to the remote setup, when I launched everything from the Matlab PC it worked perfectly fine.
The data I'm trying to get are the raw image of the camera and the scan of a LIDAR. If there is anything else needed I am happy to provide it.
Answers (1)
Vidip Jain
on 5 Sep 2023
I understand that you've successfully established communication between your MATLAB environment and the ROS network. Since the issue you're facing is specific to Simulink, here are some steps to troubleshoot and resolve the problem:
- ROS Master and Nodes: On your car, confirm that the ROS Master is running correctly when launched from your launch file. Check if the ROS nodes running on the car (publishing camera and LIDAR data) are functioning properly. You can use tools like “rostopic list” and “rostopic info” to verify their status.
- Simulink Configuration: Ensure that Simulink's ROS hardware configuration is set up correctly. Verify that the ROS Master URI and Node Hostname are correctly configured in Simulink. Double-check that the Simulink blocks for subscribing to and publishing ROS topics are configured properly. Make sure the topic names match those in your ROS environment.
- Remote vs. Local Testing: As you mentioned that it worked fine when running everything from the MATLAB PC, this suggests that the issue might be related to the remote setup. Try to isolate the problem by running Simulink and MATLAB on the same machine as ROS (e.g., on the car) to see if it works locally. This can help determine if the problem is specific to the remote setup.
By systematically checking and addressing these aspects, you should be able to identify the root cause of the problem and establish data communication between Simulink and your ROS system. If you continue to experience issues, providing specific error messages or log details can help in diagnosing the problem further.
0 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!