-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathicecream_cone.py
88 lines (66 loc) · 1.62 KB
/
icecream_cone.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#!/usr/bin/python3
import rospy
import math as m
import time
from geometry_msgs.msg import Twist
pub = rospy.Publisher('/turtle1/cmd_vel', Twist, queue_size=1)
rospy.init_node('turtle_in_a_dream_eat_a_icecream', anonymous=False)
move = Twist()
SIDE_LENGTH = 2*(m.pi)*150/360
TOP_LENGTH = 2*(m.pi)*75/360
TOPSIDE_ANGLE = 2*(m.pi)*104.95/360
SIDESIDE_ANGLE = 2*(m.pi)*150/360
SCOOP_ANGLE = 2*(m.pi)*330/360
time.sleep(2)
def make_side():
move.linear.x = SIDE_LENGTH
move.angular.z = 0.0
pub.publish(move)
time.sleep(1)
def topside_rotate():
move.linear.x = 0.0
move.angular.z = TOPSIDE_ANGLE
pub.publish(move)
time.sleep(1)
def make_top():
move.linear.x = TOP_LENGTH
move.angular.z = 0.0
pub.publish(move)
time.sleep(1)
def sidesiderotate():
move.linear.x = 0.0
move.angular.z = SIDESIDE_ANGLE
pub.publish(move)
time.sleep(1)
def scoop_angle():
move.linear.x = 0.0
move.angular.z = SCOOP_ANGLE
pub.publish(move)
time.sleep(1)
def make_scoop():
for _ in range(2):
move.linear.x = 2.5
move.angular.z = 2.5
pub.publish(move)
time.sleep(1)
def make_icecream():
move.linear.x = 0.0
move.angular.z = 0.0
pub.publish(move)
time.sleep(1)
while not rospy.is_shutdown():
make_side()
topside_rotate()
make_top()
topside_rotate()
make_side()
sidesiderotate()
make_side()
scoop_angle()
make_scoop()
break
if __name__ == '__main__':
try:
make_icecream()
except rospy.ROSInterruptException:
pass