Desmond-Dong commited on
Commit
377d38f
·
1 Parent(s): 58f00d3

fix the motion

Browse files
reachy_mini_ha_voice/__main__.py CHANGED
@@ -20,6 +20,7 @@ from pyopen_wakeword import OpenWakeWord, OpenWakeWordFeatures
20
 
21
  from .models import AvailableWakeWord, Preferences, ServerState, WakeWordType
22
  from .audio_player import AudioPlayer
 
23
  from .satellite import VoiceSatelliteProtocol
24
  from .util import get_mac
25
  from .zeroconf import HomeAssistantZeroconf
@@ -314,10 +315,12 @@ async def main() -> None:
314
 
315
  # Initialize Reachy Mini (if available)
316
  reachy_mini = None
 
317
  if not args.no_motion:
318
  try:
319
  from reachy_mini import ReachyMini
320
  reachy_mini = ReachyMini()
 
321
  _LOGGER.info("Reachy Mini connected")
322
  except ImportError:
323
  _LOGGER.warning("reachy-mini not installed, motion control disabled")
@@ -343,6 +346,7 @@ async def main() -> None:
343
  refractory_seconds=args.refractory_seconds,
344
  download_dir=download_dir,
345
  reachy_mini=reachy_mini,
 
346
  motion_enabled=not args.no_motion and reachy_mini is not None,
347
  )
348
 
 
20
 
21
  from .models import AvailableWakeWord, Preferences, ServerState, WakeWordType
22
  from .audio_player import AudioPlayer
23
+ from .motion import ReachyMiniMotion
24
  from .satellite import VoiceSatelliteProtocol
25
  from .util import get_mac
26
  from .zeroconf import HomeAssistantZeroconf
 
315
 
316
  # Initialize Reachy Mini (if available)
317
  reachy_mini = None
318
+ motion = None
319
  if not args.no_motion:
320
  try:
321
  from reachy_mini import ReachyMini
322
  reachy_mini = ReachyMini()
323
+ motion = ReachyMiniMotion(reachy_mini)
324
  _LOGGER.info("Reachy Mini connected")
325
  except ImportError:
326
  _LOGGER.warning("reachy-mini not installed, motion control disabled")
 
346
  refractory_seconds=args.refractory_seconds,
347
  download_dir=download_dir,
348
  reachy_mini=reachy_mini,
349
+ motion=motion,
350
  motion_enabled=not args.no_motion and reachy_mini is not None,
351
  )
352
 
reachy_mini_ha_voice/motion.py CHANGED
@@ -45,7 +45,9 @@ class ReachyMiniMotion:
45
  Args:
46
  doa_angle_deg: Direction of arrival angle in degrees (0=front, positive=right, negative=left)
47
  """
 
48
  if not self.reachy_mini:
 
49
  return
50
  self._submit_motion(self._do_wakeup, doa_angle_deg)
51
 
@@ -148,8 +150,12 @@ class ReachyMiniMotion:
148
  """Actual wakeup motion (blocking, runs in thread pool)."""
149
  with self._lock:
150
  try:
 
151
  if doa_angle_deg is not None:
 
152
  self._turn_to_sound_source(doa_angle_deg)
 
 
153
  self._nod(count=1, amplitude=10, duration=0.3)
154
  _LOGGER.debug("Reachy Mini: Wake up nod (DOA: %s)", doa_angle_deg)
155
  except Exception as e:
 
45
  Args:
46
  doa_angle_deg: Direction of arrival angle in degrees (0=front, positive=right, negative=left)
47
  """
48
+ _LOGGER.debug("on_wakeup called with doa_angle_deg=%s, reachy_mini=%s", doa_angle_deg, self.reachy_mini)
49
  if not self.reachy_mini:
50
+ _LOGGER.warning("on_wakeup: reachy_mini is None, skipping motion")
51
  return
52
  self._submit_motion(self._do_wakeup, doa_angle_deg)
53
 
 
150
  """Actual wakeup motion (blocking, runs in thread pool)."""
151
  with self._lock:
152
  try:
153
+ _LOGGER.info("_do_wakeup: doa_angle_deg=%s", doa_angle_deg)
154
  if doa_angle_deg is not None:
155
+ _LOGGER.info("Turning to sound source at %s degrees", doa_angle_deg)
156
  self._turn_to_sound_source(doa_angle_deg)
157
+ else:
158
+ _LOGGER.warning("DOA angle is None, skipping turn to sound source")
159
  self._nod(count=1, amplitude=10, duration=0.3)
160
  _LOGGER.debug("Reachy Mini: Wake up nod (DOA: %s)", doa_angle_deg)
161
  except Exception as e:
reachy_mini_ha_voice/satellite.py CHANGED
@@ -333,9 +333,6 @@ class VoiceSatelliteProtocol(APIServer):
333
  # Update DOA entity in Home Assistant
334
  self._update_doa_entities()
335
 
336
- # Reachy Mini: Wake up animation
337
- self._reachy_on_wakeup()
338
-
339
  def stop(self) -> None:
340
  self.state.active_wake_words.discard(self.state.stop_word.id)
341
  self.state.tts_player.stop()
@@ -485,17 +482,6 @@ class VoiceSatelliteProtocol(APIServer):
485
  except Exception as e:
486
  _LOGGER.error("Error updating DOA entities: %s", e)
487
 
488
- def _reachy_on_wakeup(self) -> None:
489
- """Called when wake word is detected."""
490
- if not self.state.motion_enabled or not self.state.reachy_mini:
491
- return
492
- try:
493
- # Nod to acknowledge
494
- _LOGGER.debug("Reachy Mini: Wake up animation")
495
- # Will be implemented with actual Reachy Mini SDK
496
- except Exception as e:
497
- _LOGGER.error("Reachy Mini motion error: %s", e)
498
-
499
  def _reachy_on_listening(self) -> None:
500
  """Called when listening for speech (HA state: Listening)."""
501
  if not self.state.motion_enabled or not self.state.reachy_mini:
 
333
  # Update DOA entity in Home Assistant
334
  self._update_doa_entities()
335
 
 
 
 
336
  def stop(self) -> None:
337
  self.state.active_wake_words.discard(self.state.stop_word.id)
338
  self.state.tts_player.stop()
 
482
  except Exception as e:
483
  _LOGGER.error("Error updating DOA entities: %s", e)
484
 
 
 
 
 
 
 
 
 
 
 
 
485
  def _reachy_on_listening(self) -> None:
486
  """Called when listening for speech (HA state: Listening)."""
487
  if not self.state.motion_enabled or not self.state.reachy_mini: