2 from flexbe_core
import EventState, Logger
7 Implements a state that checks if the given condition is true based on multiple userdata inputs 8 provided as a list to the calculation function and returns the corresponding outcome. 9 This state can be used if the further control flow of the behavior depends on a simple condition. 11 -- predicate function The condition whose truth value will be evaluated. 12 It could be a private function (self.foo) manually defined in a behavior's source code 13 or a lambda function (e.g., lambda x: x[0]^2 + x[1]^2). 14 -- input_keys string[] List of available input keys. 16 ># input_keys object[] Input(s) to the calculation function as a list of userdata. 17 The individual inputs can be accessed as list elements (see lambda expression example). 19 <= true Returned if the condition evaluates to True 20 <= false Returned if the condition evaluates to False 25 super(FlexibleCheckConditionState, self).
__init__(outcomes=[
'true',
'false'],
26 input_keys=input_keys)
36 self.
_outcome =
"true" if self.
_predicate([userdata[key]
for key
in self._input_keys])
else 'false' 37 except Exception
as e:
38 Logger.logwarn(
'Failed to execute condition function!\n%s' % str(e))
40 Logger.logwarn(
'Passed no predicate!')
def __init__(self, predicate, input_keys)
def execute(self, userdata)
def on_enter(self, userdata)