loopback_state.py
Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 import rospy
00003 
00004 from flexbe_core.core.lockable_state import LockableState
00005 
00006 class LoopbackState(LockableState):
00007     """
00008     A state that can refer back to itself.
00009     It periodically transitions to itself while no other outcome is fulfilled.
00010     """
00011     
00012     _loopback_name = 'loopback'
00013     def __init__(self, *args, **kwargs):
00014         self._rate = rospy.Rate(10)
00015         # add loopback outcome
00016         if len(args) > 0  and type(args[0]) is list:
00017             # need this ugly check for list type, because first argument in CBState is the callback
00018             args[0].append(self._loopback_name)
00019         else:
00020             outcomes = kwargs.get('outcomes', [])
00021             outcomes.append(self._loopback_name)
00022             kwargs['outcomes'] = outcomes
00023             
00024         super(LoopbackState, self).__init__(*args, **kwargs)
00025         self.__execute = self.execute
00026         self.execute = self._loopback_execute
00027 
00028     def _loopback_execute(self, *args, **kwargs):
00029         result = self.__execute(*args, **kwargs)
00030             
00031         if result is None or result == 'None':
00032             result = self._loopback_name
00033         return result


flexbe_core
Author(s): Philipp Schillinger
autogenerated on Thu Jun 6 2019 19:32:27