Commit ·
17348fa
1
Parent(s): 9844c98
fix: Disable tap detection during emotion playback to prevent false triggers
Browse files
reachy_mini_ha_voice/satellite.py
CHANGED
|
@@ -816,6 +816,24 @@ class VoiceSatelliteProtocol(APIServer):
|
|
| 816 |
"""
|
| 817 |
try:
|
| 818 |
import requests
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 819 |
|
| 820 |
# Get WLAN IP from daemon status
|
| 821 |
wlan_ip = "localhost"
|
|
@@ -838,3 +856,7 @@ class VoiceSatelliteProtocol(APIServer):
|
|
| 838 |
|
| 839 |
except Exception as e:
|
| 840 |
_LOGGER.error(f"Error playing emotion {emotion_name}: {e}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 816 |
"""
|
| 817 |
try:
|
| 818 |
import requests
|
| 819 |
+
import threading
|
| 820 |
+
|
| 821 |
+
# Temporarily disable tap detection during emotion playback
|
| 822 |
+
# to prevent false triggers from robot movement
|
| 823 |
+
tap_detector = getattr(self.state, 'tap_detector', None)
|
| 824 |
+
if tap_detector:
|
| 825 |
+
tap_detector.set_enabled(False)
|
| 826 |
+
_LOGGER.debug("Tap detection disabled during emotion playback")
|
| 827 |
+
|
| 828 |
+
# Re-enable after emotion completes (estimated 3 seconds)
|
| 829 |
+
def reenable_tap():
|
| 830 |
+
import time
|
| 831 |
+
time.sleep(3.0)
|
| 832 |
+
if tap_detector:
|
| 833 |
+
tap_detector.set_enabled(True)
|
| 834 |
+
_LOGGER.debug("Tap detection re-enabled after emotion")
|
| 835 |
+
|
| 836 |
+
threading.Thread(target=reenable_tap, daemon=True).start()
|
| 837 |
|
| 838 |
# Get WLAN IP from daemon status
|
| 839 |
wlan_ip = "localhost"
|
|
|
|
| 856 |
|
| 857 |
except Exception as e:
|
| 858 |
_LOGGER.error(f"Error playing emotion {emotion_name}: {e}")
|
| 859 |
+
# Re-enable tap detection on error
|
| 860 |
+
tap_detector = getattr(self.state, 'tap_detector', None)
|
| 861 |
+
if tap_detector:
|
| 862 |
+
tap_detector.set_enabled(True)
|