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

problem with roscore subscription and publishing

asked 2012-07-24 03:32:26 -0600

vivek gravatar image

updated 2012-07-24 06:35:54 -0600


Im having a small problem with my roscore. What happens is while running my code, after a while i publish flags for another program and the flags are never subscribed. Basically this is what happens. I have 2 nodes A and B. A subscribes to a topic "example" and B publishes data into in at around 20Hz. If i start B and then start A its able to subscribe. But if i start A and then start B nothing happens. Bascally what ive found is that if you subscribe to something and then publish, the subscriber will not recieve the data. But if i were publishing and then subscribe, then ill get the data. I know that this is not the problem because ive verified it using rostopic echo and rostopic pub. I echo and publish data, nothing is recieved but if i publish and echo i see the data on the terminal. BTW restarting roscore resolves this issue. The worst part of this is that it also happens when i run the code. Can someone help me out. Im using ros electric on ubuntu 11.10

After the error starts there are 2 cases (only roscore running so far, closed the rest)

Case 1

a. Open a new terminal and type "rostopic pub /stat geometry_msgs/Point -r 20 -- 0 1 0

b. Open another terminal and type "rostopic echo /stat"

In this case i will get the desired output during echo

Case 2

a. Open another terminal and type "rostopic echo /stat"

b. Open a new terminal and type "rostopic pub /stat geometry_msgs/Point -r 20 -- 0 1 0

In this case i do not get any output on the echo

Please tell me if i have made my problem clear

edit retag flag offensive close merge delete


Please edit your question, adding the exact sequence of rostopic commands that demonstrates this failure.

joq gravatar image joq  ( 2012-07-24 05:58:44 -0600 )edit

1 Answer

Sort by » oldest newest most voted

answered 2012-07-24 04:44:42 -0600

joq gravatar image

updated 2012-07-24 09:44:17 -0600

You are probably restarting roscore at some point without realizing it. Note that roslaunch will normally start a new roscore if there is not already one running.

Try starting roscore first in a separate window. That will probably eliminate these problems.

EDIT: Both of those test cases work for me on Oneiric with Fuerte.

EDIT2: If your system is failing randomly, you might try running memory diagnostics on your computer.

edit flag offensive delete link more


i am running roscore in a separate terminal. Plus if the roscore is restarted then the rostopic echo's shouldn't work any way. But it works only if i start the publisher 1st and then echo. It wont if i echo and then publish.

vivek gravatar image vivek  ( 2012-07-24 05:48:53 -0600 )edit

If you restart a roscore established connections aren't necessarily terminated!

dornhege gravatar image dornhege  ( 2012-07-24 06:47:00 -0600 )edit

@jog theese conditions work for me too. but the problem happens suddenly and randomly. Sometimes after 2 hours of starting roscore , somethimes in 10 mins. Cant pinpoint when this happens as its very very random.

vivek gravatar image vivek  ( 2012-07-24 09:33:19 -0600 )edit

@dornhege when i restart roscore i have to restart all the programs to get them working again. The problem comes when the error happens while running the program and some flags arent recieved by the subscriber and i have to restart the program

vivek gravatar image vivek  ( 2012-07-24 09:36:12 -0600 )edit

So, the programs stop working when you restart roscore or you restart roscore because the programs stopped working? Also: Do Case 1 and 2 work for you normally, but just after 2 hours sometimes fail?

dornhege gravatar image dornhege  ( 2012-07-24 23:54:11 -0600 )edit

I restart roscore because the programs stop working. The 2 cases work normally when the error doesn't happen. As soon as it happens case 2 wont work

vivek gravatar image vivek  ( 2012-07-30 11:47:40 -0600 )edit

@joq i dont think its a memory issue as nothing else stops. all other applications running in the background is fine. plus my system doesn't fail. only roscore is the problem.

vivek gravatar image vivek  ( 2012-07-30 11:50:49 -0600 )edit

Why do you think roscore is the problem? Maybe, your nodes are hanging for some reason. Nodes don't normally depend on roscore for continuous operation.

joq gravatar image joq  ( 2012-07-31 10:59:01 -0600 )edit

Question Tools


Asked: 2012-07-24 03:32:26 -0600

Seen: 2,097 times

Last updated: Jul 24 '12