Skip to content

Commit 2498d5b

Browse files
authored
Add explaining function with ramp effect
Implement gesture explaining function with speed configurations and ramp systems for arms, head, and hands.
1 parent 70aafd9 commit 2498d5b

1 file changed

Lines changed: 254 additions & 0 deletions

File tree

gestures/explaining.py

Lines changed: 254 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,254 @@
1+
def explaining():
2+
3+
# ----------------------------------
4+
# SPEED CONFIG (natural + controlled)
5+
# ----------------------------------
6+
7+
i01.setHandSpeed("left", 30,30,30,30,30,30)
8+
i01.setHandSpeed("right",30,30,30,30,30,30)
9+
10+
i01.setArmSpeed("left",50,50,50,50)
11+
i01.setArmSpeed("right",50,50,50,50)
12+
13+
i01.setHeadSpeed(50,45,50)
14+
i01.setTorsoSpeed(50,50,50)
15+
16+
# ----------------------------------
17+
# ARM + HEAD RAMP SYSTEM
18+
# ----------------------------------
19+
20+
def rampArm(side, a, b, steps=8, delay=0.05):
21+
for i in range(steps):
22+
t = i / float(steps - 1)
23+
k = t * t * (3 - 2 * t)
24+
25+
x = a[0] + (b[0] - a[0]) * k
26+
y = a[1] + (b[1] - a[1]) * k
27+
z = a[2] + (b[2] - a[2]) * k
28+
r = a[3] + (b[3] - a[3]) * k
29+
30+
i01.moveArm(side, x, y, z, r)
31+
sleep(delay)
32+
33+
def rampHead(yawStart, yawEnd, pitch, steps=10, delay=0.04):
34+
for i in range(steps):
35+
t = i / float(steps - 1)
36+
k = t * t * (3 - 2 * t)
37+
38+
yaw = yawStart + (yawEnd - yawStart) * k
39+
i01.moveHead(yaw, pitch, 90)
40+
sleep(delay)
41+
42+
# ----------------------------------
43+
# ✋ HAND RAMP SYSTEM
44+
# ----------------------------------
45+
46+
def rampHand(side, a, b, steps=6, delay=0.04):
47+
for i in range(steps):
48+
t = i / float(steps - 1)
49+
k = t * t * (3 - 2 * t)
50+
51+
f1 = a[0] + (b[0] - a[0]) * k
52+
f2 = a[1] + (b[1] - a[1]) * k
53+
f3 = a[2] + (b[2] - a[2]) * k
54+
f4 = a[3] + (b[3] - a[3]) * k
55+
f5 = a[4] + (b[4] - a[4]) * k
56+
twist = a[5] + (b[5] - a[5]) * k
57+
58+
i01.moveHand(side, f1,f2,f3,f4,f5,twist)
59+
sleep(delay)
60+
61+
# ----------------------------------
62+
# START POSITION
63+
# ----------------------------------
64+
65+
relax()
66+
sleep(0.6)
67+
68+
rampArm("left", [70,78,40,15], [75,82,42,15])
69+
rampArm("right", [70,78,40,15], [75,82,42,15])
70+
71+
# ✋ relaxed attentive hands (not rigid open)
72+
rampHand("left",
73+
[35,35,35,35,35,150],
74+
[20,25,30,30,25,120])
75+
76+
rampHand("right",
77+
[35,35,35,35,35,11],
78+
[20,25,30,30,25,30])
79+
80+
rampHead(90, 110, 110)
81+
rampHead(110, 75, 75)
82+
rampHead(75, 90, 90)
83+
84+
# ----------------------------------
85+
# INTRODUCTION
86+
# ----------------------------------
87+
88+
rampArm("right", [75,82,42,15], [55,72,38,15])
89+
90+
# ✋ presenting gesture (soft cup)
91+
rampHand("right",
92+
[30,25,25,25,25,40],
93+
[70,45,40,40,35,25])
94+
95+
sleep(0.4)
96+
97+
rampArm("right", [55,72,48,15], [70,80,40,15])
98+
99+
# ----------------------------------
100+
# POINT 1
101+
# ----------------------------------
102+
103+
rampArm("right", [70,80,40,15], [45,68,35,15])
104+
105+
# ✋ pointing emphasis (not rigid)
106+
rampHand("right",
107+
[30,30,30,30,30,30],
108+
[160,45,150,150,150,40])
109+
110+
sleep(0.8)
111+
112+
rampArm("right", [45,68,35,15], [70,80,40,15])
113+
114+
rampHand("right",
115+
[160,45,150,150,150,20],
116+
[30,30,30,30,30,11])
117+
118+
# small expressive pulse
119+
rampHand("right",
120+
[30,30,30,30,30,11],
121+
[80,50,60,60,50,11], steps=4)
122+
123+
rampHand("right",
124+
[80,50,60,60,50,11],
125+
[30,30,30,30,30,20], steps=4)
126+
127+
# ----------------------------------
128+
# POINT 2
129+
# ----------------------------------
130+
131+
rampArm("left", [75,82,52,15], [55,70,38,15])
132+
133+
# ✋ “two ideas” gesture
134+
rampHand("left",
135+
[30,30,30,30,30,130],
136+
[160,20,20,160,160,150])
137+
138+
sleep(0.7)
139+
140+
rampArm("left", [55,70,38,15], [75,82,42,15])
141+
142+
rampHand("left",
143+
[160,20,20,160,160,150],
144+
[30,30,30,30,30,80])
145+
146+
rampHead(90,90,90)
147+
148+
# ----------------------------------
149+
# COMPARISON
150+
# ----------------------------------
151+
152+
rampArm("left", [75,80,40,15], [60,72,38,15])
153+
rampArm("right", [75,80,40,15], [60,72,38,15])
154+
155+
rampHead(90,80,90)
156+
rampArm("left", [60,72,38,15], [50,66,35,15])
157+
158+
rampHand("left",
159+
[30,30,30,30,30,90],
160+
[70,45,50,50,45,150])
161+
162+
rampHead(80,110,90)
163+
rampArm("right", [60,72,38,15], [50,66,35,15])
164+
165+
rampHand("right",
166+
[30,30,30,30,30,30],
167+
[70,45,50,50,45,11])
168+
169+
rampHead(110,90,90)
170+
171+
# ----------------------------------
172+
# EXPANSION
173+
# ----------------------------------
174+
175+
rampArm("left", [70,82,40,15], [62,74,38,15], steps=10)
176+
rampArm("right", [70,82,40,15], [62,74,38,15], steps=10)
177+
178+
rampHand("left",
179+
[40,40,40,40,40,120],
180+
[15,15,15,15,15,150])
181+
182+
rampHand("right",
183+
[40,40,40,40,40,11],
184+
[15,15,15,15,15,30])
185+
186+
sleep(0.3)
187+
188+
rampArm("left", [62,74,38,15], [72,84,52,15], steps=10)
189+
rampArm("right", [62,74,38,15], [72,84,52,15], steps=10)
190+
191+
# ----------------------------------
192+
# EMPHASIS LOOP
193+
# ----------------------------------
194+
195+
for _ in range(3):
196+
197+
rampHead(85,95,88,steps=6)
198+
rampArm("right", [70,80,40,15], [55,70,38,15], steps=6)
199+
200+
rampHand("right",
201+
[30,30,30,30,30,11],
202+
[90,60,70,70,60,25], steps=4)
203+
204+
rampHead(95,85,88,steps=6)
205+
rampArm("left", [70,80,40,15], [55,70,38,15], steps=6)
206+
207+
rampHand("left",
208+
[30,30,30,30,30,110],
209+
[90,60,70,70,60,150], steps=4)
210+
211+
rampHead(90,90,90)
212+
213+
# ----------------------------------
214+
# AUDIENCE SWEEP
215+
# ----------------------------------
216+
217+
rampHead(80,110,90,steps=14)
218+
rampHead(110,90,90,steps=14)
219+
220+
rampHand("left",
221+
[20,20,20,20,20,110],
222+
[10,10,10,10,10,150])
223+
224+
rampHand("right",
225+
[20,20,20,20,20,11],
226+
[10,10,10,10,10,25])
227+
228+
sleep(0.8)
229+
230+
# ----------------------------------
231+
# CONCLUSION
232+
# ----------------------------------
233+
234+
rampArm("left", [72,80,42,15], [68,76,40,15], steps=8)
235+
rampArm("right", [72,80,42,15], [68,76,40,15], steps=8)
236+
237+
rampHead(90,80,90,steps=10)
238+
239+
rampHand("left",
240+
[35,35,35,35,35,110],
241+
[40,40,40,40,40,160])
242+
243+
rampHand("right",
244+
[35,35,35,35,35,11],
245+
[40,40,40,40,40,50])
246+
247+
sleep(1.0)
248+
249+
# gentle return
250+
rampArm("left", [68,76,40,15], [80,80,50,15], steps=10)
251+
rampArm("right", [68,76,40,15], [80,80,50,15], steps=10)
252+
253+
relax()
254+
i01.finishedGesture()

0 commit comments

Comments
 (0)