kF in new pid controller?

I would like to know how to add a kF in the pid command. It seems to be taken away for this year and I haven’t seen an alternative. Thanks

I thought of maybe adding + . 1 to the output in our drive train but I don’t think that would go well as I wouldn’t know how to copy the sign of the output

(assuming you’re using Java or C++)

Because kF is just based on your setpoint, you should be able to just multiply your setpoint (goal velocity) by your kF (feedforward constant) and simply add it to the PID control signal. Assuming it ranges from [-1,1], you won’t need to copy the sign.

The new WPILib docs detail the usage of SimpleMotorFeedforward for this purpose, as well as how to combine it with PID.

We aren’t in percent but rather volts, we are also doing this based on a gyro value. The project is auto aim.

I believe you’ll want to end up passing output + feedforward to driveSubsystem.setOutput, where feedforward is calculated based on setpoint * kF (or, for a more rigorous approach, calculated from a frc-characterization model).

How exactly you structure this depends on your programming style. Hopefully someone more familiar with good code architecture can recommend specifics, as I’m not too familiar with command-based programming and OO style in general. The docs suggest handling the feedforward and feedback (PID) controllers separately:

Moreover, feedforward is a separate feature entirely from feedback, and thus has no reason to be handled in the same controller object, as this violates separation of concerns.

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