|
10 | 10 |
|
11 | 11 | import com.ctre.phoenix6.configs.CANcoderConfiguration; |
12 | 12 | import com.ctre.phoenix6.configs.TalonFXConfiguration; |
| 13 | +import com.ctre.phoenix6.signals.GravityTypeValue; |
13 | 14 | import com.ctre.phoenix6.signals.InvertedValue; |
14 | 15 | import com.ctre.phoenix6.signals.NeutralModeValue; |
15 | 16 | import com.ctre.phoenix6.signals.SensorDirectionValue; |
| 17 | +import com.ctre.phoenix6.signals.StaticFeedforwardSignValue; |
16 | 18 | import com.frcteam3255.components.swerve.SN_SwerveConstants; |
17 | 19 | import com.pathplanner.lib.config.ModuleConfig; |
18 | 20 | import com.pathplanner.lib.config.PIDConstants; |
|
34 | 36 | import edu.wpi.first.units.measure.Distance; |
35 | 37 | import edu.wpi.first.units.measure.LinearVelocity; |
36 | 38 | import edu.wpi.first.units.measure.Mass; |
37 | | -import edu.wpi.first.units.Unit; |
| 39 | +import edu.wpi.first.units.measure.Time; |
| 40 | +import edu.wpi.first.units.measure.Voltage; |
38 | 41 | import edu.wpi.first.units.Units; |
39 | 42 | import edu.wpi.first.wpilibj.DriverStation; |
40 | 43 | import edu.wpi.first.wpilibj.DriverStation.Alliance; |
@@ -246,10 +249,75 @@ public static boolean isRedAlliance() { |
246 | 249 | public static class constElevator { |
247 | 250 |
|
248 | 251 | public static final Distance CORAL_L1_HEIGHT = Units.Inches.of(0); |
249 | | - public static final Distance CORAL_L2_HEIGHT = Units.Inches.of(2); |
250 | | - public static final Distance CORAL_L3_HEIGHT = Units.Inches.of(3); |
251 | | - public static final Distance CORAL_L4_HEIGHT = Units.Inches.of(4); |
| 252 | + public static final Distance CORAL_L2_HEIGHT = Units.Inches.of(0); |
| 253 | + public static final Distance CORAL_L3_HEIGHT = Units.Inches.of(0); |
| 254 | + public static final Distance CORAL_L4_HEIGHT = Units.Inches.of(0); |
| 255 | + public static final Distance ALGAE_NET_HEIGHT = Units.Inches.of(0); |
| 256 | + public static final Distance DEADZONE_DISTANCE = Units.Inches.of(0); |
252 | 257 |
|
| 258 | + public static final AngularVelocity ZEROED_VELOCITY = Units.RotationsPerSecond.of(0.2); |
| 259 | + |
| 260 | + public static final Angle MAX_POS = Units.Degrees.of(57); |
| 261 | + public static final Angle MIN_POS = Units.Degrees.of(-37); |
| 262 | + |
| 263 | + public static final Angle ZEROED_MANUAL_POS = Units.Degrees.of(57); |
| 264 | + public static final Angle ZEROED_AUTO_POS = Units.Degrees.of(59); |
| 265 | + |
| 266 | + /** |
| 267 | + * The elapsed time required to consider the motor as zeroed |
| 268 | + */ |
| 269 | + public static final Time ZEROED_TIME = Units.Seconds.of(1); |
| 270 | + |
| 271 | + public static final Voltage ZEROING_VOLTAGE = Units.Volts.of(1); |
| 272 | + |
| 273 | + public static TalonFXConfiguration ELEVATOR_LIFT_CONFIG = new TalonFXConfiguration(); |
| 274 | + public static TalonFXConfiguration ELEVATOR_PIVOT_CONFIG = new TalonFXConfiguration(); |
| 275 | + |
| 276 | + static { |
| 277 | + // elevator motor config |
| 278 | + ELEVATOR_LIFT_CONFIG.MotorOutput.NeutralMode = NeutralModeValue.Brake; |
| 279 | + ELEVATOR_LIFT_CONFIG.MotorOutput.Inverted = InvertedValue.CounterClockwise_Positive; |
| 280 | + ELEVATOR_LIFT_CONFIG.SoftwareLimitSwitch.ForwardSoftLimitEnable = true; |
| 281 | + ELEVATOR_LIFT_CONFIG.SoftwareLimitSwitch.ForwardSoftLimitThreshold = Units.Inches.of(62).in(Units.Meters); |
| 282 | + ELEVATOR_LIFT_CONFIG.SoftwareLimitSwitch.ReverseSoftLimitEnable = true; |
| 283 | + ELEVATOR_LIFT_CONFIG.SoftwareLimitSwitch.ReverseSoftLimitThreshold = Units.Inches.of(0).in(Units.Meters); |
| 284 | + ELEVATOR_LIFT_CONFIG.Slot0.GravityType = GravityTypeValue.Elevator_Static; |
| 285 | + ELEVATOR_LIFT_CONFIG.Feedback.SensorToMechanismRatio = 0.876; |
| 286 | + ELEVATOR_LIFT_CONFIG.MotionMagic.MotionMagicCruiseVelocity = 0; |
| 287 | + ELEVATOR_LIFT_CONFIG.MotionMagic.MotionMagicAcceleration = 0; |
| 288 | + ELEVATOR_LIFT_CONFIG.MotionMagic.MotionMagicExpo_kV = 0.04; |
| 289 | + ELEVATOR_LIFT_CONFIG.MotionMagic.MotionMagicExpo_kA = 0.005; |
| 290 | + ELEVATOR_LIFT_CONFIG.CurrentLimits.SupplyCurrentLimitEnable = true; |
| 291 | + ELEVATOR_LIFT_CONFIG.CurrentLimits.SupplyCurrentLowerLimit = 30; |
| 292 | + ELEVATOR_LIFT_CONFIG.CurrentLimits.SupplyCurrentLimit = 60; |
| 293 | + ELEVATOR_LIFT_CONFIG.CurrentLimits.SupplyCurrentLowerTime = 1; |
| 294 | + |
| 295 | + // elevator pivot motor config |
| 296 | + ELEVATOR_PIVOT_CONFIG.MotorOutput.NeutralMode = NeutralModeValue.Brake; |
| 297 | + ELEVATOR_PIVOT_CONFIG.MotorOutput.Inverted = InvertedValue.CounterClockwise_Positive; |
| 298 | + |
| 299 | + ELEVATOR_PIVOT_CONFIG.SoftwareLimitSwitch.ForwardSoftLimitEnable = true; |
| 300 | + ELEVATOR_PIVOT_CONFIG.SoftwareLimitSwitch.ForwardSoftLimitThreshold = Units.Rotations.of(57) |
| 301 | + .in(Units.Degrees); |
| 302 | + ELEVATOR_PIVOT_CONFIG.SoftwareLimitSwitch.ReverseSoftLimitEnable = true; |
| 303 | + ELEVATOR_PIVOT_CONFIG.SoftwareLimitSwitch.ReverseSoftLimitThreshold = Units.Rotations.of(-37) |
| 304 | + .in(Units.Degrees); |
| 305 | + |
| 306 | + ELEVATOR_PIVOT_CONFIG.Feedback.SensorToMechanismRatio = 1000 / 27;// just like intake pivot, we still need |
| 307 | + // to get the ratio from fab |
| 308 | + |
| 309 | + ELEVATOR_PIVOT_CONFIG.Slot0.GravityType = GravityTypeValue.Arm_Cosine; |
| 310 | + ELEVATOR_PIVOT_CONFIG.Slot0.StaticFeedforwardSign = StaticFeedforwardSignValue.UseClosedLoopSign; |
| 311 | + |
| 312 | + ELEVATOR_PIVOT_CONFIG.MotionMagic.MotionMagicCruiseVelocity = 9999; |
| 313 | + ELEVATOR_PIVOT_CONFIG.MotionMagic.MotionMagicAcceleration = 9999; |
| 314 | + |
| 315 | + ELEVATOR_PIVOT_CONFIG.CurrentLimits.SupplyCurrentLimitEnable = true; |
| 316 | + ELEVATOR_PIVOT_CONFIG.CurrentLimits.SupplyCurrentLowerLimit = 30; |
| 317 | + ELEVATOR_PIVOT_CONFIG.CurrentLimits.SupplyCurrentLimit = 45; |
| 318 | + ELEVATOR_PIVOT_CONFIG.CurrentLimits.SupplyCurrentLowerTime = 0.5; |
| 319 | + |
| 320 | + } |
253 | 321 | } |
254 | 322 |
|
255 | 323 | public static class constClimber { |
|
0 commit comments