DeepBlueRobotics/lib199

`SwerveModule.periodic()` does not update the drive voltage

brettle opened this issue · 0 comments

Currently, SwerveModule.periodic() only updates the turn voltage. The drive voltage is only updated when SwerveModule.setSpeed() is called. Since drivetrain code might not call setSpeed() regularly (e.g. if nothing is changing the speed), the drive pid controller won't be called to determine the correct voltage to use to achieve the most recently requested speed. Seems like the code in setSpeed() should be moved into periodic() and setSpeed() should just save the desired speed in a field for use by periodic().

This is almost definitely the cause of the robot drifting while it's supposed to be stopped in the middle of an auto routine.