Skip to content
This repository has been archived by the owner on Apr 20, 2024. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
…gamma into elevator-ryan
  • Loading branch information
jordanjcoderman committed Feb 10, 2024
2 parents 5b953dc + 2cad3f8 commit f2b61fb
Show file tree
Hide file tree
Showing 3 changed files with 166 additions and 4 deletions.
159 changes: 159 additions & 0 deletions src/main/java/frc/robot/config/CompConfig.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
// Copyright (c) FIRST and other WPILib contributors.
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.

package frc.robot.config;

import com.ctre.phoenix6.configs.CurrentLimitsConfigs;
import com.ctre.phoenix6.configs.FeedbackConfigs;
import com.ctre.phoenix6.configs.MotionMagicConfigs;
import com.ctre.phoenix6.configs.MotorOutputConfigs;
import com.ctre.phoenix6.configs.Slot0Configs;
import com.ctre.phoenix6.configs.Slot1Configs;
import com.ctre.phoenix6.configs.TalonFXConfiguration;
import com.ctre.phoenix6.configs.VoltageConfigs;
import com.ctre.phoenix6.mechanisms.swerve.utility.PhoenixPIDController;
import com.ctre.phoenix6.signals.GravityTypeValue;
import com.ctre.phoenix6.signals.InvertedValue;
import com.ctre.phoenix6.signals.NeutralModeValue;
import edu.wpi.first.math.geometry.Rotation2d;
import frc.robot.config.RobotConfig.ClimberConfig;
import frc.robot.config.RobotConfig.IMUConfig;
import frc.robot.config.RobotConfig.IntakeConfig;
import frc.robot.config.RobotConfig.LightsConfig;
import frc.robot.config.RobotConfig.ShooterConfig;
import frc.robot.config.RobotConfig.ShoulderConfig;
import frc.robot.config.RobotConfig.SwerveConfig;

