7 from geometry_msgs.msg
import PoseArray, PoseStamped, Pose
8 from std_msgs.msg
import Bool, Empty
11 Since many navigations stacks do not support multiple goals or even action servers,
12 this node serves is a demo example of sending simple goals sequentially, checking for range completion in between.
13 Goal timeouts and handling other edge cases is left as an excercise to the reader.
18 rospy.init_node(
'waypoints_to_simple_goals')
20 self.
rate = rospy.get_param(
'~rate', 10)
21 self.
robot_link = rospy.get_param(
'~robot_link',
'base_link')
34 self.
goal_pub = rospy.Publisher(
'/move_base_simple/goal', PoseStamped, queue_size=1)
37 self.
state_pub = rospy.Publisher(
'/waypoints/state', Bool, queue_size=1, latch=
True)
48 rospy.loginfo(
"Waypoints node started.")
51 poses = list(msg.poses)
61 rospy.loginfo(
"New path received!")
74 rospy.loginfo(
"Emergency stop triggered!")
95 rospy.loginfo(f
"Published: ({next_pose.position.x},{next_pose.position.y},{next_pose.position.z}), {len(self.waypoints)} goals left.")
103 rospy.loginfo(
"Path finished!")
107 transform = self.
tf_buffer.lookup_transform(
108 goal.header.frame_id,
118 dx = transform.transform.translation.x - goal.pose.position.x
119 dy = transform.transform.translation.y - goal.pose.position.y
120 distance = math.sqrt(dx*dx + dy*dy)
124 except (tf2_ros.LookupException,
125 tf2_ros.ConnectivityException,
126 tf2_ros.ExtrapolationException)
as e:
138 rate = rospy.Rate(node.rate)
139 rospy.on_shutdown(node.cleanup)
141 while not rospy.is_shutdown():