My team is switching to swerve drive this year, using Kraken motors with embedded TalonFX controllers. We are using CANcoders as absolute encoders to find the offset on the turning motors. My question is about which encoders to use for Drive motor PID control during autonomous. Do teams use the internal encoder in the TalonFX for that, or is there value in mounting external relative encoders for Drive motor control? In the past for differential driving we always liked to have external encoders attached directly to the wheel shaft to get the most accurate data.
well if your using the TalonFX controllers on the krakens you can use the setControl method and the PID from that will be using the internal motor encoder, if you want you can use Rio PID but personally i prefer using the Talonfx controllers for everything, since its basically plug and play.
if you were to use external encoders you would be forced to use Rio PID to set the drive motors, and the TalonFX controller would just be handling applying the voltage, which is kinda pointless when you have a motor as nice as a kraken.
others may disagree with this, but ur just better off using the TalonFX controllers.
Everything you are saying is correct.
Tank drives would frequently have an incremental encoder directly on the wheel to measure actual wheel rotations after backlash from drive gearbox and such. This was also the established norm back before we had brushless motors and so you had to put an encoder somewhere, you might as well put it at the wheel.
Swerve drives with off-the-shelf modules these days exclusively just use the drive brushless motor’s internal encoder.
There can be a couple reasons for this:
- COTS Swerve modules are machined well (good center-center control), often use steel gears that don’t wear as much, and as such have lower backlash
- Accurate driving based off wheel encoders is a lot less needed in today’s games where you can “close the loop” with vision (vision on the goal, vision of game object, April tag field odometry)
- PID controller will be most precise and stable when it is directly getting feedback from and controlling the motor. This is also why I believe that even we have absolute encoder 1:1 with the azimuth we still run PID controller off brushless encoder, only using that external encoder for initial pose/boot-up-homing (I may be wrong on this last point, I’m no software pro)
This is correct. Almost all swerve drive code simply grabs the absolute encoders’ poses on code boot to correctly offset the motors’ internal encoder and never touches it again.
Thanks everyone, this is very helpful. We will use the TalonFX controllers for PID control of the Drive motors.
Worth noting if you have Phoenix Pro you can use the FusedCANcoder feedback mode to get the benefits of both sensors