16 from copy
import deepcopy
18 from geometry_msgs.msg
import PoseStamped
23 Basic stock inspection demo. In this demonstration, the expectation
24 is that there are cameras or RFID sensors mounted on the robots
25 collecting information about stock quantity and location.
32 navigator = BasicNavigator()
50 initial_pose = PoseStamped()
51 initial_pose.header.frame_id =
'map'
52 initial_pose.header.stamp = navigator.get_clock().now().to_msg()
53 initial_pose.pose.position.x = 0.0
54 initial_pose.pose.position.y = 0.0
55 initial_pose.pose.orientation.z = 0.0
56 initial_pose.pose.orientation.w = 1.0
57 navigator.setInitialPose(initial_pose)
60 navigator.waitUntilNav2Active()
63 inspection_points = []
64 inspection_pose = PoseStamped()
65 inspection_pose.header.frame_id =
'map'
66 inspection_pose.header.stamp = navigator.get_clock().now().to_msg()
67 for pt
in inspection_route:
68 inspection_pose.pose.position.x = pt[0]
69 inspection_pose.pose.position.y = pt[1]
72 inspection_pose.pose.orientation.z = 0.707
73 inspection_pose.pose.orientation.w = 0.707
75 inspection_pose.pose.orientation.z = -0.707
76 inspection_pose.pose.orientation.w = 0.707
77 inspection_points.append(deepcopy(inspection_pose))
79 navigator.followWaypoints(inspection_points)
84 while not navigator.isTaskComplete():
86 feedback = navigator.getFeedback()
87 if feedback
and i % 5 == 0:
89 'Executing current waypoint: '
90 + str(feedback.current_waypoint + 1)
92 + str(len(inspection_points))
95 result = navigator.getResult()
96 if result == TaskResult.SUCCEEDED:
97 print(
'Inspection of shelves complete! Returning to start...')
98 elif result == TaskResult.CANCELED:
99 print(
'Inspection of shelving was canceled. Returning to start...')
100 elif result == TaskResult.FAILED:
101 print(
'Inspection of shelving failed! Returning to start...')
104 initial_pose.header.stamp = navigator.get_clock().now().to_msg()
105 navigator.goToPose(initial_pose)
106 while not navigator.isTaskComplete():
112 if __name__ ==
'__main__':