Hello, I am trying to use photon vision pose estimation with a CTRE swerve drive and I am running into a problem with the pose. Whenever I run the code it says the pose is 0,0. I am not too sure what is causing this to happen or if I did something wrong but any help would be greatly appreciated.
Our code is here: GitHub - ManOfAgua/SwerveCompV2_2024 at TestBranch
Does the SwerveDriveTrain automatically do the kinematics and odometry updates from the encoders and the swerve modules or is that something you need to do?
If so, you probably need to call your parent class periodic inside of your method override.
I see you implemented a Runnable
(PhotonRunnable
) to get the latest pose, but I don’t see you starting a thread for PhotonRunnable photonEstimator
in CommandSwerveDrivetrain.java. Assuming I haven’t missed anything, the PhotonRunnable.run()
method is never called, so grabLatestEstimatedPose()
will always be empty.
You shouldn’t need to implement the Runnable
there. You can just have grabLatestEstimatedPose()
call photonPoseEstimator.update()
directly. PhotonVision is already caching the latest result via a NetworkTable subscriber.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.