ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

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


 * /rosdistro: kinetic
 * /rosversion: 1.12.12


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

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:


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



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 image gvdhoorn  ( 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 image mgruhler  ( 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 image gvdhoorn  ( 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 image TheMilkman  ( 2018-01-16 19:09:58 -0600 )edit

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 image ufr3c_tjc  ( 2018-01-16 22:05:42 -0600 )edit

... 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 image ufr3c_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 image TheMilkman  ( 2018-01-16 22:19:22 -0600 )edit

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 image ufr3c_tjc  ( 2018-01-16 22:25:41 -0600 )edit

1 Answer

Sort by » oldest newest most voted

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

replace " to ' works for me

edit flag offensive delete link more


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

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

Question Tools



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

Seen: 43,647 times

Last updated: Jan 16 '18