CrossTheRoadElec / Phoenix-Releases

Release repository for Phoenix-Framework and Phoenix-Tuner
76 stars 7 forks source link

Swerve Drive Class Constructor: Add Parameter For Std Devs #65

Closed TheTripleV closed 5 months ago

TheTripleV commented 5 months ago

The WPILib PoseEstimator takes state standard deviations in the constructor (https://github.com/wpilibsuite/allwpilib/blob/9206b47d6708cbae61506e962c633d722884a26f/wpimath/src/main/java/edu/wpi/first/math/estimator/PoseEstimator.java#L65) but does not allow you update the state std devs after the fact, only the vision std devs.

Could the CTRE Swerve constructor be updated to optionally take in state standard deviations that are then passed into the PoseEstimator?

A more generic solution would be to allow all the elements of swerve (odometry, pose estimator, kinematics) to be passed in but that might lead to a slippery of race conditions if teams hold on to and use objects they pass in. In this specific case, it looks like the std devs are copied in manually so I think it should be threadsafe.

TheTripleV commented 5 months ago

Thanks!