Ask Your Question
0

rostopic pub/echo not working on single pc system [closed]

asked 2018-01-15 23:07:04 -0600

TheMilkman gravatar image

updated 2018-01-16 19:07:06 -0600

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 ...
(more)
edit retag flag offensive reopen merge delete

Closed for the following reason question is not relevant or outdated by tfoote
close date 2019-03-05 14:58:37.272466

Comments

2

Could you add the output of env | grep -i ros | sort, ip addr show and route -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.

gvdhoorn gravatar imagegvdhoorn ( 2018-01-16 02:37:02 -0600 )edit

Also, try to add a -r 10 after the rostopic pub ... command. This publishes the message with 10 Hz. It might be that the one-time message is lost between publishing and subscribing with rostopic echo.

mgruhler gravatar imagemgruhler ( 2018-01-16 04:08:55 -0600 )edit

@mig: good suggestion. I assumed that OP had started rosptopic echo /hello before the rostopic pub .., but it could definitely be the case that the message is lost because the subscription is not yet there.

gvdhoorn gravatar imagegvdhoorn ( 2018-01-16 04:14:25 -0600 )edit

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?

TheMilkman gravatar imageTheMilkman ( 2018-01-16 19:09:58 -0600 )edit
1

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.

ufr3c_tjc gravatar imageufr3c_tjc ( 2018-01-16 22:05:42 -0600 )edit
1

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

ufr3c_tjc gravatar imageufr3c_tjc ( 2018-01-16 22:07:38 -0600 )edit

Thanks @ufr3c_tjc! That got the rostopic pub/echo working. Although rostopic pub /hello std_msgs/String hello outputs 7 iterations of invalid 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?

TheMilkman gravatar imageTheMilkman ( 2018-01-16 22:19:22 -0600 )edit
1

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.

ufr3c_tjc gravatar imageufr3c_tjc ( 2018-01-16 22:25:41 -0600 )edit

1 Answer

Sort by » oldest newest most voted
0

answered 2019-01-03 21:29:09 -0600

replace " to ' works for me

edit flag offensive delete link more

Comments

Can you clarify what you write here? What is "to"?

gvdhoorn gravatar imagegvdhoorn ( 2019-01-04 02:10:24 -0600 )edit

Question Tools

2 followers

Stats

Asked: 2018-01-15 23:07:04 -0600

Seen: 588 times

Last updated: Jan 16 '18