-
Notifications
You must be signed in to change notification settings - Fork 0
ishan puh lease tell me wtf is wrong with this #171
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
Changes from 3 commits
7d66fde
8945799
acbc642
b1d162f
12aa7ec
7452cf1
c445f3d
2cbdf35
626e139
3d753a5
9726262
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,8 +8,8 @@ | |
|
|
||
| /** Add your docs here. */ | ||
| public class ElevatorConstants { | ||
| public static final int ELEVATOR_LEADER_MOTOR_ID = 0; | ||
| public static final int ELEVATOR_FOLLOWER_MOTOR_ID = 62; | ||
| public static final int ELEVATOR_LEADER_MOTOR_ID = 0-9; // 0, changed for testing just follower | ||
| public static final int ELEVATOR_FOLLOWER_MOTOR_ID = 34; | ||
|
|
||
| public static final double ELEVATOR_P = 10; | ||
| public static final double ELEVATOR_I = 0; | ||
|
|
@@ -20,19 +20,20 @@ public class ElevatorConstants { | |
| public static final double ELEVATOR_G = -0.35; | ||
|
|
||
| public static final double DRUM_RADIUS = 1; | ||
| public static final double ELEVATOR_GEAR_RATIO = 4.8; // 29 | ||
| public static final double ELEVATOR_GEAR_RATIO = 4.8; // 4.8 | ||
| public static final double ELEVATOR_CARRIAGE_MASS = 10; | ||
| public static final double MIN_HEIGHT = 0; | ||
| public static final double MAX_HEIGHT = 3; | ||
| public static final double INCLINE_ANGLE_RADIANS = Units.degreesToRadians(8); | ||
| public static final boolean SIMULATE_GRAVITY = true; | ||
|
|
||
| public static final double STATOR_CURRENT_LIMIT = 100; // 100 | ||
| public static final double STATOR_CURRENT_LIMIT = 200; // 100 | ||
| public static final double SUPPLY_CURRENT_LIMIT = 0; | ||
| public static final double STATOR_CURRENT_THRESHOLD = 10000000; // will tune later | ||
|
||
| public static final boolean STATOR_CURRENT_LIMIT_ENABLE = true; | ||
| public static final boolean SUPPLY_CURRENT_LIMIT_ENABLE = false; | ||
|
|
||
| public static final double MOTION_MAGIC_MAX_ACCELERATION = 80; // 160 | ||
| public static final double MOTION_MAGIC_MAX_ACCELERATION = 160; // 160 | ||
| public static final double MOTION_MAGIC_CRUISE_VELOCITY = 100; // 100 | ||
|
|
||
| public static final double ELEVATOR_ERROR_TOLERANCE = 0.08; | ||
|
|
@@ -46,10 +47,10 @@ public class ElevatorConstants { | |
| // Elevator setpoints | ||
| public enum ElevatorSetpoints { | ||
| L1(-2.50), | ||
| L2(-2.8 + .00004829), | ||
| L2(-2.8 + .0000000000000000000004829), // Easter egg lol | ||
| L3(-4.517), | ||
| L4(-7.55), // -9.2 | ||
| FEEDER(-0.3); | ||
| L4(-7.55), | ||
| FEEDER(-0.2); | ||
|
|
||
| private final double position; | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,6 +11,7 @@ | |
| import com.ctre.phoenix6.controls.Follower; | ||
| import com.ctre.phoenix6.controls.MotionMagicTorqueCurrentFOC; | ||
| import com.ctre.phoenix6.controls.MotionMagicVoltage; | ||
| import com.ctre.phoenix6.controls.NeutralOut; | ||
| import com.ctre.phoenix6.controls.TorqueCurrentFOC; | ||
| import com.ctre.phoenix6.hardware.TalonFX; | ||
| import com.ctre.phoenix6.signals.GravityTypeValue; | ||
|
|
@@ -33,7 +34,6 @@ public class PhysicalElevator implements ElevatorInterface { | |
|
|
||
| private final MotionMagicTorqueCurrentFOC mmTorqueRequest = new MotionMagicTorqueCurrentFOC(0.0); | ||
| private final TorqueCurrentFOC currentOut = new TorqueCurrentFOC(0.0); | ||
|
|
||
| private final StatusSignal<Angle> leaderPosition; | ||
| private final StatusSignal<Angle> followerPosition; | ||
| private final StatusSignal<Voltage> leaderAppliedVoltage; | ||
|
|
@@ -87,7 +87,6 @@ public PhysicalElevator() { | |
|
|
||
| // Use Follower control | ||
| followerMotor.setControl(follower); | ||
| elevatorConfig.Feedback.SensorToMechanismRatio = 19.2; | ||
| followerMotor.getConfigurator().apply(elevatorConfig); | ||
|
|
||
| leaderPosition = leaderMotor.getPosition(); | ||
|
|
@@ -123,8 +122,8 @@ public PhysicalElevator() { | |
| leaderVelocity, | ||
| followerTemp, | ||
| leaderTemp); | ||
| leaderMotor.optimizeBusUtilization(); | ||
| followerMotor.optimizeBusUtilization(); | ||
| leaderMotor.optimizeBusUtilization(); | ||
| } | ||
|
|
||
| @Override | ||
|
|
@@ -145,7 +144,7 @@ public void updateInputs(ElevatorInputs inputs) { | |
| inputs.leaderMotorPosition = leaderPosition.getValueAsDouble(); | ||
| inputs.leaderMotorVoltage = leaderAppliedVoltage.getValueAsDouble(); | ||
| inputs.leaderDutyCycle = leaderDutyCycle.getValueAsDouble(); | ||
| inputs.followerMotorPosition = followerPosition.getValueAsDouble() / 4.0; | ||
| inputs.followerMotorPosition = followerPosition.getValueAsDouble(); | ||
| inputs.followerMotorVoltage = followerAppliedVoltage.getValueAsDouble(); | ||
| inputs.followerDutyCycle = followerDutyCycle.getValueAsDouble(); | ||
| inputs.desiredPosition = elevatorReference.getValueAsDouble(); | ||
|
|
@@ -167,13 +166,12 @@ public double getElevatorPosition() { | |
| @Override | ||
| public void setElevatorPosition(double position) { | ||
| leaderMotor.setControl(mmPositionRequest.withPosition(position)); | ||
| followerMotor.setControl(mmPositionRequest.withPosition(-position)); | ||
| } | ||
|
|
||
| @Override | ||
| public void hardStop() { | ||
| if (leaderPosition.getValueAsDouble() == 0) { | ||
| leaderMotor.setControl(mmPositionRequest.withPosition(-0.1)); | ||
| if (leaderStatorCurrent.getValueAsDouble() > ElevatorConstants.STATOR_CURRENT_THRESHOLD) { | ||
| leaderMotor.setControl(mmPositionRequest.withPosition(0.001)); | ||
|
||
| } | ||
| } | ||
|
|
||
|
|
||
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.
why was this doubled
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.
When limits were enabled i forgot to turn them off and i wasnt sure how high the threshold was gonna be so i was gonna tune it and i wanted there to be a negligible existing limit
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.
Ok... but why is it doubled. Like what's the point of a threshold if you're going to make the existing limit negligible? At that point the threshold becomes the actual limit, but with a delay.
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.
Also, you doubled acceleration

Why?
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.
Ill revert the limit 😔 i HALVED the acceleration cuz the elevator was too fast
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 see ur right
but how was the elevator too fast? ...Ig u slowed it down for testing which is chill