operator_decision_state.py
Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 
00003 from flexbe_core import EventState, Logger
00004 
00005 '''
00006 Created on 12.12.2013
00007 
00008 @author: Philipp Schillinger
00009 '''
00010 
00011 class OperatorDecisionState(EventState):
00012         '''
00013         Implements a state where the operator has to manually choose an outcome.
00014         Autonomy Level of all outcomes should be set to Full, because this state is not able to choose an outcome on its own.
00015         Only exception is the suggested outcome, which will be returned immediately by default.
00016         This state can be used to create alternative execution paths by setting the suggestion to High autonomy instead of Full.
00017 
00018         -- outcomes     string[]    A list of all possible outcomes of this state.
00019         -- hint         string      Text displayed to the operator to give instructions how to decide.
00020         -- suggestion   string      The outcome which is suggested. Will be returned if the level of autonomy is high enough.
00021 
00022         '''
00023 
00024 
00025         def __init__(self, outcomes, hint=None, suggestion=None):
00026                 '''
00027                 Constructor
00028                 '''
00029                 super(OperatorDecisionState, self).__init__(outcomes=outcomes)
00030                 
00031                 self._hint = hint
00032                 self._suggestion = suggestion
00033                 self._my_outcomes = outcomes
00034                 
00035                 
00036         def execute(self, userdata):
00037                 '''
00038                 Execute this state
00039                 '''
00040                 if self._suggestion is not None and self._my_outcomes.count(self._suggestion) > 0:
00041                         return self._suggestion
00042                         
00043         
00044         def on_enter(self, userdata):
00045                 if self._hint is not None:
00046                         Logger.loghint(self._hint)


flexbe_states
Author(s): Philipp Schillinger
autogenerated on Thu Jun 6 2019 19:32:33