-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
128 make lift use pids #129
Conversation
|
||
rightBumper.and(leftBumper.negate()).whileTrue(new RightLiftUpCommand()); | ||
rightTrigger.and(leftTrigger.negate()).whileTrue(new RightLiftDownCommand()); | ||
rightBumper.and(leftBumper.negate()).whileTrue(new LiftUpCommand()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since left bumper/trigger is no longer used
rightBumper.and(leftBumper.negate()).whileTrue(new LiftUpCommand()); | |
rightBumper.whileTrue(new LiftUpCommand()); |
} | ||
|
||
@Override | ||
public void execute() { | ||
lift.runLeftUp(); | ||
lift.runRightUp(); | ||
lift.enable(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
enable should be in initialize
@@ -192,11 +182,130 @@ public boolean rightLowerLimitReached() { | |||
|
|||
@Override | |||
public void periodic() { | |||
if (enabled) { | |||
double output = verticalController.calculate(getLeftPosition()); | |||
double error = errorController.calculate(DriveTrain.getInstance().getPitch()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would store driveTrain as a private variable on this class so that we don't have to get instance more than once
double power = MathUtil.clamp(output, LiftConstants.backwardsMotorSpeed, LiftConstants.motorSpeed); | ||
double clampedError = MathUtil.clamp(error, LiftConstants.backwardsMotorSpeed, LiftConstants.motorSpeed); | ||
|
||
double left = DriveTrain.getInstance().getPitch() > 0 ? power + clampedError : power; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would store pitch in a variable so that we only read it once per execution
runLeftUp(left); | ||
runRightUp(right); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we need to replace runLeftUp with runLeft and allow it to go up or down from that function, otherwise the PID can only run the motor up
* @param ElevatorSetpoints - desired setpoint | ||
*/ | ||
public void setSetpoint(double setpoint) { | ||
verticalController.setSetpoint(MathUtil.clamp(setpoint, 0, LiftConstants.maxExtension)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
verticalController.setSetpoint(MathUtil.clamp(setpoint, 0, LiftConstants.maxExtension)); | |
verticalController.setSetpoint(MathUtil.clamp(setpoint, LiftConstants.minExtension, LiftConstants.maxExtension)); |
/** | ||
* Returns the position of the left lift encoder. | ||
* | ||
* @return double - current encoder position |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* @return double - current encoder position | |
* @return current encoder position |
you don't need to mention the data type in javadoc, this is handled automatically
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, I would wait to merge until PID is tuned though
Pull Request
Issue Number
Closes #128
Comments