-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmove_base.py
executable file
·68 lines (56 loc) · 1.71 KB
/
move_base.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
61
62
63
64
65
66
67
68
#!/usr/bin/env python
import roslib
## roslib.load_manifest('handover')
import rospy
import sys, time, os
import numpy as np
from geometry_msgs.msg import Twist
# PI = 3.1415926535897
# from handover.msg import skeleton
# from std_msgs.msg import Float64MultiArray
class MoveBase:
def __init__(self):
start = time.time()
self.move_base = rospy.Publisher("/amp_wpi/twist_command", Twist, queue_size=10)
def move_right(self):
start = time.time()
# self.move_base = rospy.Publisher("/amp_wpi/twist_command", Twist, queue_size=10)
base = Twist()
base.angular.z = -0.2
rate = 30
r = rospy.Rate(rate)
stop = 2.8/2
while time.time()-start < stop:
self.move_base.publish(base)
r.sleep()
def move_left(self):
start = time.time()
# self.move_base = rospy.Publisher("/amp_wpi/twist_command", Twist, queue_size=10)
base = Twist()
base.angular.z = 0.2
rate = 30
r = rospy.Rate(rate)
stop = 3.25
while time.time()-start < stop:
self.move_base.publish(base)
r.sleep()
def move_45deg(self):
start = time.time()
# self.move_base = rospy.Publisher("/amp_wpi/twist_command", Twist, queue_size=10)
base = Twist()
base.angular.z = -0.2
rate = 30
r = rospy.Rate(rate)
stop = 3.25/2
while time.time()-start < stop:
self.move_base.publish(base)
r.sleep()
def main(args):
rospy.init_node('MoveBase', anonymous=True)
numpub = MoveBase()
try:
rospy.spin()
except KeyboardInterrupt:
print ("Shutting down")
if __name__ == '__main__':
main(sys.argv)