-
Notifications
You must be signed in to change notification settings - Fork 13
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
Created Climb Subsystem #15
Conversation
Created Climb Subsystem
Adding PID to climb, changed to CANSparkFlex
i fixed it :DDDD (bugfixing lol)
@Yumnah2 - need to fix spotlessJavaCheck failures. |
private final SparkAbsoluteEncoder encoderLeft; | ||
private final SparkAbsoluteEncoder encoderRight; |
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.
Should delete these, as the absolute encoder is only useful for measuring less than a single turn. Assuming climb rotates more than one turn, the RelativeEncoder
returned from motorLeft.getEncoder()
is what will need to be used.
motorLeftPIDController.setFeedbackDevice(encoderLeft); | ||
motorRightPIDController.setFeedbackDevice(encoderRight); | ||
|
||
//motor configuration |
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.
Need to also reset to factory default, set inverted mode (or not), set current limits, and burn configuration to flash so it persists across power loss. See https://github.com/robototes/ChargedUp2023/blob/f25191718390d11df9ddda789a0f0d5c35686734/src/main/java/frc/team2412/robot/subsystems/IntakeSubsystem.java#L124 for an example
} | ||
|
||
public void setMotorDown() { | ||
setMotor(-RETRACT_SPEED); |
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.
RETRACT_SPEED
is already defined as negative above, so shouldn't be inverted again here.
public void setMotorUp() { | ||
setMotor(EXTEND_SPEED); | ||
} |
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.
FYI that when climbing at the edges (where the chain will be much higher on one side of the robot than the other), the left & right climb motors may need to go up to different heights. Fine to assume climbing in the middle with both sides going to the same level, but the controls may need to be more complex later to handle cases where left & right sides need to go up to different heights.
motorRight.set(speed); | ||
} | ||
|
||
public void stopArm() { |
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.
Rename for climb. Maybe just stop()
@@ -0,0 +1,5 @@ | |||
package motorRight; | |||
|
|||
public class getAbsoluteEncoder { |
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.
Delete extraneous file
public void climb(double rotations) { | ||
motorLeftPIDController.setReference(rotations, ControlType.kPosition); | ||
motorRightPIDController.setReference(rotations, ControlType.kPosition); | ||
} |
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'm not sure what happens when using both the built-in PID controller (by setting the reference value here) and also setting a raw power (the .set()
commands above). Having the ability to specify a raw power when retracting the climb arms has been useful in the past. But for extension, it'd likely be better to just use .setReference()
so the units are in "amount being extended" instead of "speed of extension".
|
||
//calculate height climbed | ||
//reset encoder to 0 if reset == true | ||
public void resetEncoder(boolean reset) { |
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.
What's the intented purpose of the reset
parameter here? Could omit it and only call resetEncoder()
when the encoder needs to be reset.
encoderLeft.setPositionConversionFactor(0); | ||
encoderRight.setPositionConversionFactor(0); |
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 this factor is multiplied by the raw value from the encoder (docs), this will make the encoder always return a position of 0, even after moving.
no more climb :C |
Created Climb Subsystem