Clarify coordinate frame conventions for project_waypoints_ftheta (refs #34)#76
Open
lonexreb wants to merge 1 commit intoNVlabs:mainfrom
Open
Clarify coordinate frame conventions for project_waypoints_ftheta (refs #34)#76lonexreb wants to merge 1 commit intoNVlabs:mainfrom
lonexreb wants to merge 1 commit intoNVlabs:mainfrom
Conversation
Issue NVlabs#34 reports that GT trajectory projections do not align with the road in the camera image. A likely cause is the docstring on project_waypoints_ftheta(), which says "3D waypoints in world coordinates" even though the function (correctly) expects rig-frame coordinates — the PAI extrinsic table stores cam_t and the camera quaternion in the rig frame, so the formula (wp - cam_t) @ R_cam_to_rig only resolves to the camera frame when wp is also in the rig frame. Document this: - wp: rig-frame 3D points (load_physical_aiavdataset's ego_future_xyz already qualifies because the ego frame at t0 coincides with the rig frame at t0). - cam_t: camera origin in the rig frame. - cam_rot: camera-to-rig rotation matrix as returned by Rotation.from_quat([qx,qy,qz,qw]).as_matrix() with quat loaded directly from the PAI extrinsics. - Camera frame: right-handed, +z forward; points with z <= 0 are dropped. Also document the world->rig transformation users must apply if they start with world-frame waypoints from egomotion().pose.translation. Refs NVlabs#34. No behavior change. Signed-off-by: lonexreb <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Doc-only fix for
src/alpamayo_r1/visualization/viz.py:project_waypoints_ftheta. No behavior change.Issue #34 reports that GT trajectory projections do not align with the road in the camera image. The current docstring says:
…but the function actually expects rig-frame coordinates. The transformation chain is:
with
cam_t= camera origin in the rig frame (as stored in the PAI extrinsics table) andcam_rot=R_cam_to_rig. This formula resolves to the camera frame only whenwpis also in the rig frame. If a user reads the docstring literally and passes world-frame waypoints (e.g.egomotion().pose.translation), the projection lands on a different surface — exactly what #34 reports.What this PR does
Updates the docstring to:
wp,cam_t, andcam_rotmust all be in the rig frame (which is what the PAI loader'sego_future_xyzandego_history_xyzalready are att0).cam_rotis the camera-to-rig rotation as returned byRotation.from_quat([qx,qy,qz,qw]).as_matrix()with the quaternion taken directly from the PAI extrinsics.(wp - cam_t) @ cam_rotstep explaining the row-vector / right-multiplication trick.Why this matters
The issue's reporter tried both
ego_future_xyz(already correct) andego_future_xyz_world → ego(t0) localpaths and reported failure on both. With the clearer docstring + inline comment, future readers can sanity-check their inputs against the documented conventions. (If the reporter is in fact passing rig-frame waypoints and still seeing misalignment, the issue lies elsewhere — most likely an extrinsic-quaternion convention mismatch — and the clearer docstring at least narrows the search space.)Test plan
python -c \"import ast; ast.parse(open('src/alpamayo_r1/visualization/viz.py').read())\"— syntax OK.viz.py:106-109andload_physical_aiavdataset.py:128-144).Related