Skip to content
This repository has been archived by the owner on Jul 16, 2024. It is now read-only.

Added a code example for the PhotonPoseEstimator Optional #321

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions source/docs/programming/photonlib/robot-pose-estimator.rst
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,15 @@ Calling ``update()`` on your ``PhotonPoseEstimator`` will return an ``EstimatedR
}

You should be updating your `drivetrain pose estimator <https://docs.wpilib.org/en/latest/docs/software/advanced-controls/state-space/state-space-pose-estimators.html>`_ with the result from the ``RobotPoseEstimator`` every loop using ``addVisionMeasurement()``. TODO: add example note
.. tab-set-code::
.. code-block:: java
var result = photonCam_1.getLatestResult();
Copy link
Contributor

Choose a reason for hiding this comment

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

Also show initialization of this camera explicitly? Also var is discouraged in our docs

Copy link
Author

Choose a reason for hiding this comment

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

Thank you for the feedback. I will make sure to be way more thorough next time.

if (result.hasTargets()) { //Make
var update = photonPoseEstimator.update();
Pose3d currentPose3d = update.get().estimatedPose;
botPose = currentPose3d.toPose2d();
Copy link
Contributor

Choose a reason for hiding this comment

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

These two variables should have explicit types

photonTimestamp = update.get().timestampSeconds;
}

Additional ``PhotonPoseEstimator`` Methods
------------------------------------------
Expand Down
Loading