Swerve Migrate to Phoenix 6

Hello,

Right now I am trying to migrate the 2023 swerve code into the 2024 swerve code. I know that the 2024 code is using Phoenix v6 firmwork, but can we use the Phoenix v5 firmworked motors on the 2024 swerve code?

Thanks,

Are you using all CTRE Components? Krakens/Falcons, Pigeons, and CANcoders?

This repo helped my team develop swerve code for 2024 using Phoenix 6. We just picked and chose what we wanted because this is essentially a library for every swerve module and motor config.

BaseTalonFXSwerve

Yes

I would highly recommend taking a look at the Tuner X’s Swerve configuration tool that will output a template project for you that is fully up to date Phoenix 6 code.

4 Likes

I second @JohnFogarty 's recommendation and add to it that the Tuner X Swerve Generator takes full advantage of CTRE’s API and capabilities with seamless enhancements if you purchase the Pro License (worth it if you want to support/thank CTRE for the fantastic Phoenix 6 API and want to eek out of much performance as possible from their components)

For my team, what changed was the configuration and the way that we passed in the angle to the motor

Config changed from this (old) to this (new)

Just ignore the motion magic stuff. That is residual from old code.

The motor call changed from:

this.steeringMotor.set(ControlMode.Position, this.motorRotation / Constants.TWO_PI * 26214.4d);

to

this.steeringMotor.setControl(new PositionDutyCycle(angle * 12.8 / Constants.TWO_PI));

the 26214.4 is the magic number that made that code work (appears to be approximately 12.8 * 2048), and 12.8 is the steering gear ratio for SDS MK4 modules

Yes, for 2024 you can, as long as you’re using a motor controller that’s supported in Phoenix v5 (not Kraken.) You will get lots of deprecation warning, but it will work this year. Next year, those deprecated methods will probably be removed.

Over the summer I followed the migration guide and successfully ported our code from v5 to v6, but have since decided to use the CTRE swerve library instead. As recommended by others, it’s certainly the way to go if you’re using Talon FX motor controllers (Falcon 500 or Kraken), CANCoders, and a Pigeon 2 IMU. Any other configuration is not supported.

With v6 you can configure the steeringMotor’s SensorToMechanismRatio to 12.8 and it will do the gearing conversion for you

1 Like

oh wow–I didn’t realize that

thanks for letting me know!

Thank you all!!! I got it figured it out. The problem was the CANcoder will only return degree.

1 Like

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