rostopic pub/echo not working on single pc system [closed]
I'm working my way through the tutorials in the wiki one by one and I and into some issues in the 'Examining the Simple Publisher and Subscriber' tutorial (link text). All my code is identical to that of the code within.
The Issue was that the listener wasnt picking up what the publisher was publishing.
Trying to troubleshoot I got to the point where I was simply trying to publish to a topic then echo it in the terminal, similar to this tutorial, but I couldn't relpicate these results. ie echo something published to a topic. In this case aftering trying rostopic pub /hello std_msgs/String “Hello Robot"
, rostopic list
would display /hello /rosout /rosout_agg
but rostopic echo /hello
yields nothing.
Any help would be greatly appreciated, is there anything else that would help answer my question?
Currently using kinetic 1.12.12 on a single machine running Ubuntu.
EDIT - Extra Info:
The output of roscore
is:
... logging to /home/nvidia/.ros/log/55fbfc34-fb20-11e7-91c6-00044b8d27bd/roslaunch-tegratx2-ubuntu-3563.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://localhost:34786/
ros_comm version 1.12.12
SUMMARY
========
PARAMETERS
* /rosdistro: kinetic
* /rosversion: 1.12.12
NODES
auto-starting new master
process[master]: started with pid [3574]
ROS_MASTER_URI=http://localhost:11311/
setting /run_id to 55fbfc34-fb20-11e7-91c6-00044b8d27bd
process[rosout-1]: started with pid [3587]
started core service [/rosout]
The output of env | grep -i ros | sort
is:
CMAKE_PREFIX_PATH=/home/nvidia/TestCatkinWS/devel:/opt/ros/kinetic
LD_LIBRARY_PATH=/home/nvidia/TestCatkinWS/devel/lib:/opt/ros/kinetic/lib:/usr/local/lib:/usr/local/lib:/usr/local/cuda-8.0/lib64
PATH=/opt/ros/kinetic/bin:/usr/local/cuda-8.0/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin
PKG_CONFIG_PATH=/home/nvidia/TestCatkinWS/devel/lib/pkgconfig:/opt/ros/kinetic/lib/pkgconfig
PYTHONPATH=/home/nvidia/TestCatkinWS/devel/lib/python2.7/dist-packages:/opt/ros/kinetic/lib/python2.7/dist-packages
ROS_DISTRO=kinetic
ROS_ETC_DIR=/opt/ros/kinetic/etc/ros
ROS_IP=10.222.146.184
ROSLISP_PACKAGE_DIRECTORIES=/home/nvidia/TestCatkinWS/devel/share/common-lisp
ROS_MASTER_URI=http://localhost:11311
ROS_PACKAGE_PATH=/home/nvidia/TestCatkinWS/src:/opt/ros/kinetic/share
ROS_ROOT=/opt/ros/kinetic/share/ros
The output of ip addr show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: dummy0: <BROADCAST,NOARP> mtu 1500 qdisc noop state DOWN group default qlen 1000
link/ether d2:02:37:ef:73:7d brd ff:ff:ff:ff:ff:ff
3: eth0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc pfifo_fast state DOWN group default qlen 1000
link/ether 00:04:4b:8d:27:bf brd ff:ff:ff:ff:ff:ff
4: tunl0@NONE: <NOARP> mtu 1480 qdisc noop state DOWN group default qlen 1
link ...
Could you add the output of
env | grep -i ros | sort
,ip addr show
androute -n
to your question? Feel free to redact your IP addresses, but be consistent.Edit: perhaps also add the output of
roscore
.Make sure to use the Preformatted Text button for everything.
Also, try to add a
-r 10
after therostopic pub ...
command. This publishes the message with 10 Hz. It might be that the one-time message is lost between publishing and subscribing withrostopic echo
.@mig: good suggestion. I assumed that OP had started
rosptopic echo /hello
before therostopic pub ..
, but it could definitely be the case that the message is lost because the subscription is not yet there.Thanks @gvdhoorn and @mig for your quick replies! I've added the extra info in the original question.
@mig I tried both ways to be honest to no avail. I thought the latching of the rostopic pub would mean the message would stay there until its picked up by a subscriber anyway?
Try removing the ROS_IP environment variable, as you are doing all of this locally and it shouldn't be needed. It is different to the ROS_MASTER_URI which may be causing issues.
... and in fact it doesn't match any of your interface IP's so is probably the cause. I'm not sure if setting it to localhost will work, but try remove it completely and restart your terminals and retry pub/sub.
Thanks @ufr3c_tjc! That got the
rostopic pub/echo
working. Althoughrostopic pub /hello std_msgs/String hello
outputs 7 iterations ofinvalid ROS_IP (an empty string)
to the terminal. I've probably not removed it correctly?Also, this didn't fix the talker/listener tutorial, any other ideas?
Where are you setting the ROS_IP variable? Is it in your
~/.bashrc
file? If so, just take that line out. You want to remove the variable, not set it to empty.