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

rospy.wait_for_message is unable to subscribe to a message

asked 2019-01-17 03:10:51 -0600

updated 2019-01-17 08:42:53 -0600

rospy.wait_for_message can receive one message from topic. It will create a new subscription to the topic, receive one message, then unsubscribe. But when I try to use it, the function can't work at all. For example,

roscore &
rostopic pub -r 1 /data std_msgs/Float32 2.0

the use this function to subscribe once:

import rospy
from std_msgs.msg import Float32
rospy.wait_for_message('/data', Float32)

It will be stuck here and there is no response at all. But if we subscribe directly

rostopic echo /data

It can work. What's the matter with this function? And I try to test it on different computers and ROS version, the result is the same.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2019-01-17 08:44:18 -0600

just add



edit flag offensive delete link more


jayess gravatar image jayess  ( 2019-01-17 16:44:28 -0600 )edit

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: 2019-01-17 03:10:51 -0600

Seen: 878 times

Last updated: Jan 17 '19