WPI Swerve Drive Example Code

Hi, my team has been attempting to integrate swerve drive into our robot this season. We have built our square frame, with the wheels equal distance apart. We have moved on to the programming portion. Seeing that there is a Swerve Drive example code in VS, we decided to attempt to use that while we learn the basics of swerve programming. We have changed all of our encoder input and out for the turning motors within the program, along with changing he motor controllers to the correct type, and we added in our gyro. Whenever we run the code the modules move(both driving and turning) however they do not go to the correct place, nor do they run consistently. The modules appear as is they are trying to go to many points at once.

1 Like

This can be one of a few different things:

  • Unit conversion (ticks, radians, degrees)
  • PIDF values
  • Offsets for each turn motor
  • Bad gyro (hope not!)

I suggest using smartdashboard (while not powering the motors) to display important values such as:

  • Target positions for each module
  • Current gyro heading

Another thing I would try is hardcoding values for setting turn motor position and current gyro heading (separately) to find where the issue really is.

Good luck!

1 Like

Thanks for the response. I like the idea of isolating each potential problem. Thank you!

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.