Skip to content

Fix PoseObservation serialization for AdvantageKit replay#662

Open
aschokking wants to merge 1 commit intomainfrom
fix-visionio-logging
Open

Fix PoseObservation serialization for AdvantageKit replay#662
aschokking wants to merge 1 commit intomainfrom
fix-visionio-logging

Conversation

@aschokking
Copy link
Contributor

@aschokking aschokking commented Mar 20, 2026

Why are we doing this?

  • log replay is useful, we should have it!
  • this blocks that
  • fixing replay will come in a later PR

Whats changing?

Claude:

PoseObservation contained a Matrix<N3, N1> estimatedStdDevs field. AdvantageKit's RecordStruct serializes records by
reflecting on each component type and looking for a static struct field. Matrix<N3, N1> doesn't have one, so AKit
silently drops estimatedStdDevs during logging and throws errors during replay deserialization.

Fix

Replace Matrix<N3, N1> estimatedStdDevs in the PoseObservation record with three separate double fields (stdDev0,
stdDev1, stdDev2), which RecordStruct can serialize natively.

The change is kept as narrow as possible:

  • IO implementations (AprilTagVisionIOPhotonVision, AprilTagVisionIOPhotonVisionEstimator) unpack their Matrix values
    only at the new PoseObservation(...) call site
  • AprilTagVisionCameraHelper converts back to Matrix<N3, N1> via VecBuilder.fill() when passing to
    VisionPoseObservation
  • getEstimationStdDevs and all other internal logic continue using Matrix<N3, N1> unchanged

Questions/notes for reviewers

How this was tested

  • unit tests added
  • tested on robot

Matrix<N3, N1> has no static struct field, so AdvantageKit's RecordStruct
silently drops the estimatedStdDevs field during logging, causing data loss
and replay crashes. Replace it with three separate doubles (stdDev0, stdDev1,
stdDev2) in the PoseObservation record, which RecordStruct can serialize
natively. IO implementations and tests unpack/repack at the record boundary;
the rest of the codebase continues using Matrix<N3, N1>.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@aschokking aschokking requested a review from a team as a code owner March 20, 2026 03:51
VecBuilder.fill(0.02, 0.02, 0.6), // This is from LinearStdDevBaseline, and AngularStdDevBaseline from the old way.
0.02, 0.02, 0.6, // This is from LinearStdDevBaseline, and AngularStdDevBaseline from the old way.
PoseObservationType.PHOTONVISION)); // Observation type

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be better to just delete this class rather than maintain it.

I think with several matches under it's belt now. AprilTagVisionIOPhotonVisionEstimator is now the king, all hail the new king.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants