tutorial rostopic: rostopic pub only working sometimes (Win10, WSL)

asked 2019-10-12 07:51:46 -0600

GabrielB gravatar image

updated 2019-10-12 08:01:26 -0600

gvdhoorn gravatar image

Hello everyone! I'm a new user, learning ROS for the first time with the the Ros wiki tutorials. I'm having an issue with the ROS topics tutorial, using rostopic pub (chapter 4.)

rostopic pub -1 /turtle1/cmd_vel geometry_msgs/Twist -- '[2.0, 0.0, 0.0]' '[0.0, 0.0, 1.8]'

I've been executing this rostopic pub command several times, but it only works properly sometimes. Every time I run the command I get the message "publishing and latching message for 3.0 seconds". With rostopic echo turtle1/cmd_vel I checked that the messages are being published to the topic correctly. The issue is that most of the times the /turtlesim node doesn't seem to receive the instructions because the turtle is not moving.

rostopic pub /turtle1/cmd_vel geometry_msgs/Twist -r 1 -- '[2.0, 0.0, 0.0]' '[0.0, 0.0, -1.8]'

This other command is also not working.

Does anyone know or suspect what may be the issue?

OS: Ubuntu 18.04.2 LTS (bionic) with WSL

ROS environment variables:



... logging to /home/balcellsg/.ros/log/49ae9a96-ece5-11e9-bce7-d481d7e3d5de/roslaunch-DESKTOP-AM7K8V9-190.log
Checking log directory for disk usage. This may take awhile.
Press Ctrl-C to interrupt
Done checking log file disk usage. Usage is <1GB.

started roslaunch server http://DESKTOP-AM7K8V9:53442/
ros_comm version 1.14.3


 * /rosdistro: melodic
 * /rosversion: 1.14.3


auto-starting new master
process[master]: started with pid [200]

setting /run_id to 49ae9a96-ece5-11e9-bce7-d481d7e3d5de
process[rosout-1]: started with pid [211]
started core service [/rosout]
edit retag flag offensive close merge delete


Ubuntu 18.04.2 LTS (bionic) with WSL

this is a likely cause of your problems.

I haven't looked at ROSonWSL lately, but it might still be having network problems. Connections / msgs not getting through occasionally would be one of the symptoms.

If you make rostopic pub republish the same message periodically (ie: use -r) does it start working?

gvdhoorn gravatar image gvdhoorn  ( 2019-10-12 08:01:09 -0600 )edit

I use Kinetic on WSL on a regular basis, I just tried turtlesim too and it work perfectly for me.

It won't resolve your problem, but maybe you can try Kinetic and Ubuntu 16.04 on WSL, if it's just for learning ROS. Also I use Vcxsrv with NativeOpengl desactivated for GUI, if it's help in any way.

lmathieu gravatar image lmathieu  ( 2019-10-12 08:40:35 -0600 )edit

"WSL" is not a single versioned piece of software. Whether or not it works depends on which exact version you have, which version of Ubuntu you have installed into it and how you have your machine configured (ie: firewalls and network).

I agree that it can work, but I would not make such general statements about a rather brittle setup.

gvdhoorn gravatar image gvdhoorn  ( 2019-10-12 09:21:30 -0600 )edit

Thank you both for your answers.

@mathieu: I am completely inexperienced with Ubuntu. That's why I chose to install WSL via Windows Store. I am not confident enough to start installing different versions on top of each other. For the moment I am working with GUI MobaXterm, but I'll look into the one you've recommended. However, I don't think it's the GUI problem because running the rqt_plot node, the plot represents the same movement (or no movement) that I am seeing on the display.

@gvdhoorn: With the periodic rostopic pub it's happening the same thing: sometimes it works (the turtle moves, and doesn't stop moving) and sometimes running the command doesn't work at all (the turtle doesn't start moving, no matter how long I wait). Did you manage to solve the network problems?

GabrielB gravatar image GabrielB  ( 2019-10-12 09:33:06 -0600 )edit