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

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

GabrielB gravatar image

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

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:

ROS_ETC_DIR=/opt/ros/melodic/etc/ros
ROS_ROOT=/opt/ros/melodic/share/ros
ROS_MASTER_URI=http://localhost:11311
ROS_VERSION=1
ROS_PYTHON_VERSION=2
ROS_PACKAGE_PATH=/opt/ros/melodic/share
ROSLISP_PACKAGE_DIRECTORIES=
ROS_DISTRO=melodic

roscore:

... 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

SUMMARY
========

PARAMETERS
 * /rosdistro: melodic
 * /rosversion: 1.14.3

NODES

auto-starting new master
process[master]: started with pid [200]
ROS_MASTER_URI=http://DESKTOP-AM7K8V9:11311/

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

Comments

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 imagegvdhoorn ( 2019-10-12 08:01:09 -0500 )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 imagelmathieu ( 2019-10-12 08:40:35 -0500 )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 imagegvdhoorn ( 2019-10-12 09:21:30 -0500 )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 imageGabrielB ( 2019-10-12 09:33:06 -0500 )edit