Commit ·
9a11246
1
Parent(s): d84e937
fix: Remove speech_detected check in DOA turn-to-sound
Browse files- speech_detected is unreliable after wake word detection completes
- Add more debug logging for DOA values
- Add detailed comments about DOA coordinate conversion
- PROJECT_PLAN.md +1 -3
- reachy_mini_ha_voice/satellite.py +25 -14
PROJECT_PLAN.md
CHANGED
|
@@ -142,9 +142,7 @@ Integrate Home Assistant voice assistant functionality into Reachy Mini Wi-Fi ro
|
|
| 142 |
|
| 143 |
### Application Architecture
|
| 144 |
- [x] Compliant with Reachy Mini App architecture
|
| 145 |
-
|
| 146 |
-
- [x] Auto-download sound effect files
|
| 147 |
-
- [x] No .env configuration file required
|
| 148 |
|
| 149 |
|
| 150 |
## File List
|
|
|
|
| 142 |
|
| 143 |
### Application Architecture
|
| 144 |
- [x] Compliant with Reachy Mini App architecture
|
| 145 |
+
|
|
|
|
|
|
|
| 146 |
|
| 147 |
|
| 148 |
## File List
|
reachy_mini_ha_voice/satellite.py
CHANGED
|
@@ -2,6 +2,7 @@
|
|
| 2 |
|
| 3 |
import hashlib
|
| 4 |
import logging
|
|
|
|
| 5 |
import posixpath
|
| 6 |
import shutil
|
| 7 |
import time
|
|
@@ -646,13 +647,15 @@ class VoiceSatelliteProtocol(APIServer):
|
|
| 646 |
Face tracking will take over after the initial turn.
|
| 647 |
|
| 648 |
DOA angle convention (from SDK):
|
| 649 |
-
- 0 radians = left
|
| 650 |
-
- π/2 radians = front
|
| 651 |
-
- π radians = right
|
| 652 |
|
| 653 |
-
|
| 654 |
-
|
| 655 |
-
|
|
|
|
|
|
|
| 656 |
"""
|
| 657 |
if not self.state.motion_enabled or not self.state.reachy_mini:
|
| 658 |
return
|
|
@@ -665,18 +668,26 @@ class VoiceSatelliteProtocol(APIServer):
|
|
| 665 |
return
|
| 666 |
|
| 667 |
angle_rad, speech_detected = doa
|
| 668 |
-
|
| 669 |
-
|
| 670 |
-
return
|
| 671 |
|
| 672 |
-
# Convert DOA to
|
| 673 |
-
# SDK:
|
| 674 |
-
#
|
| 675 |
-
|
| 676 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 677 |
yaw_rad = angle_rad - math.pi / 2
|
| 678 |
yaw_deg = math.degrees(yaw_rad)
|
| 679 |
|
|
|
|
|
|
|
|
|
|
| 680 |
# Only turn if angle is significant (> 10°) to avoid noise
|
| 681 |
DOA_THRESHOLD_DEG = 10.0
|
| 682 |
if abs(yaw_deg) < DOA_THRESHOLD_DEG:
|
|
|
|
| 2 |
|
| 3 |
import hashlib
|
| 4 |
import logging
|
| 5 |
+
import math
|
| 6 |
import posixpath
|
| 7 |
import shutil
|
| 8 |
import time
|
|
|
|
| 647 |
Face tracking will take over after the initial turn.
|
| 648 |
|
| 649 |
DOA angle convention (from SDK):
|
| 650 |
+
- 0 radians = left (Y+ direction in head frame)
|
| 651 |
+
- π/2 radians = front (X+ direction in head frame)
|
| 652 |
+
- π radians = right (Y- direction in head frame)
|
| 653 |
|
| 654 |
+
The SDK uses: p_head = [sin(doa), cos(doa), 0]
|
| 655 |
+
So we need to convert this to yaw angle.
|
| 656 |
+
|
| 657 |
+
Note: We don't check speech_detected because by the time wake word
|
| 658 |
+
detection completes, the user may have stopped speaking.
|
| 659 |
"""
|
| 660 |
if not self.state.motion_enabled or not self.state.reachy_mini:
|
| 661 |
return
|
|
|
|
| 668 |
return
|
| 669 |
|
| 670 |
angle_rad, speech_detected = doa
|
| 671 |
+
_LOGGER.debug("DOA raw: angle=%.3f rad (%.1f°), speech=%s",
|
| 672 |
+
angle_rad, math.degrees(angle_rad), speech_detected)
|
|
|
|
| 673 |
|
| 674 |
+
# Convert DOA to direction vector in head frame
|
| 675 |
+
# SDK convention: p_head = [sin(doa), cos(doa), 0]
|
| 676 |
+
# where X+ is front, Y+ is left
|
| 677 |
+
dir_x = math.sin(angle_rad) # Front component
|
| 678 |
+
dir_y = math.cos(angle_rad) # Left component
|
| 679 |
+
|
| 680 |
+
# Calculate yaw angle from direction vector
|
| 681 |
+
# yaw = atan2(y, x), but we want: positive yaw = turn right
|
| 682 |
+
# In robot frame: Y+ is left, so yaw = -atan2(dir_y, dir_x)
|
| 683 |
+
# But since dir_x = sin(doa), dir_y = cos(doa):
|
| 684 |
+
# yaw = -atan2(cos(doa), sin(doa)) = -(π/2 - doa) = doa - π/2
|
| 685 |
yaw_rad = angle_rad - math.pi / 2
|
| 686 |
yaw_deg = math.degrees(yaw_rad)
|
| 687 |
|
| 688 |
+
_LOGGER.debug("DOA direction: x=%.2f, y=%.2f, yaw=%.1f°",
|
| 689 |
+
dir_x, dir_y, yaw_deg)
|
| 690 |
+
|
| 691 |
# Only turn if angle is significant (> 10°) to avoid noise
|
| 692 |
DOA_THRESHOLD_DEG = 10.0
|
| 693 |
if abs(yaw_deg) < DOA_THRESHOLD_DEG:
|