ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | Q&A
Ask Your Question

subscriber cannot receive topic on rospy

asked 2017-01-27 01:16:46 -0600

graziegrazie gravatar image

I made a node which has 1 action client, 5 subscribers and 1 publisher. I wrote its pseudo code is following. When I tried a certain sequence, one of the subscribers sub1 did not call its callback cb1 every time. If you know the reason why the subscriber did not call cb1, could you tell me how to fix?

In the sequence, topic1 was published 2 times, when topic1 had different parameters. When topic1 was published with parameter B before not be published with parameter C, sub1 received topic1. At this time, "[cb1]called" was displayed on a terminal. however, after that, when topic1 with parameter C was published, sub1 did not receive the topic and "[cb1]called" was not displayed. I confirmed the topic1 subscribed was published with using command-line "rostopic echo". The topic was published by rosbridge_websocket node. After sub1 missed topic1, when I tried command-line "rostopic pub /topic1 ...", sub1 received topic1 and cb1 was called. I do not why sub1 received topic1 in the case...

[ pseudo code ]

   def cb1(p_msg):


if name == 'main':
   rospy.init_node("node_name", anonymous=True)
   action_client = actionlib.SimpleActionClient('move_base', MoveBaseAction)

   sub1 = rospy.Subscriber("topic1", type1, cb1)
   sub2 = rospy.Subscriber("topic2", type2, cb2)
   sub3 = rospy.Subscriber("topic3", type3, cb3)
   sub4 = rospy.Subscriber("topic4", type4, cb4)
   sub5 = rospy.Subscriber("topic5", type5, cb5)

   cmd_vel_pub = rospy.Publisher("cmd_vel_mux/input/navi", Twist, queue_size=2)


Following figure shows whta I said.

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted

answered 2017-01-30 00:22:15 -0600

graziegrazie gravatar image

I found the solution and added 2 lines in pseudo code which includes add !

The reason why callback was not called was that subprocess("rosrun package node") didn't return. So the node couldn't receive a message and start the callback function.

On the other hand, the reason why the node could receive the topic published by command "rostopic pub" might be due to their priorities. That is, the priority of topic published by command-line may be higher than published by a node. This is my opinion and I don't check whether it is correct or not.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools



Asked: 2017-01-27 01:16:46 -0600

Seen: 492 times

Last updated: Jan 30 '17