Consolidate per-dataset geometry helpers into utils.geometry#21
Merged
Conversation
Quaternion->rotation, SE(3) assembly, camera-intrinsics, and homogeneous point-transform logic was reimplemented across the comma2k19, WayveScenes, NAVSIM, and Argoverse 2 processors -- comma2k19 and wayve_scenes/_colmap even hand-rolled the Hamilton quaternion formula that NAVSIM and AV2 already get from scipy. Add standard_e2e/utils/geometry.py (quats_wxyz_to_rotmats / quat_wxyz_to_rotmat, se3, intrinsics_matrix, transform_points) and route all four datasets through it; the scalar-first wxyz <-> scalar-last xyzw reorder scipy needs now lives in one place. A regression test asserts the scipy-backed quaternion helper reproduces the old hand-rolled formula bit-for-bit. Declare scipy as a direct dependency (it was already imported transitively) and relock.
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
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.
Removes geometry code that was reimplemented across dataset processors, and replaces in-repo math with
scipywhere it already lived.What
A new
standard_e2e/utils/geometry.pycentralises five operations that were duplicated per dataset:quats_wxyz_to_rotmats/quat_wxyz_to_rotmat— Hamilton(w,x,y,z)quaternion → rotation matrix, backed byscipy.spatial.transform.Rotation. The scalar-first→scalar-last (xyzw) reorder scipy needs now lives in one place.se3(rotation, translation)— 4×4 SE(3) assembly.intrinsics_matrix(fx, fy, cx, cy)— pinholeK.transform_points(transform, points)— homogeneous(N,3)transform.comma2k19, WayveScenes (incl. the COLMAP reader), NAVSIM, and Argoverse 2 now all route through these. Notably comma2k19 and
wayve_scenes/_colmapwere hand-rolling the Hamilton quaternion formula that NAVSIM/AV2 already obtained from scipy — that duplication (and convention-handling drift risk) is gone.Safety
tests/test_geometry.py::test_quats_match_hand_rolled_hamilton_formula) asserts the scipy-backed helper reproduces the previous hand-rolled Hamilton formula bit-for-bit (max abs diff ~1e-15 over random unit quaternions) — important because comma2k19's coordinate convention is empirically locked.scipyis declared as a direct dependency (it was already pulled in transitively and imported by the NAVSIM/AV2 processors);uv.lockrelocked.Tests
black/isort/flake8/mypyclean;pytestpasses (tests/test_geometry.py6/6, plus the comma2k19 / wayve / colmap suites that exercise the migrated paths).Note: the two
test_navsim_dataset_processor.pyreal-log tests fail on this machine regardless of this branch — nuplan's HD-map loader tries to create a.maplocksdir under the read-only/mnt/bigdisk/datasetsmount (PermissionError); verified the same failure onmain.