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

Climber Positions API + Rickaboot #148

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open

Climber Positions API + Rickaboot #148

wants to merge 6 commits into from

Conversation

ZachOrr
Copy link
Contributor

@ZachOrr ZachOrr commented Feb 21, 2022

This PR attempts to abstract the idea of moving the climber so we don't have to talk voltages or speeds directly. Instead, commands that want to move the climber call moveToSetpoint with a setpoint to move the climber automatically. Right now - only rickaboot and start are supported. Internally, the climber manages moving itself to the proper position either via the string pot or encoders.

Copy link
Contributor

@Nicholas-Stokes Nicholas-Stokes left a comment

Choose a reason for hiding this comment

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

I feel like the encoders are being neglected here, I guess this is really just setting up more advanced features to use in the future, maybe this name should be changed since we aren't really going to positions, just setting up dirty work.

return leftMotor.getSelectedSensorPosition();
/** Public API */

private boolean isStringPotConnected() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Our voltage without the stringpot might still be a value

src/main/java/frc/robot/subsystems/Climber.java Outdated Show resolved Hide resolved
@Nicholas-Stokes
Copy link
Contributor

I stayed up last night thinking about this, and I feel like we want the String Pot to be a luxury or periphery option instead of being our main focus for setting limits and positions. I feel like this is jumping through hoops in case the string pot breaks, where we should be able to write this so that it shouldn't matter if it breaks, it would just be nice to have. I think we need to step back and think about this in case we start merging a bunch of unnecessary code, i.e., we shouldn't have to rush this, we have three weeks until Livonia.

@ZachOrr ZachOrr reopened this Feb 22, 2022
@ZachOrr ZachOrr changed the title Climber Positions [WIP] Climber Positions Feb 22, 2022
@ZachOrr ZachOrr force-pushed the zorr/climber-api branch 3 times, most recently from a3de4f2 to 06a638b Compare March 9, 2022 19:15
Comment on lines 27 to 31
// private static final double MAX_SPEED = 0.70;
private static final double MAX_SPEED = 0.10;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

  • Test this low, merge this higher

private final AnalogInput stringPot = new AnalogInput(Constants.CLIMBER_STRING_POT_ID);
private final TalonFX leftMotor = new TalonFX(Constants.CLIMBER_LEFT_MOTOR_ID);
private final TalonFX rightMotor = new TalonFX(Constants.CLIMBER_RIGHT_MOTOR_ID);

private static final double STRING_POT_UPPER_SOFT_LIMIT = 3.0;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

  • Find our string pot upper limit - probably via driving with a joystick

private static final double STRING_POT_UPPER_SOFT_LIMIT = 3.0;
private Double stringPotStartingVoltage;
private double stringPotVoltage;
private PIDController stringPotPIDController = new PIDController(0.1, 0.0, 0.0);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

  • Be careful with this value - needs to be tuned. If anything, we might want to start this lower and start moving up as we go.

private double stringPotVoltage;
private PIDController stringPotPIDController = new PIDController(0.1, 0.0, 0.0);

private static final double ENCODER_UPPER_SOFT_LIMIT = 3000;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

  • Find our upper limit here (pull value for the same location we pull the value for the string pot)

private PIDController stringPotPIDController = new PIDController(0.1, 0.0, 0.0);

private static final double ENCODER_UPPER_SOFT_LIMIT = 3000;
private static final double ENCODER_LOWER_SOFT_LIMIT = 0; // Zero == where the motor boots
Copy link
Contributor Author

Choose a reason for hiding this comment

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

  • As mentioned, our lower limits will almost certainly be lower than this due to our "pull up".

if (setpointPosition.sensor == ClimberSensor.ENCODER) {
// If we're using the encoders - set the internal encoder PID
// to move us to our position
setPosition(setpointPosition.value);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

  • We need to have our range check here

// attempt to
// hold the climber at the setpoint. The brake mode motors do that for us.
if (stringPotPIDController.atSetpoint()) {
// TODO: Hold at position?
Copy link
Contributor Author

Choose a reason for hiding this comment

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

  • TODO? Worth talking with someone else to figure out if this is how we want this to work

stringPotStartingVoltage,
ClimberSensor.STRING_POT
);
case RICKABOOT: // TODO: Figure out Rickaboot string pot voltage
Copy link
Contributor Author

Choose a reason for hiding this comment

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

  • TODO

0.0,
ClimberSensor.ENCODER
);
case RICKABOOT: // TODO: Figure out Rickaboot encoder value
Copy link
Contributor Author

Choose a reason for hiding this comment

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

  • TODO

@ZachOrr ZachOrr changed the title [WIP] Climber Positions Climber Positions API + Rickaboot Mar 9, 2022
@ZachOrr ZachOrr force-pushed the zorr/climber-api branch 2 times, most recently from ad5b5c0 to bf69584 Compare March 9, 2022 20:07
@ZachOrr ZachOrr force-pushed the zorr/climber-api branch from bf69584 to f051926 Compare March 9, 2022 22:40
Nicholas-Stokes and others added 2 commits March 9, 2022 21:52
Manual is still not working, PID looks good.
Comment on lines +167 to +169
// NOTE: This is temp, and should not be checked in to main
operatorRightBumper.whenPressed(() -> climber.moveToSetpoint(ClimberSetpoint.RICKABOOT));
operatorRightBumper.whenReleased(() -> climber.moveToSetpoint(ClimberSetpoint.START));
Copy link
Contributor Author

Choose a reason for hiding this comment

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

  • Back this out before merge

private static final double STRING_POT_LOWER_SOFT_LIMIT = 0.1;

private Double stringPotStartingVoltage;
private PIDController stringPotPIDController = new PIDController(6.0, 0.0, 0.0);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

  • This controller needs to be tuned some more. My guess is way more P + a bunch of D.

Comment on lines +109 to +110
// configuration.nominalOutputForward = 0.1;
// configuration.nominalOutputReverse = 0.1;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

  • Temp removed the nominal outputs while we're tuning the PID. I want to see what happens if we run without them. We might need them back in through for our position hold.


output = Math.copySign(Math.min(Math.abs(output), MAX_SPEED), output);

SmartDashboard.putNumber("Climber Output", output);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

  • We can remove this once we have our PIDs tuned.

);
case RICKABOOT:
return new ClimberPosition(
148500, // TODO: This needs to be fixed...
Copy link
Contributor Author

Choose a reason for hiding this comment

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

  • This needs to be re-configured with the climber at it's new start location (~0.9something v). We were also having issues last night where we weren't getting close to the encoder values we expected. Need to figure out why that is.

}
}

// TODO: Make private - provide some other method here to move via joystick control
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We're gonna merge with this TODO - since we're not going to convert the climber joystick drive code right this moment.

ZachOrr and others added 2 commits March 10, 2022 12:52
The logic that we had currently had the boolean causing a stop and conflicting our motors. By removing this stop, and moving it into the actual periodicMoveToSetpoint, we can use the joystick and the PID. Also, adjusted the volatage we get when the stringpot is disconnected to be accurate.
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.

2 participants