loopback_state.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 import rospy
3 
4 from flexbe_core.core.lockable_state import LockableState
5 
7  """
8  A state that can refer back to itself.
9  It periodically transitions to itself while no other outcome is fulfilled.
10  """
11 
12  _loopback_name = 'loopback'
13  def __init__(self, *args, **kwargs):
14  self._rate = rospy.Rate(10)
15  # add loopback outcome
16  if len(args) > 0 and type(args[0]) is list:
17  # need this ugly check for list type, because first argument in CBState is the callback
18  args[0].append(self._loopback_name)
19  else:
20  outcomes = kwargs.get('outcomes', [])
21  outcomes.append(self._loopback_name)
22  kwargs['outcomes'] = outcomes
23 
24  super(LoopbackState, self).__init__(*args, **kwargs)
25  self.__execute = self.execute
27 
28  def _loopback_execute(self, *args, **kwargs):
29  result = self.__execute(*args, **kwargs)
30 
31  if result is None or result == 'None':
32  result = self._loopback_name
33  return result


flexbe_core
Author(s): Philipp Schillinger
autogenerated on Wed Jun 5 2019 21:51:59