direct_search_sm.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 
3 '''
4 Copyright (c) 2016, Allgeyer Tobias, Aumann Florian, Borella Jocelyn, Hutmacher Robin, Karrenbauer Oliver, Marek Felix, Meissner Pascal, Trautmann Jeremias, Wittenbeck Valerij
5 
6 All rights reserved.
7 
8 Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
9 
10 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
11 
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.
13 
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.
15 
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.
17 '''
18 
19 import roslib
20 import rospy
21 import smach
22 import smach_ros
23 
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
30 
32 
33  def getSmSearch():
34  sm_search = smach.StateMachine(outcomes=['found_objects',
35  'aborted',
36  'nowhere_left_to_search'],
37  input_keys=['searched_object_types_and_ids'])
38 
39  with sm_search:
40 
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',
46  'aborted':'aborted'},
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'})
52 
53  smach.StateMachine.add('MOVE_ROBOT',
55  transitions={'succeeded':'PTU_POSE_CORRECTION',
56  'aborted':'aborted'},
57  remapping={'goal_robot_pose':'goal_robot_pose',
58  'goal_ptu_position':'goal_ptu_position'})
59 
60  smach.StateMachine.add('MOVE_PTU_ONLY',
61  MovePTU(),
62  transitions={'succeeded':'PTU_POSE_CORRECTION',
63  'aborted':'aborted'},
64  remapping={'goal_ptu_position':'goal_ptu_position'})
65 
66  smach.StateMachine.add('PTU_POSE_CORRECTION',
68  transitions={'succeeded':'VISUALIZE_FRUSTUM',
69  'aborted':'VISUALIZE_FRUSTUM'},
70  remapping={'goal_camera_pose':'goal_camera_pose'})
71 
72  smach.StateMachine.add('VISUALIZE_FRUSTUM',
73  FrustumViz(),
74  transitions={'succeeded':'VISUALIZE_WAYPOINT'})
75 
76  smach.StateMachine.add('VISUALIZE_WAYPOINT',
78  transitions={'succeeded':'OBJECT_DETECTION'})
79 
80  smach.StateMachine.add('OBJECT_DETECTION',
82  transitions={'found_objects':'found_objects',
83  'no_objects_found':'GET_GOAL_CAMERA_POSE',
84  'aborted':'aborted'},
85  remapping={'searched_object_types':'filtered_searched_object_types',
86  'detected_objects':'detected_objects'})
87  return sm_search
88 
89 
90 
91  sm_direct_search_as_standalone = smach.StateMachine(outcomes=['search_finished',
92  'aborted',
93  'found_all_objects',
94  'found_all_required_scenes',
95  'nowhere_left_to_search'])
96 
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'})
104 
105  smach.StateMachine.add('OBJECT_LOCATIONS_BASED_SEARCH',
106  getSmSearch(),
107  transitions={'found_objects':'CHECK_SEARCH_FINISHED',
108  'aborted':'aborted',
109  'nowhere_left_to_search':'SCENE_EXPLORATION'},
110  remapping={'searched_object_types_and_ids':'searched_object_types_and_ids'})
111 
112  smach.StateMachine.add('SCENE_EXPLORATION',
113  getSmSearch(),
114  transitions={'found_objects':'CHECK_SEARCH_FINISHED',
115  'aborted':'aborted',
116  'nowhere_left_to_search':'nowhere_left_to_search'},
117  remapping={'searched_object_types_and_ids':'searched_object_types_and_ids'})
118 
119 
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'})
126 
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'})
133 
134 
135 
136  sm_direct_search_for_object_search = smach.StateMachine(outcomes=['found_objects',
137  'aborted',
138  'nowhere_left_to_search'])
139 
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'})
147 
148  smach.StateMachine.add('OBJECT_LOCATIONS_BASED_SEARCH',
149  getSmSearch(),
150  transitions={'found_objects':'found_objects',
151  'aborted':'aborted',
152  'nowhere_left_to_search':'SCENE_EXPLORATION'},
153  remapping={'searched_object_types_and_ids':'searched_object_types_and_ids'})
154 
155  smach.StateMachine.add('SCENE_EXPLORATION',
156  getSmSearch(),
157  transitions={'found_objects':'found_objects',
158  'aborted':'aborted',
159  'nowhere_left_to_search':'nowhere_left_to_search'},
160  remapping={'searched_object_types_and_ids':'searched_object_types_and_ids'})
def GetMoveRobotSateMachine()
Definition: common_sm.py:29


asr_state_machine
Author(s): Allgeyer Tobias, Aumann Florian, Borella Jocelyn, Hutmacher Robin, Karrenbauer Oliver, Marek Felix, Meißner Pascal, Trautmann Jeremias, Wittenbeck Valerij
autogenerated on Mon Feb 28 2022 21:53:50