class CompConfig {
public static final RobotConfig competitionBot =
new RobotConfig(
"competition",
"581CANivore",
new ShooterConfig(
18,
19,
new TalonFXConfiguration()
.withFeedback(new FeedbackConfigs().withSensorToMechanismRatio(1.0 / 1.5))
.withCurrentLimits(new CurrentLimitsConfigs().withSupplyCurrentLimit(120))
.withSlot0(new Slot0Configs().withKP(5.5).withKV(0.0).withKS(13.0))
.withMotorOutput(
new MotorOutputConfigs()
.withNeutralMode(NeutralModeValue.Coast)
.withInverted(InvertedValue.Clockwise_Positive)),
new TalonFXConfiguration()
.withFeedback(new FeedbackConfigs().withSensorToMechanismRatio(1.0 / 1.5))
.withCurrentLimits(new CurrentLimitsConfigs().withSupplyCurrentLimit(120))
.withSlot0(new Slot0Configs().withKP(5).withKV(0.0).withKS(13.0))
.withMotorOutput(
new MotorOutputConfigs()
.withNeutralMode(NeutralModeValue.Coast)
.withInverted(InvertedValue.Clockwise_Positive)),
speakerDistanceToRPM -> {
speakerDistanceToRPM.put(0.0, 4000.0);
speakerDistanceToRPM.put(3.0, 6000.0);
speakerDistanceToRPM.put(4.0, 6500.0);
speakerDistanceToRPM.put(6.0, 7000.0);
},
floorSpotDistanceToRPM -> {
floorSpotDistanceToRPM.put(1.6, 1700.0);
floorSpotDistanceToRPM.put(3.4, 2000.0);
floorSpotDistanceToRPM.put(4.8, 2700.0);
}),
new ClimberConfig(
20,
21,
new TalonFXConfiguration()
.withSlot0(new Slot0Configs().withKP(8))
.withFeedback(new FeedbackConfigs().withSensorToMechanismRatio(17.0 / 1.0))
.withCurrentLimits(new CurrentLimitsConfigs().withStatorCurrentLimit(40))
.withVoltage(
new VoltageConfigs()
.withPeakForwardVoltage(12.0)
.withPeakReverseVoltage(-2.0))),
new ShoulderConfig(
14,
15,
new TalonFXConfiguration()
.withSlot0(
new Slot0Configs()
.withGravityType(GravityTypeValue.Arm_Cosine)
.withKG(0.47)
.withKP(200.0))
.withSlot1(
new Slot1Configs()
.withGravityType(GravityTypeValue.Arm_Cosine)
.withKG(0.47)
.withKP(200.0))
.withMotionMagic(
new MotionMagicConfigs()
.withMotionMagicAcceleration(1.5)
.withMotionMagicCruiseVelocity(2.0)
.withMotionMagicJerk(0))
.withFeedback(
new FeedbackConfigs()
.withSensorToMechanismRatio(
1 / ((12.0 / 50.0) * (20.0 / 84.0) * (12.0 / 72.0))))
.withCurrentLimits(new CurrentLimitsConfigs().withSupplyCurrentLimit(40))
.withMotorOutput(
new MotorOutputConfigs()
.withInverted(InvertedValue.Clockwise_Positive)
.withNeutralMode(NeutralModeValue.Brake)),
new CurrentLimitsConfigs().withSupplyCurrentLimit(40),
-0.05,
10,
Rotation2d.fromDegrees(-14),
4,
Rotation2d.fromDegrees(-13.5),
Rotation2d.fromDegrees(115),
distanceToAngleTolerance -> {
distanceToAngleTolerance.put(0.85, 5.0);
distanceToAngleTolerance.put(8.0, 1.0);
},
speakerDistanceToAngle -> {
speakerDistanceToAngle.put(0.0, 0.0);
speakerDistanceToAngle.put(1.43, 6.0);
speakerDistanceToAngle.put(2.0, 17.0);
speakerDistanceToAngle.put(2.57, 23.0);
speakerDistanceToAngle.put(3.0, 26.0);
speakerDistanceToAngle.put(3.5, 30.0);
speakerDistanceToAngle.put(4.0, 32.0);
speakerDistanceToAngle.put(6.0, 34.0);
},
floorSpotDistanceToAngle -> {
floorSpotDistanceToAngle.put(1.6, 70.0);
floorSpotDistanceToAngle.put(3.4, 40.0);
floorSpotDistanceToAngle.put(4.8, 20.0);
floorSpotDistanceToAngle.put(15.0, 10.0);
}),
new IntakeConfig(
16,
22,
0,
// Top Motor
new TalonFXConfiguration()
.withFeedback(new FeedbackConfigs().withSensorToMechanismRatio(1))
.withCurrentLimits(new CurrentLimitsConfigs().withSupplyCurrentLimit(20))
.withMotorOutput(
new MotorOutputConfigs()
.withInverted(InvertedValue.CounterClockwise_Positive)),
// Bottom Motor
new TalonFXConfiguration()
.withFeedback(new FeedbackConfigs().withSensorToMechanismRatio(1))
.withCurrentLimits(new CurrentLimitsConfigs().withSupplyCurrentLimit(20))
.withMotorOutput(
new MotorOutputConfigs().withInverted(InvertedValue.Clockwise_Positive))),
new SwerveConfig(
new CurrentLimitsConfigs().withStatorCurrentLimit(60),
new CurrentLimitsConfigs().withStatorCurrentLimit(60),
new PhoenixPIDController(12, 0, 0.8),
true),
new IMUConfig(
1,
distanceToAngleTolerance -> {
// TODO: tune distance and angle
distanceToAngleTolerance.put(1.0, 2.5);
distanceToAngleTolerance.put(10.0, 2.5);
}),
new LightsConfig(23));
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@
import frc.robot.config.RobotConfig.ShoulderConfig;
import frc.robot.config.RobotConfig.SwerveConfig;

class RealRobotConfig {
class PracticeConfig {
public static final RobotConfig config =
new RobotConfig(
"spectrum",
"practice",
"581CANivore",
new ShooterConfig(
18,
Expand Down
7 changes: 5 additions & 2 deletions src/main/java/frc/robot/config/RobotConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,13 @@ public record SwerveConfig(

// TODO: Change this to false during events
public static final boolean IS_DEVELOPMENT = true;
private static final String ROBOT_SERIAL_NUMBER = "0322443D"; // TODO: get serial number
private static final String PRACTICE_BOT_SERIAL_NUMBER = "0322443D"; // TODO: get serial number

public static final String SERIAL_NUMBER = System.getenv("serialnum");
public static final boolean IS_PRACTICE_BOT =
SERIAL_NUMBER != null && SERIAL_NUMBER.equals(PRACTICE_BOT_SERIAL_NUMBER);

public static RobotConfig get() {
return RealRobotConfig.config;
return IS_PRACTICE_BOT ? PracticeConfig.config : CompConfig.competitionBot;
}
}

0 comments on commit f2b61fb

Please sign in to comment.