Extract 3D positions for all joints from hand data. Joint matrices are relative to the wrist, so we compute: global_joint = wrist @ joint_local
(hand_data: dict)
| 113 | |
| 114 | |
| 115 | def extract_hand_positions(hand_data: dict) -> dict[str, np.ndarray]: |
| 116 | """Extract 3D positions for all joints from hand data. |
| 117 | |
| 118 | Joint matrices are relative to the wrist, so we compute: |
| 119 | global_joint = wrist @ joint_local |
| 120 | """ |
| 121 | positions = {} |
| 122 | |
| 123 | # Get wrist matrix first (this is in global frame) |
| 124 | if "wrist" not in hand_data or hand_data["wrist"] is None: |
| 125 | return positions |
| 126 | |
| 127 | wrist_matrix = matrix_from_array(hand_data["wrist"]) |
| 128 | positions["wrist"] = get_position(wrist_matrix) |
| 129 | |
| 130 | # All other joints are relative to wrist |
| 131 | for joint_name in JOINT_NAMES: |
| 132 | if joint_name == "wrist": |
| 133 | continue |
| 134 | if joint_name in hand_data and hand_data[joint_name] is not None: |
| 135 | joint_local = matrix_from_array(hand_data[joint_name]) |
| 136 | joint_global = wrist_matrix @ joint_local |
| 137 | positions[joint_name] = get_position(joint_global) |
| 138 | |
| 139 | return positions |
| 140 | |
| 141 | |
| 142 | def draw_coordinate_frame(ax, matrix: np.ndarray, label: str, scale: float = 0.1): |
nothing calls this directly
no test coverage detected