-
Notifications
You must be signed in to change notification settings - Fork 1
/
waypoints_loader.py
executable file
·60 lines (47 loc) · 1.63 KB
/
waypoints_loader.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/usr/bin/env python
import pprint
import rospy
import time
import geometry_msgs.msg
import std_srvs.srv
pp = pprint.PrettyPrinter(indent=2)
# Init right away
rospy.init_node('waypoint_loader', anonymous=True)
# TODO: Support loading from a file
waypoints = [
# Right 10m square
dict(x=8, y=0, tolerance=0.3),
dict(x=10, y=-2, tolerance=0.3),
dict(x=10, y=-8, tolerance=0.3),
dict(x=8, y=-10, tolerance=0.3),
dict(x=2, y=-10, tolerance=0.3),
dict(x=0, y=-8, tolerance=0.3),
dict(x=0, y=3, tolerance=0.3),
]
pp.pprint('hi world')
pp.pprint(waypoints)
# Initialize publishers and service proxies
initial_pose_pub = rospy.Publisher('/initialpose', geometry_msgs.msg.PoseWithCovarianceStamped, queue_size=1)
goal_pub = rospy.Publisher('/move_base_simple/goal', geometry_msgs.msg.PoseStamped, queue_size=10)
waypoints_clear = rospy.ServiceProxy('/waypoint_manager/clear', std_srvs.srv.Empty)
navigator_start = rospy.ServiceProxy('/navigator/start', std_srvs.srv.Empty)
# FIXME: Why is this necessary? I see some places in cpp too where publishing
# something like a visualization marker clear isn't seen either.
time.sleep(1)
# Clear any existing waypoints
waypoints_clear()
# Set our initial pose at origin
msg = geometry_msgs.msg.PoseWithCovarianceStamped()
msg.pose.pose.position.x = 0.0
msg.pose.pose.position.y = 0.0
msg.pose.pose.orientation.w = 1.0
initial_pose_pub.publish(msg)
# Publish the waypoints
for waypoint in waypoints:
msg = geometry_msgs.msg.PoseStamped()
msg.pose.position.x = waypoint['x']
msg.pose.position.y = waypoint['y']
goal_pub.publish(msg)
# Start the navigation
navigator_start()
pass