Main Page
Namespaces
Classes
Files
File List
src
flexbe_core
core
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
6
class
LoopbackState
(
LockableState
):
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
26
self.
execute
= self.
_loopback_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.core.lockable_state
Definition:
lockable_state.py:1
flexbe_core.core.lockable_state.LockableState.execute
execute
Definition:
lockable_state.py:26
flexbe_core.core.loopback_state.LoopbackState._loopback_name
string _loopback_name
Definition:
loopback_state.py:12
flexbe_core.core.loopback_state.LoopbackState._rate
_rate
Definition:
loopback_state.py:14
flexbe_core.core.lockable_state.LockableState
Definition:
lockable_state.py:11
flexbe_core.core.loopback_state.LoopbackState.__init__
def __init__(self, args, kwargs)
Definition:
loopback_state.py:13
flexbe_core.core.loopback_state.LoopbackState._loopback_execute
def _loopback_execute(self, args, kwargs)
Definition:
loopback_state.py:28
flexbe_core.core.loopback_state.LoopbackState
Definition:
loopback_state.py:6
flexbe_core.core.lockable_state.LockableState.__execute
__execute
Definition:
lockable_state.py:25
flexbe_core
Author(s): Philipp Schillinger
autogenerated on Wed Jun 5 2019 21:51:59