wait_state.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 import rospy
3 from flexbe_core import EventState
4 
5 
6 class WaitState(EventState):
7  '''
8  Implements a state that can be used to wait on timed process.
9 
10  -- wait_time float Amount of time to wait in seconds.
11 
12  <= done Indicates that the wait time has elapsed.
13  '''
14 
15  def __init__(self, wait_time):
16  super(WaitState, self).__init__(outcomes=['done'])
17  self._wait = wait_time
18 
19  def execute(self, userdata):
20  elapsed = rospy.get_rostime() - self._start_time
21  if elapsed.to_sec() > self._wait:
22  return 'done'
23 
24  def on_enter(self, userdata):
25  '''Upon entering the state, save the current time and start waiting.'''
26  self._start_time = rospy.get_rostime()
def on_enter(self, userdata)
Definition: wait_state.py:24
def execute(self, userdata)
Definition: wait_state.py:19
def __init__(self, wait_time)
Definition: wait_state.py:15


flexbe_states
Author(s): Philipp Schillinger
autogenerated on Sun Dec 13 2020 04:01:46