Commit ·
9181fcd
1
Parent(s): 8ee2217
fix: pass current body_yaw to SDK for proper automatic body yaw calculation
Browse files- In movement_manager.py: Get current body_yaw from joint positions and pass
it to set_target() so SDK's IK can calculate safe body_yaw from current position
- In reachy_controller.py: Fix variable name bug (reachy_mini -> reachy) in set_body_yaw()
The SDK's inverse_kinematics_safe() needs the current body_yaw as a starting
point to properly calculate when body rotation is needed to prevent head-body
collision. Previously we were passing None/0.0, causing the SDK to always
start from 0, which prevented proper body following behavior.
reachy_mini_ha_voice/movement_manager.py
CHANGED
|
@@ -806,7 +806,9 @@ class MovementManager:
|
|
| 806 |
def _issue_control_command(self, head_pose: np.ndarray, antennas: Tuple[float, float]) -> None:
|
| 807 |
"""Send control command to robot with error throttling and connection health tracking.
|
| 808 |
|
| 809 |
-
|
|
|
|
|
|
|
| 810 |
|
| 811 |
Args:
|
| 812 |
head_pose: 4x4 head pose matrix
|
|
@@ -852,12 +854,22 @@ class MovementManager:
|
|
| 852 |
logger.debug("Attempting to send command after connection loss...")
|
| 853 |
|
| 854 |
try:
|
| 855 |
-
#
|
| 856 |
-
#
|
| 857 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 858 |
self.robot.set_target(
|
| 859 |
head=head_pose,
|
| 860 |
antennas=list(antennas),
|
|
|
|
| 861 |
)
|
| 862 |
|
| 863 |
# Command succeeded - update connection health and cache
|
|
|
|
| 806 |
def _issue_control_command(self, head_pose: np.ndarray, antennas: Tuple[float, float]) -> None:
|
| 807 |
"""Send control command to robot with error throttling and connection health tracking.
|
| 808 |
|
| 809 |
+
When automatic_body_yaw is enabled (set in voice_assistant.py), the SDK's IK
|
| 810 |
+
automatically calculates body_yaw to prevent head-body collision. We pass the
|
| 811 |
+
current body_yaw as a starting point so IK can smoothly adjust from current position.
|
| 812 |
|
| 813 |
Args:
|
| 814 |
head_pose: 4x4 head pose matrix
|
|
|
|
| 854 |
logger.debug("Attempting to send command after connection loss...")
|
| 855 |
|
| 856 |
try:
|
| 857 |
+
# Get current body_yaw to pass to IK as starting point
|
| 858 |
+
# This allows SDK's automatic_body_yaw to smoothly adjust from current position
|
| 859 |
+
current_body_yaw = 0.0
|
| 860 |
+
try:
|
| 861 |
+
joints = self.robot.get_current_joint_positions()
|
| 862 |
+
if joints is not None:
|
| 863 |
+
head_joints, _ = joints
|
| 864 |
+
current_body_yaw = head_joints[0] # body_yaw is first joint
|
| 865 |
+
except Exception:
|
| 866 |
+
pass # Use 0.0 as fallback
|
| 867 |
+
|
| 868 |
+
# Send to robot with current body_yaw for smooth IK calculation
|
| 869 |
self.robot.set_target(
|
| 870 |
head=head_pose,
|
| 871 |
antennas=list(antennas),
|
| 872 |
+
body_yaw=current_body_yaw,
|
| 873 |
)
|
| 874 |
|
| 875 |
# Command succeeded - update connection health and cache
|
reachy_mini_ha_voice/reachy_controller.py
CHANGED
|
@@ -505,11 +505,11 @@ class ReachyController:
|
|
| 505 |
Note: This directly calls SDK's set_target_body_yaw since automatic body yaw
|
| 506 |
is enabled. Manual control will temporarily override automatic mode.
|
| 507 |
"""
|
| 508 |
-
if self.
|
| 509 |
self._disabled_pose_setter('body_yaw')
|
| 510 |
return
|
| 511 |
try:
|
| 512 |
-
self.
|
| 513 |
except Exception as e:
|
| 514 |
logger.error(f"Error setting body yaw: {e}")
|
| 515 |
|
|
|
|
| 505 |
Note: This directly calls SDK's set_target_body_yaw since automatic body yaw
|
| 506 |
is enabled. Manual control will temporarily override automatic mode.
|
| 507 |
"""
|
| 508 |
+
if self.reachy is None:
|
| 509 |
self._disabled_pose_setter('body_yaw')
|
| 510 |
return
|
| 511 |
try:
|
| 512 |
+
self.reachy.set_target_body_yaw(math.radians(yaw_deg))
|
| 513 |
except Exception as e:
|
| 514 |
logger.error(f"Error setting body yaw: {e}")
|
| 515 |
|