apirrone commited on
Commit
4e01395
·
1 Parent(s): 337cea5
Files changed (2) hide show
  1. pyproject.toml +3 -3
  2. red_light_green_light/main.py +10 -14
pyproject.toml CHANGED
@@ -11,9 +11,9 @@ readme = "README.md"
11
  requires-python = ">=3.8"
12
  # dependencies = ["reachy-mini"]
13
  dependencies = [
14
- "reachy-mini@git+https://github.com/pollen-robotics/reachy_mini",
15
- "mediapipe",
16
- ] # TODO open
17
 
18
  [tool.setuptools]
19
  package-dir = { "" = "." }
 
11
  requires-python = ">=3.8"
12
  # dependencies = ["reachy-mini"]
13
  dependencies = [
14
+ "reachy-mini",
15
+ "reachy-mini-toolbox[vision]>=1.0.1"
16
+ ]
17
 
18
  [tool.setuptools]
19
  package-dir = { "" = "." }
red_light_green_light/main.py CHANGED
@@ -5,7 +5,8 @@ from importlib.resources import files
5
  import cv2
6
  import numpy as np
7
  from reachy_mini import ReachyMiniApp
8
- from reachy_mini.utils.camera import find_camera
 
9
  from reachy_mini.reachy_mini import (
10
  SLEEP_ANTENNAS_JOINT_POSITIONS,
11
  SLEEP_HEAD_JOINT_POSITIONS,
@@ -21,11 +22,6 @@ UPPER_BODY_LANDMARKS = [11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22]
21
 
22
  class RedLightGreenLightApp(ReachyMiniApp):
23
  def run(self, reachy_mini: ReachyMini, stop_event: threading.Event):
24
- cap = find_camera()
25
- # cap = cv2.VideoCapture(0) # debug
26
- if cap is None:
27
- raise RuntimeError("No camera found. Please connect a camera.")
28
-
29
  # arbitrary 3 maximum people are tracked. Maybe make it a parameter?
30
  pose_landmarker_path: str = str(
31
  files(red_light_green_light).joinpath("pose_landmarker_full.task")
@@ -49,7 +45,7 @@ class RedLightGreenLightApp(ReachyMiniApp):
49
  sleep_2_time = np.random.rand() + 0.4 * 1.3
50
  sleep_3_time = np.random.rand() + 0.3 * 3.0
51
  print("1...")
52
- reachy_mini.play_sound("count.wav")
53
  sleep_head_joint_positions[0] = np.deg2rad(160)
54
  reachy_mini._goto_joint_positions(
55
  head_joint_positions=sleep_head_joint_positions,
@@ -63,7 +59,7 @@ class RedLightGreenLightApp(ReachyMiniApp):
63
  duration=sleep_1_time,
64
  )
65
  print("2...")
66
- reachy_mini.play_sound("count.wav")
67
  sleep_head_joint_positions[0] = np.deg2rad(150)
68
  reachy_mini._goto_joint_positions(
69
  head_joint_positions=sleep_head_joint_positions,
@@ -77,7 +73,7 @@ class RedLightGreenLightApp(ReachyMiniApp):
77
  duration=sleep_2_time,
78
  )
79
  print("3...")
80
- reachy_mini.play_sound("count.wav")
81
  sleep_head_joint_positions[0] = np.deg2rad(0)
82
  reachy_mini._goto_joint_positions(
83
  head_joint_positions=sleep_head_joint_positions,
@@ -85,7 +81,7 @@ class RedLightGreenLightApp(ReachyMiniApp):
85
  duration=sleep_3_time,
86
  )
87
  print("SOLEIL !!!")
88
- reachy_mini.play_sound("dance1.wav")
89
  reachy_mini.goto_target(np.eye(4), antennas=[0.0, 0.0], duration=0.5)
90
 
91
  def scan():
@@ -97,11 +93,11 @@ class RedLightGreenLightApp(ReachyMiniApp):
97
  ) # Random scan duration between 4 and 7 seconds
98
  buffer = []
99
  moved = []
100
- reachy_mini.play_sound("confused1.wav")
101
  last_watched = time.time()
102
  while time.time() - t0 < scan_for:
103
- ret, frame = cap.read()
104
- if not ret:
105
  break
106
 
107
  # Look at a random player
@@ -185,7 +181,7 @@ class RedLightGreenLightApp(ReachyMiniApp):
185
  reachy_mini.goto_target(
186
  head=pose, antennas=[-0.5, 0.5], duration=1.0
187
  )
188
- reachy_mini.play_sound("impatient1.wav")
189
 
190
  time.sleep(2)
191
  return
 
5
  import cv2
6
  import numpy as np
7
  from reachy_mini import ReachyMiniApp
8
+
9
+ # from reachy_mini.utils.camera import find_camera
10
  from reachy_mini.reachy_mini import (
11
  SLEEP_ANTENNAS_JOINT_POSITIONS,
12
  SLEEP_HEAD_JOINT_POSITIONS,
 
22
 
23
  class RedLightGreenLightApp(ReachyMiniApp):
24
  def run(self, reachy_mini: ReachyMini, stop_event: threading.Event):
 
 
 
 
 
25
  # arbitrary 3 maximum people are tracked. Maybe make it a parameter?
26
  pose_landmarker_path: str = str(
27
  files(red_light_green_light).joinpath("pose_landmarker_full.task")
 
45
  sleep_2_time = np.random.rand() + 0.4 * 1.3
46
  sleep_3_time = np.random.rand() + 0.3 * 3.0
47
  print("1...")
48
+ reachy_mini.media.play_sound("count.wav")
49
  sleep_head_joint_positions[0] = np.deg2rad(160)
50
  reachy_mini._goto_joint_positions(
51
  head_joint_positions=sleep_head_joint_positions,
 
59
  duration=sleep_1_time,
60
  )
61
  print("2...")
62
+ reachy_mini.media.play_sound("count.wav")
63
  sleep_head_joint_positions[0] = np.deg2rad(150)
64
  reachy_mini._goto_joint_positions(
65
  head_joint_positions=sleep_head_joint_positions,
 
73
  duration=sleep_2_time,
74
  )
75
  print("3...")
76
+ reachy_mini.media.play_sound("count.wav")
77
  sleep_head_joint_positions[0] = np.deg2rad(0)
78
  reachy_mini._goto_joint_positions(
79
  head_joint_positions=sleep_head_joint_positions,
 
81
  duration=sleep_3_time,
82
  )
83
  print("SOLEIL !!!")
84
+ reachy_mini.media.play_sound("dance1.wav")
85
  reachy_mini.goto_target(np.eye(4), antennas=[0.0, 0.0], duration=0.5)
86
 
87
  def scan():
 
93
  ) # Random scan duration between 4 and 7 seconds
94
  buffer = []
95
  moved = []
96
+ reachy_mini.media.play_sound("confused1.wav")
97
  last_watched = time.time()
98
  while time.time() - t0 < scan_for:
99
+ frame = reachy_mini.media.get_frame()
100
+ if frame is None:
101
  break
102
 
103
  # Look at a random player
 
181
  reachy_mini.goto_target(
182
  head=pose, antennas=[-0.5, 0.5], duration=1.0
183
  )
184
+ reachy_mini.media.play_sound("impatient1.wav")
185
 
186
  time.sleep(2)
187
  return