How to implement torque feedforward with VelocityVoltage request?

Our team does not have a Phoenix Pro license, so we used the VelocityVoltage request for driving wheels on our swerve drive. We want to add a torque feed-forward to the control request. There seems to be a .withFeedForward() method available.

With a known feedforward torque, what should the feedforward voltage be in this case?

From fundamental principles, the conversion between torque and voltage is T = kT*(Va - kb * thetadot) / ra where kT is the torque constant, kb is the back-emf constant, thetadot is the rotation speed of your motor, ra is the effective armature resistance, and Va is the applied voltage.

To get a requested torque, you need to first cancel out the back-emf, and then add an additional voltage to create a current which creates torque. The backemf can be canceled using a kV gain of kb exactly, which then gives you a torque scalar of Va = T*ra / kT.

The motor constants can be found from CTRE’s motor testing data, where kT is given directly, ra is the the rated voltage divided by the stall current, while kB is the (rated voltage minus the free current times ra) / free speed. These constants all have units, ensure that you are consistent with them.

2 Likes