Skip to content
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

Merged
merged 23 commits into from
Mar 23, 2024
Merged

128 make lift use pids #129

merged 23 commits into from
Mar 23, 2024

Conversation

Griffin9881
Copy link
Contributor

Pull Request


Issue Number

Closes #128

Comments

@Griffin9881 Griffin9881 self-assigned this Mar 16, 2024
@Griffin9881 Griffin9881 linked an issue Mar 16, 2024 that may be closed by this pull request

rightBumper.and(leftBumper.negate()).whileTrue(new RightLiftUpCommand());
rightTrigger.and(leftTrigger.negate()).whileTrue(new RightLiftDownCommand());
rightBumper.and(leftBumper.negate()).whileTrue(new LiftUpCommand());
Copy link
Member

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

Suggested change
rightBumper.and(leftBumper.negate()).whileTrue(new LiftUpCommand());
rightBumper.whileTrue(new LiftUpCommand());

}

@Override
public void execute() {
lift.runLeftUp();
lift.runRightUp();
lift.enable();
Copy link
Member

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());
Copy link
Member

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;
Copy link
Member

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

Comment on lines 194 to 195
runLeftUp(left);
runRightUp(right);
Copy link
Member

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));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* @return double - current encoder position
* @return current encoder position

you don't need to mention the data type in javadoc, this is handled automatically

src/main/java/frc/robot/subsystems/Lift.java Show resolved Hide resolved
src/main/java/frc/robot/subsystems/Lift.java Outdated Show resolved Hide resolved
reediculous456
reediculous456 previously approved these changes Mar 18, 2024
Copy link
Member

@reediculous456 reediculous456 left a 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

reediculous456
reediculous456 previously approved these changes Mar 23, 2024
@reediculous456 reediculous456 merged commit 6cfaa8c into main Mar 23, 2024
1 check passed
@reediculous456 reediculous456 deleted the 128-make-lift-use-pids branch March 23, 2024 19:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make Lift Use PIDs
2 participants