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()
47 initial_pose = PoseStamped()
48 initial_pose.header.frame_id =
'map'
49 initial_pose.header.stamp = navigator.get_clock().now().to_msg()
50 initial_pose.pose.position.x = 3.45
51 initial_pose.pose.position.y = 2.15
52 initial_pose.pose.orientation.z = 1.0
53 initial_pose.pose.orientation.w = 0.0
54 navigator.setInitialPose(initial_pose)
57 navigator.waitUntilNav2Active()
60 inspection_points = []
61 inspection_pose = PoseStamped()
62 inspection_pose.header.frame_id =
'map'
63 inspection_pose.header.stamp = navigator.get_clock().now().to_msg()
64 inspection_pose.pose.orientation.z = 1.0
65 inspection_pose.pose.orientation.w = 0.0
66 for pt
in inspection_route:
67 inspection_pose.pose.position.x = pt[0]
68 inspection_pose.pose.position.y = pt[1]
69 inspection_points.append(deepcopy(inspection_pose))
70 navigator.followWaypoints(inspection_points)
75 while not navigator.isTaskComplete():
77 feedback = navigator.getFeedback()
78 if feedback
and i % 5 == 0:
79 print(
'Executing current waypoint: ' +
80 str(feedback.current_waypoint + 1) +
'/' + str(len(inspection_points)))
82 result = navigator.getResult()
83 if result == TaskResult.SUCCEEDED:
84 print(
'Inspection of shelves complete! Returning to start...')
85 elif result == TaskResult.CANCELED:
86 print(
'Inspection of shelving was canceled. Returning to start...')
87 elif result == TaskResult.FAILED:
88 print(
'Inspection of shelving failed! Returning to start...')
91 initial_pose.header.stamp = navigator.get_clock().now().to_msg()
92 navigator.goToPose(initial_pose)
93 while not navigator.isTaskComplete():
99 if __name__ ==
'__main__':