7 from flexbe_core
import EventState, Logger
8 from flexbe_msgs.msg
import BehaviorInputAction, BehaviorInputGoal, BehaviorInputResult
14 @author: Philipp Schillinger 19 Implements a state where the state machine needs an input from the operator. 20 Requests of different types, such as requesting a waypoint, a template, or a pose, can be specified. 22 -- request uint8 One of the class constants to specify the type of request. 23 -- message string Message displayed to the operator to let him know what to do. 25 #> data object The data provided by the operator. The exact type depends on the request. 27 <= received Returned as soon as valid data is available. 28 <= aborted The operator declined to provide the requested data. 29 <= no_connection No request could be sent to the operator. 30 <= data_error Data has been received, but could not be deserialized successfully. 34 POINT_LOCATION = BehaviorInputGoal.POINT_LOCATION
35 SELECTED_OBJECT_ID = BehaviorInputGoal.SELECTED_OBJECT_ID
36 WAYPOINT_GOAL_POSE = BehaviorInputGoal.WAYPOINT_GOAL_POSE
37 GHOST_JOINT_STATES = BehaviorInputGoal.GHOST_JOINT_STATES
38 FOOTSTEP_PLAN_HEADER = BehaviorInputGoal.FOOTSTEP_PLAN_HEADER
45 super(InputState, self).
__init__(outcomes=[
'received',
'aborted',
'no_connection',
'data_error'],
63 return 'no_connection' 69 if result.result_code != BehaviorInputResult.RESULT_OK:
74 response_data = pickle.loads(result.data)
76 userdata.data = response_data
78 if self.
_request == BehaviorInputGoal.SELECTED_OBJECT_ID:
79 Logger.loginfo(
'Received template ID: %d' % int(response_data))
81 except Exception
as e:
82 Logger.logwarn(
'Was unable to load provided data:\n%s' % str(e))
96 action_goal = BehaviorInputGoal()
97 action_goal.request_type = self.
_request 102 except Exception
as e:
103 Logger.logwarn(
'Was unable to send data request:\n%s' % str(e))