Skip to content

PhotonPoseEstimator should invalidate the pose cache when setting referencePose #2039

Description

@kcooney

Describe the bug
In both PhotonPoseEstimator.checkUpdate() (Java) and PhotonPoseEstimator._checkUpdate() (Python) the cache is not invalidated if the first parameter is empty/null. With the current usages, this means that if the reference pose was not set, setting it would not invalidate the cache.

To Reproduce
Steps to reproduce the behavior in Python:

camera = createCameraWithVisibleTag()
estimator = PhotonPoseEstimator(
    aprilTags, PoseStrategy.LOWEST_AMBIGUITY, camera, Transform3d())
estimatedPose = estimator.update()
assert estimatedPose is not None
estimator.referencePose = Pose3d(3, 3, 3, robotToCamera)
assert estimator._poseCacheTimestampSeconds == -1  # fails

Steps to reproduce the behavior in Java:

PhotonCamera camera = createCameraWithVisibleTag();
var estimator = new PhotonPoseEstimator(
    aprilTags, PoseStrategy.LOWEST_AMBIGUITY, camera, robotToCamera);
var estimatedPose = estimator.update(cameraResult);
assert estimatedPose.isPresent();
estimator.setReferencePose(new Pose3d(3, 3, 3, new Rotation3d());
assert estimator.poseCacheTimestampSeconds == -1  // fails

Additional context
I found this while adding working on adding support for more strategies in Python.
I have a fix I'll be sending out shortly for Python

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingphotonlibThings related to the PhotonVision library

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions