How to add field centric drive?

Wondering how to add field oriented drive to REVMaxSwerve code.

My team have been able to configure the Rev swerve template code to get our first swerve up and running. However, the drive is not field centric. Does anyone have any tips or how we can change to Rev template to add field oriented drive with a NAVX? Should we just get gyro yaw and use that to transform the stick inputs?

Use ChassisSpeeds.fromFieldRelativeSpeeds(velocityX, velocityY, rotateRate, m_navx.getAngle())

The MaxSwerve template already does this.

Called from here:

Make sure that part of your code matches the template I linked to (specifically the 4th argument of the drive() method needs to be true), and that your gyro is returning appropriate values.

As an aside, when asking for help with coding questions, it’s infinitely easier to help when code is provided. Whenever possible, please include a link to your project on github (or whatever online code repository you prefer)

1 Like