4 Copyright (c) 2016, Allgeyer Tobias, Aumann Florian, Borella Jocelyn, Hutmacher Robin, Karrenbauer Oliver, Marek Felix, Meissner Pascal, Trautmann Jeremias, Wittenbeck Valerij 8 Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 10 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 12 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 14 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. 16 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 from common.common_sm
import GetMoveRobotSateMachine
25 from direct_search_states
import DirectSearchInit, GetGoalCameraPose, CheckSearchFinished, FrustumViz
26 from common.object_detection
import ObjectDetection
27 from common.move
import MovePTU, PTUPoseCorrection
28 from indirect_search.ism
import SceneRecognition
29 from common.visualize_waypoints
import VisualizeWaypoints
34 sm_search = smach.StateMachine(outcomes=[
'found_objects',
36 'nowhere_left_to_search'],
37 input_keys=[
'searched_object_types_and_ids'])
41 smach.StateMachine.add(
'GET_GOAL_CAMERA_POSE',
43 transitions={
'MoveRobot':
'MOVE_ROBOT',
44 'MovePTUOnly':
'MOVE_PTU_ONLY',
45 'nowhere_left_to_search':
'nowhere_left_to_search',
47 remapping={
'goal_camera_pose':
'goal_camera_pose',
48 'goal_robot_pose':
'goal_robot_pose',
49 'goal_ptu_position':
'goal_ptu_position',
50 'searched_object_types_and_ids':
'searched_object_types_and_ids',
51 'filtered_searched_object_types':
'filtered_searched_object_types'})
53 smach.StateMachine.add(
'MOVE_ROBOT',
55 transitions={
'succeeded':
'PTU_POSE_CORRECTION',
57 remapping={
'goal_robot_pose':
'goal_robot_pose',
58 'goal_ptu_position':
'goal_ptu_position'})
60 smach.StateMachine.add(
'MOVE_PTU_ONLY',
62 transitions={
'succeeded':
'PTU_POSE_CORRECTION',
64 remapping={
'goal_ptu_position':
'goal_ptu_position'})
66 smach.StateMachine.add(
'PTU_POSE_CORRECTION',
68 transitions={
'succeeded':
'VISUALIZE_FRUSTUM',
69 'aborted':
'VISUALIZE_FRUSTUM'},
70 remapping={
'goal_camera_pose':
'goal_camera_pose'})
72 smach.StateMachine.add(
'VISUALIZE_FRUSTUM',
74 transitions={
'succeeded':
'VISUALIZE_WAYPOINT'})
76 smach.StateMachine.add(
'VISUALIZE_WAYPOINT',
78 transitions={
'succeeded':
'OBJECT_DETECTION'})
80 smach.StateMachine.add(
'OBJECT_DETECTION',
82 transitions={
'found_objects':
'found_objects',
83 'no_objects_found':
'GET_GOAL_CAMERA_POSE',
85 remapping={
'searched_object_types':
'filtered_searched_object_types',
86 'detected_objects':
'detected_objects'})
91 sm_direct_search_as_standalone = smach.StateMachine(outcomes=[
'search_finished',
94 'found_all_required_scenes',
95 'nowhere_left_to_search'])
97 with sm_direct_search_as_standalone:
98 smach.StateMachine.add(
'DIRECT_SEARCH_INIT',
100 transitions={
'object_poses_from_demonstrations_given':
'OBJECT_LOCATIONS_BASED_SEARCH',
101 'no_object_poses_from_demonstrations':
'SCENE_EXPLORATION',
102 'aborted':
'aborted'},
103 remapping={
'searched_object_types_and_ids':
'searched_object_types_and_ids'})
105 smach.StateMachine.add(
'OBJECT_LOCATIONS_BASED_SEARCH',
107 transitions={
'found_objects':
'CHECK_SEARCH_FINISHED',
109 'nowhere_left_to_search':
'SCENE_EXPLORATION'},
110 remapping={
'searched_object_types_and_ids':
'searched_object_types_and_ids'})
112 smach.StateMachine.add(
'SCENE_EXPLORATION',
114 transitions={
'found_objects':
'CHECK_SEARCH_FINISHED',
116 'nowhere_left_to_search':
'nowhere_left_to_search'},
117 remapping={
'searched_object_types_and_ids':
'searched_object_types_and_ids'})
120 smach.StateMachine.add(
'CHECK_SEARCH_FINISHED',
122 transitions={
'search_finished':
'search_finished',
123 'search_not_finished':
'SCENE_RECOGNITION',
124 'aborted':
'aborted'},
125 remapping={
'searched_object_types_and_ids':
'searched_object_types_and_ids'})
127 smach.StateMachine.add(
'SCENE_RECOGNITION',
129 transitions={
'found_scenes':
'OBJECT_LOCATIONS_BASED_SEARCH',
130 'found_all_required_scenes':
'found_all_required_scenes',
131 'found_all_objects':
'found_all_objects',
132 'aborted':
'aborted'})
136 sm_direct_search_for_object_search = smach.StateMachine(outcomes=[
'found_objects',
138 'nowhere_left_to_search'])
140 with sm_direct_search_for_object_search:
141 smach.StateMachine.add(
'DIRECT_SEARCH_INIT',
143 transitions={
'object_poses_from_demonstrations_given':
'OBJECT_LOCATIONS_BASED_SEARCH',
144 'no_object_poses_from_demonstrations':
'SCENE_EXPLORATION',
145 'aborted':
'aborted'},
146 remapping={
'searched_object_types_and_ids':
'searched_object_types_and_ids'})
148 smach.StateMachine.add(
'OBJECT_LOCATIONS_BASED_SEARCH',
150 transitions={
'found_objects':
'found_objects',
152 'nowhere_left_to_search':
'SCENE_EXPLORATION'},
153 remapping={
'searched_object_types_and_ids':
'searched_object_types_and_ids'})
155 smach.StateMachine.add(
'SCENE_EXPLORATION',
157 transitions={
'found_objects':
'found_objects',
159 'nowhere_left_to_search':
'nowhere_left_to_search'},
160 remapping={
'searched_object_types_and_ids':
'searched_object_types_and_ids'})
def GetMoveRobotSateMachine()