Merged
Conversation
richunger
previously approved these changes
Jan 28, 2026
Contributor
Author
The docs say setVoltage is preferred:
And in their doc on combining FeedForward with PID controls, WPILib uses setVoltage in their example: public void tankDriveWithFeedforwardPID(double leftVelocitySetpoint, double rightVelocitySetpoint) {
leftMotor.setVoltage(feedforward.calculate(leftVelocitySetpoint)
+ leftPID.calculate(leftEncoder.getRate(), leftVelocitySetpoint));
rightMotor.setVoltage(feedForward.calculate(rightVelocitySetpoint)
+ rightPID.calculate(rightEncoder.getRate(), rightVelocitySetpoint));
}https://docs.wpilib.org/en/stable/docs/software/advanced-controls/controllers/feedforward.html |
84c9201
Contributor
|
the problem with that is that setVoltage() expects a voltage as the input, while the PID controller is solving assuming a 0-1 range. So you would be putting 0-1 volts into the motor which would not work for obvious reasons. You could try multiplying by 12, but that is basically just what the set() method does anyway.
…-------- Original Message --------
On Wednesday, 01/28/26 at 11:00 Iprobablydontknowwhatimdoing ***@***.***> wrote:
Iprobablydontknowwhatimdoing left a comment [(IronRiders/rebuilt#25)](#25 (comment))
> wristMotor.setVoltage() should be wristMotor.set()
The docs say setVoltage is preferred:
> Since feedforward voltages are physically meaningful, it is best to use the setVoltage() ([Java](https://github.wpilib.org/allwpilib/docs/release/java/edu/wpi/first/wpilibj/motorcontrol/MotorController.html#setVoltage(double)), [C++](https://github.wpilib.org/allwpilib/docs/release/cpp/classfrc_1_1_motor_controller.html#a613c23a3336e103876e433bcb8b5ad3e), [Python](https://robotpy.readthedocs.io/projects/robotpy/en/stable/wpilib.interfaces/MotorController.html#wpilib.interfaces.MotorController.setVoltage)) method when applying them to motors to compensate for “voltage sag” from the battery.
And in their doc on combining FeedForward with PID controls, WPILib uses setVoltage in their example:
public void tankDriveWithFeedforwardPID(double leftVelocitySetpoint, double rightVelocitySetpoint) { leftMotor.setVoltage(feedforward.calculate(leftVelocitySetpoint) + leftPID.calculate(leftEncoder.getRate(), leftVelocitySetpoint)); rightMotor.setVoltage(feedForward.calculate(rightVelocitySetpoint) + rightPID.calculate(rightEncoder.getRate(), rightVelocitySetpoint)); }
https://docs.wpilib.org/en/stable/docs/software/advanced-controls/controllers/feedforward.html
—
Reply to this email directly, [view it on GitHub](#25 (comment)), or [unsubscribe](https://github.com/notifications/unsubscribe-auth/AZ2JPANJCUBUCQVAM2A5S434JEBK7AVCNFSM6AAAAACTDCRPU2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTQMJTGI3TONBVG4).
You are receiving this because you commented.Message ID: ***@***.***>
|
Contributor
|
and feed forward also compenstates some what for voltage sag, and it's just not a very big deal anyway. Even if you compensate for it, if more than like 3 motors are running you will not be able to avoid sag
…-------- Original Message --------
On Wednesday, 01/28/26 at 13:54 isabelle901 ***@***.***> wrote:
the problem with that is that setVoltage() expects a voltage as the input, while the PID controller is solving assuming a 0-1 range. So you would be putting 0-1 volts into the motor which would not work for obvious reasons. You could try multiplying by 12, but that is basically just what the set() method does anyway.
-------- Original Message --------
On Wednesday, 01/28/26 at 11:00 Iprobablydontknowwhatimdoing ***@***.***> wrote:
> Iprobablydontknowwhatimdoing left a comment [(IronRiders/rebuilt#25)](#25 (comment))
>
>> wristMotor.setVoltage() should be wristMotor.set()
>
> The docs say setVoltage is preferred:
>
>> Since feedforward voltages are physically meaningful, it is best to use the setVoltage() ([Java](https://github.wpilib.org/allwpilib/docs/release/java/edu/wpi/first/wpilibj/motorcontrol/MotorController.html#setVoltage(double)), [C++](https://github.wpilib.org/allwpilib/docs/release/cpp/classfrc_1_1_motor_controller.html#a613c23a3336e103876e433bcb8b5ad3e), [Python](https://robotpy.readthedocs.io/projects/robotpy/en/stable/wpilib.interfaces/MotorController.html#wpilib.interfaces.MotorController.setVoltage)) method when applying them to motors to compensate for “voltage sag” from the battery.
>
> And in their doc on combining FeedForward with PID controls, WPILib uses setVoltage in their example:
>
> public void tankDriveWithFeedforwardPID(double leftVelocitySetpoint, double rightVelocitySetpoint) { leftMotor.setVoltage(feedforward.calculate(leftVelocitySetpoint) + leftPID.calculate(leftEncoder.getRate(), leftVelocitySetpoint)); rightMotor.setVoltage(feedForward.calculate(rightVelocitySetpoint) + rightPID.calculate(rightEncoder.getRate(), rightVelocitySetpoint)); }
>
> https://docs.wpilib.org/en/stable/docs/software/advanced-controls/controllers/feedforward.html
>
> —
> Reply to this email directly, [view it on GitHub](#25 (comment)), or [unsubscribe](https://github.com/notifications/unsubscribe-auth/AZ2JPANJCUBUCQVAM2A5S434JEBK7AVCNFSM6AAAAACTDCRPU2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTQMJTGI3TONBVG4).
> You are receiving this because you commented.Message ID: ***@***.***>
|
Contributor
|
I like the new constant names though! |
Amber-leaf
requested changes
Jan 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.