Spaces:
Running
Running
Keep gestures fluid throughout narration
Browse files- reachy_sistema_solar/robot.py +29 -12
reachy_sistema_solar/robot.py
CHANGED
|
@@ -140,20 +140,37 @@ class GesturePlayer:
|
|
| 140 |
return thread
|
| 141 |
|
| 142 |
def play_sequence(self, gestures: list[str], speech_duration: float) -> threading.Thread:
|
| 143 |
-
"""
|
| 144 |
-
selected = gestures[:5]
|
| 145 |
|
| 146 |
def run() -> None:
|
| 147 |
-
|
| 148 |
-
|
| 149 |
-
#
|
| 150 |
-
#
|
| 151 |
-
|
| 152 |
-
|
| 153 |
-
|
| 154 |
-
|
| 155 |
-
|
| 156 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 157 |
|
| 158 |
thread = threading.Thread(target=run, name="astro-gesture-sequence", daemon=True)
|
| 159 |
thread.start()
|
|
|
|
| 140 |
return thread
|
| 141 |
|
| 142 |
def play_sequence(self, gestures: list[str], speech_duration: float) -> threading.Thread:
|
| 143 |
+
"""Encadena gestos suaves durante toda la explicaci贸n, sin pausas."""
|
| 144 |
+
selected = gestures[:5] or ["atento"]
|
| 145 |
|
| 146 |
def run() -> None:
|
| 147 |
+
deadline = time.monotonic() + max(0.0, speech_duration - 1.0)
|
| 148 |
+
index = 0
|
| 149 |
+
# Cada destino parte de la postura anterior. Esto hace que cabeza,
|
| 150 |
+
# cuerpo y antenas se desplacen de forma continua en lugar de
|
| 151 |
+
# hacer gestos aislados con una parada entre ellos.
|
| 152 |
+
while time.monotonic() < deadline:
|
| 153 |
+
gesture = selected[index % len(selected)]
|
| 154 |
+
target = self._MAP.get(gesture, self._MAP["atento"])
|
| 155 |
+
angle = {"alegre": 0.28, "curioso": -0.24, "sorpresa": 0.18,
|
| 156 |
+
"suave": -0.16, "orgulloso": 0.32, "atento": -0.20}.get(gesture, 0.0)
|
| 157 |
+
head = np.eye(4)
|
| 158 |
+
head[:3, :3] = np.array([
|
| 159 |
+
[math.cos(angle), -math.sin(angle), 0.0],
|
| 160 |
+
[math.sin(angle), math.cos(angle), 0.0],
|
| 161 |
+
[0.0, 0.0, 1.0],
|
| 162 |
+
])
|
| 163 |
+
body_yaw = 0.22 if gesture in {"alegre", "orgulloso", "sorpresa"} else -0.18
|
| 164 |
+
try:
|
| 165 |
+
self.reachy.goto_target(head=head, antennas=target, duration=1.15, body_yaw=body_yaw)
|
| 166 |
+
except Exception as error:
|
| 167 |
+
LOGGER.warning("[MOTION] Secuencia detenida: %s", error)
|
| 168 |
+
break
|
| 169 |
+
index += 1
|
| 170 |
+
try:
|
| 171 |
+
self.reachy.goto_target(head=np.eye(4), antennas=[-0.1745, 0.1745], duration=1.0, body_yaw=0.0)
|
| 172 |
+
except Exception:
|
| 173 |
+
pass
|
| 174 |
|
| 175 |
thread = threading.Thread(target=run, name="astro-gesture-sequence", daemon=True)
|
| 176 |
thread.start()
|