apirrone
commited on
Commit
·
8637e54
1
Parent(s):
13808fa
cleaning up
Browse files
reachy_mini_red_light_green_light/main.py
CHANGED
@@ -20,8 +20,8 @@ UPPER_BODY_LANDMARKS = [11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22]
|
|
20 |
|
21 |
class RedLightGreenLightApp(ReachyMiniApp):
|
22 |
def run(self, reachy_mini: ReachyMini, stop_event: threading.Event):
|
23 |
-
|
24 |
-
cap = cv2.VideoCapture(0) # debug
|
25 |
if cap is None:
|
26 |
raise RuntimeError("No camera found. Please connect a camera.")
|
27 |
|
@@ -34,6 +34,9 @@ class RedLightGreenLightApp(ReachyMiniApp):
|
|
34 |
people_detector = PeopleDetector(model_path=pose_landmarker_path, max_poses=3)
|
35 |
|
36 |
def sequence():
|
|
|
|
|
|
|
37 |
time.sleep(1)
|
38 |
sleep_head_joint_positions = SLEEP_HEAD_JOINT_POSITIONS.copy()
|
39 |
sleep_head_joint_positions[0] = np.deg2rad(170)
|
@@ -82,12 +85,6 @@ class RedLightGreenLightApp(ReachyMiniApp):
|
|
82 |
antennas_joint_positions=SLEEP_ANTENNAS_JOINT_POSITIONS,
|
83 |
duration=sleep_3_time,
|
84 |
)
|
85 |
-
# sleep_head_joint_positions[0] = np.deg2rad(170)
|
86 |
-
# reachy_mini._goto_joint_positions(
|
87 |
-
# head_joint_positions=sleep_head_joint_positions,
|
88 |
-
# antennas_joint_positions=SLEEP_ANTENNAS_JOINT_POSITIONS,
|
89 |
-
# duration=sleep_3_time,
|
90 |
-
# )
|
91 |
print("SOLEIL !!!")
|
92 |
reachy_mini.play_sound("dance1.wav")
|
93 |
reachy_mini.goto_target(np.eye(4), antennas=[0.0, 0.0], duration=0.5)
|
@@ -123,22 +120,6 @@ class RedLightGreenLightApp(ReachyMiniApp):
|
|
123 |
look_at_px[0], look_at_px[1], duration=0.3
|
124 |
)
|
125 |
|
126 |
-
# normalized_look_at = (
|
127 |
-
# ((look_at_px[0] / frame.shape[1]) - 0.5) * 2,
|
128 |
-
# ((look_at_px[1] / frame.shape[0]) - 0.5) * 2,
|
129 |
-
# ) # Normalize to [-1, 1]
|
130 |
-
# yaw_range = [-80, 80]
|
131 |
-
# target_yaw = (
|
132 |
-
# normalized_look_at[0] * (yaw_range[1] - yaw_range[0]) / 2
|
133 |
-
# + (yaw_range[1] + yaw_range[0]) / 2
|
134 |
-
# )
|
135 |
-
# pose = create_head_pose(
|
136 |
-
# yaw=-target_yaw,
|
137 |
-
# )
|
138 |
-
# reachy_mini.goto_target(
|
139 |
-
# head=pose, antennas=[0.5, 0.0], duration=0.3
|
140 |
-
# )
|
141 |
-
|
142 |
last_watched = time.time()
|
143 |
buffer = []
|
144 |
moved = []
|
@@ -210,8 +191,7 @@ class RedLightGreenLightApp(ReachyMiniApp):
|
|
210 |
time.sleep(2)
|
211 |
return
|
212 |
|
213 |
-
|
214 |
-
cv2.waitKey(1)
|
215 |
|
216 |
cv2.destroyAllWindows()
|
217 |
|
|
|
20 |
|
21 |
class RedLightGreenLightApp(ReachyMiniApp):
|
22 |
def run(self, reachy_mini: ReachyMini, stop_event: threading.Event):
|
23 |
+
cap = find_camera()
|
24 |
+
# cap = cv2.VideoCapture(0) # debug
|
25 |
if cap is None:
|
26 |
raise RuntimeError("No camera found. Please connect a camera.")
|
27 |
|
|
|
34 |
people_detector = PeopleDetector(model_path=pose_landmarker_path, max_poses=3)
|
35 |
|
36 |
def sequence():
|
37 |
+
"""
|
38 |
+
Red light green light sequence.
|
39 |
+
"""
|
40 |
time.sleep(1)
|
41 |
sleep_head_joint_positions = SLEEP_HEAD_JOINT_POSITIONS.copy()
|
42 |
sleep_head_joint_positions[0] = np.deg2rad(170)
|
|
|
85 |
antennas_joint_positions=SLEEP_ANTENNAS_JOINT_POSITIONS,
|
86 |
duration=sleep_3_time,
|
87 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
88 |
print("SOLEIL !!!")
|
89 |
reachy_mini.play_sound("dance1.wav")
|
90 |
reachy_mini.goto_target(np.eye(4), antennas=[0.0, 0.0], duration=0.5)
|
|
|
120 |
look_at_px[0], look_at_px[1], duration=0.3
|
121 |
)
|
122 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
123 |
last_watched = time.time()
|
124 |
buffer = []
|
125 |
moved = []
|
|
|
191 |
time.sleep(2)
|
192 |
return
|
193 |
|
194 |
+
time.sleep(0.01)
|
|
|
195 |
|
196 |
cv2.destroyAllWindows()
|
197 |
|