-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcozmo_actions.py
111 lines (84 loc) · 2.82 KB
/
cozmo_actions.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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
import numpy as np
import rospy
import time
from std_msgs.msg import String
from std_msgs.msg import Float64
from std_msgs.msg import ColorRGBA
pub_say = rospy.Publisher('/cozmo/say', String, queue_size=10)
pub_head_angle = rospy.Publisher('/cozmo/head_angle', Float64, queue_size=10)
pub_lift_hight = rospy.Publisher('/cozmo/lift_height',Float64, queue_size=10)
pub_back_color = rospy.Publisher('/cozmo/backpack_led', ColorRGBA, queue_size=10)
party_count = 0
cheerup_count = 0
confused_count= 0
cute_count = 0
rospy.init_node('actions', anonymous=True)
class actions():
def action_party(self):
global party_count
say = 'lets party'
pub_say.publish(say)
time.sleep(0.3)
head_angle = (3)
pub_head_angle.publish(head_angle)
# party_count += 1
for i in range(0,12):
lift_hight = (1)
pub_lift_hight.publish(lift_hight)
time.sleep(0.3)
lift_hight = (0)
pub_lift_hight.publish(lift_hight)
time.sleep(0.3)
# back_color = ColorRGBA(1,1,1,1)
# pub_back_color.publish(back_color)
def action_sadness(self):
global cheerup_count
say = 'i will cheer you up'
pub_say.publish(say)
time.sleep(0.3)
head_angle = (1)
pub_head_angle.publish(head_angle)
# cheerup_count += 1
for i in range(0,4):
lift_hight = (0.2)
pub_lift_hight.publish(lift_hight)
time.sleep(0.3)
lift_hight = (0)
pub_lift_hight.publish(lift_hight)
time.sleep(0.3)
# back_color = ColorRGBA(1,1,1,1)
# pub_back_color.publish(back_color)
def action_confused_cute(self):
global confused_count
say = 'What are we doing again?'
pub_say.publish(say)
time.sleep(0.3)
head_angle = (3)
pub_head_angle.publish(head_angle)
# confused_count += 1
for i in range(0,2):
lift_hight = (0.2)
pub_lift_hight.publish(lift_hight)
time.sleep(0.3)
lift_hight = (0)
pub_lift_hight.publish(lift_hight)
time.sleep(0.3)
# back_color = ColorRGBA(1,1,1,1)
# pub_back_color.publish(back_color)
def action_cute(self):
global cute_count
say = 'You are cute'
pub_say.publish(say)
time.sleep(0.3)
head_angle = (3)
pub_head_angle.publish(head_angle)
# cute_count += 1
for i in range(0,1):
lift_hight = (0.2)
pub_lift_hight.publish(lift_hight)
time.sleep(0.3)
lift_hight = (0)
pub_lift_hight.publish(lift_hight)
time.sleep(0.3)
# back_color = ColorRGBA(1,1,1,1)
# pub_back_color.publish(back_color)