MATLAB Answers

Communicate with ROS in WSL2

33 views (last 30 days)
Steven Crews
Steven Crews on 11 Nov 2020
Commented: Steven Crews on 18 Nov 2020
I am using MATLAB 2020a on Windows 10, v2004 with WSL2 Ubuntu 20.04.
I am having trouble communicating between Ubuntu using WSL and Matlab on Windows. I build ROS nodes on both Ubuntu and Matlab.
TRYING TO GO FROM WSL2 UBUNTU TO WINDOWS:
I ran the basic publisher (talker.py) in Ubuntu. Within WSL2 Ubuntu, I have no issues seeing /talker.
In Matlab, I run
rosinit % run once only
rostopic list
% OUTPUT:
% /chatter
% /rosout
% /rosout_agg
python_talker = rossubscriber('/chatter','std_msgs/String');
python_talker.LatestMessage.Data
but the /chatter message is empty.
TRYING TO GO FROM WINDOWS TO WSL2 UBUNTU:
Similarly, if I start in Matlab with
matlab_talker = rospublisher('/matlab_chatter','std_msgs/Float64MultiArray');
matlab_message = rosmessage( matlab_talker );
tic
while toc < 10
matlab_message.Data = [toc , 1 , 2 , 3 , 4 ] ;
pause(0.1)
send( matlab_talker , matlab_message )
end
I can see that the /matlab_chatter node exists in Ubuntu, but it's also empty:
$ rostopic list
% OUTPUT:
% /chatter
% /matlab_chatter
% /rosout
% /rosout_agg
$ rostopic echo /matlab_chatter
% no output
This all works if I'm running pure Ubuntu. Any ideas on troubleshooting WSL2 inter-connectivity?
  2 Comments
Steven Crews
Steven Crews on 18 Nov 2020
Thanks, Cam. I'm looking into these options. I hope it is an easy setting somewhere.

Sign in to comment.

Answers (0)

Tags

Products

Community Treasure Hunt

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

Start Hunting!