Go to the documentation of this file.00001
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
00016 if len(args) > 0 and type(args[0]) is list:
00017
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