MCPcopy Create free account
hub / github.com/Improbable-AI/VisionProTeleop / extract_hand_positions

Function extract_hand_positions

utils/visualize_tracking.py:115–139  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

113
114
115def 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
142def draw_coordinate_frame(ax, matrix: np.ndarray, label: str, scale: float = 0.1):

Callers

nothing calls this directly

Calls 2

matrix_from_arrayFunction · 0.70
get_positionFunction · 0.70

Tested by

no test coverage detected