Skip to content

SwerveModule.periodic() does not update the drive voltage #39

@brettle

Description

@brettle

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.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions