Clear Filters
Clear Filters

Cannot echo Topics from Simulink in ROS on WSL2

22 views (last 30 days)
I'm troubling in connecting Simulink and Unreal Engine through ROS on WSL2.
I want to send some messages from Simulink to UE (ROS Integration) using ROS Topics, but the topics from Simulink cannot be subscribed. (Actually the topic itself is subscribed, but no message is coming.)
My environment is as follows:
  • MATLAB R2024a + ROS Toolbox
  • Unreal Engine 5.1.1 (+ ROS Integration)
  • Ubuntu 20.04 on WSL2
  • ROS Noetic
I have confirmed the ROS communications below:
  • Simulink to the same Simulink: succes
  • Simulink to the other Simulink on the same computer: partly success (✔A→B, while ✘B→A. I suspected that the same port cannot be used for both publishing and subscribing, but alternating their roles did not work.)
  • Simulink to ROS: failed (The topics can be found by rostopic list, but I couldn't rostopic echo.)
  • Simulink to UE: failed
  • UE to ROS: success (only String messages)
  • UE to Simulink: success (only String messages)
Regarding to the rostopic list, the rosnode info /SimulinkSystem_xxxxx (the node created by Simulink) response says that the connection to the node is failed.
I searched for the similar issues on internet and it may be caused by that the hostname cannot be resolved by ROS.
I have tried to set the environment variables so that they are not "localhost" nor "127.0.0.1", but it did not work. (When doing it, I could not connect to the ROS master.)
Could anyone figure out what is the true problem(s), and how to solve it?
Thank you

Accepted Answer

NAKANISHI
NAKANISHI on 14 Jun 2024
I could solve it myself:
I could publish topics from SImulink and subscribe in ROS/Unreal by:
1) Check the IP address of the Windows seen from Ubuntu by "ip route show | grep -i default | awk '{ print $3}'"
2) Set the IP address as the Node Host IP address of the ROS network setting in SImulink.
However, it turned to be impossible to subscribe topics from ROS after i did solve the problem above. The topics are published to ROS and i can echo them in Ubuntu terminal, but the ROS Subscribe block in Simulink receives nothing.
I have no idea what causes this issue. The only change from the case i could subscribe topics in Simulink is the Node Hos IP Address, and it did not work even when i return it to be "localhost".

More Answers (1)

Nishan Nekoo
Nishan Nekoo on 12 Jun 2024
Hi Nakanishi, MATLAB offers a tight integration with the Unreal Engine through Simulink 3D Animation that offers deterministic simulation and shared memory for data exchange. In particular, you can use Simulation 3D Message Set and Simulation 3D Message Get blocks to exchange custom data between Simulink and Unreal Engine.
Is there any reason you need a ROS interface specifically? Are there other nodes besides Simulink and Unreal Engine?
Nishan
  1 Comment
NAKANISHI
NAKANISHI on 12 Jun 2024
Hi, Nishan,
Thank you for your answer.
Of course I know those blocks, and I'm using Simulation 3D Vehicle from Automated Driving Toolbox.
But, the reasons I'm going to use ROS are:
  • I do not have Vehilce Dynamics Blockset nor Aerospace Blockset that include the Simulation 3D Message Get/Set.
  • I want to exchange data that are not just numbers, such as texts, waypoints, pointclouds, etc, which seem not to be supported by Simulation 3D Message Get/Set.
Of course if I cannot resolve the problem, I will try those blocks.

Sign in to comment.

Products


Release

R2024a

Community Treasure Hunt

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

Start Hunting!