Why does rospy::wait_for_message get stucked even though messages are being published?
I am using this method in my python script
rospy.wait_for_message("/my_topic", Bool, timeout=None)
The /my_topic
messages are being published, I can see them when running rostopic echo /my_topic
. But the script stays at the rospy.wait_for_message
line as if it couldn't detect any messages. What could be the cause?
EDIT
$ rostopic echo -n1 /my_topic
data: True
---
wait_for_message is explicitly meant to get just one message on the topic. Does it detect at least one message? If you need to continuously receive the data on /my_topic, you need a Subscriber.
@curi_ROS no, it doesn't detect any message. Not even one.
What is the output of
rostopic echo -n1 /my_topic
?@gvdhoorn It outputs the message.
I actually wanted to make sure that
/my_topic
is of typeBool
. Because if it isn't, things won't work. I also wanted to make sure that/my_topic
actually exists, and is not namespaced. Without you showing us that, we cannot help you.@gvdhoorn ok, I didn't understand what you wanted me to do. The question is now edited with the output of this command.
Then I guess we'll need to see some of your code. Specifically how you initialise everything up to and including where you use
wait_for_message(..)
.It doesn't necessarily need to be your exact code, as long as it reproduces the problem you are experiencing.