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

Revision history [back]

click to hide/show revision 1
initial version

If you look at the source for the wait_for_message function, you'll see that you can specifiy a timeout and if that timeout is exceeded an exception will be raised (I removed the parts that aren't necessary for the question)

def wait_for_message(topic, topic_type, timeout=None):
    """
    ...

    @param timeout: timeout time in seconds
    @type  timeout: double
    ...
    @raise ROSException: if specified timeout is exceeded
    """

So, just call the function like this

rospy.wait_for_message(my_topic, MyMessage, my_timeout)

and if my_timeout is exceeded a ROSException will be raised.

If Take a look at the documentation. Or, if you look at the source for the wait_for_message function, you'll see that you can specifiy a timeout and if that timeout is exceeded an exception will be raised (I removed the parts that aren't necessary for the question)

def wait_for_message(topic, topic_type, timeout=None):
    """
    ...

    @param timeout: timeout time in seconds
    @type  timeout: double
    ...
    @raise ROSException: if specified timeout is exceeded
    """

So, just call the function like this

rospy.wait_for_message(my_topic, MyMessage, my_timeout)

and if my_timeout is exceeded a ROSException will be raised.

Take a look at the documentation. Or, if you look at the source for the wait_for_message function, you'll see that you can specifiy a timeout and if timeout. If that timeout is exceeded then an exception will be raised (I removed the parts that aren't necessary for the question)

def wait_for_message(topic, topic_type, timeout=None):
    """
    ...

    @param timeout: timeout time in seconds
    @type  timeout: double
    ...
    @raise ROSException: if specified timeout is exceeded
    """

So, just call the function like this

rospy.wait_for_message(my_topic, MyMessage, my_timeout)

and if my_timeout is exceeded a ROSException will be raised.