First tinkering iteration, missing some stuff
This commit is contained in:
@@ -0,0 +1,6 @@
|
||||
package frc.robot.constants;
|
||||
|
||||
public class CompetitionConstants {
|
||||
// THIS SHOULD BE FALSE DURING COMPETITION PLAY
|
||||
public static final boolean logToNetworkTables = true;
|
||||
}
|
||||
62
src/main/java/frc/robot/constants/DrivetrainConstants.java
Normal file
62
src/main/java/frc/robot/constants/DrivetrainConstants.java
Normal file
@@ -0,0 +1,62 @@
|
||||
package frc.robot.constants;
|
||||
|
||||
import edu.wpi.first.math.geometry.Translation2d;
|
||||
import edu.wpi.first.math.kinematics.SwerveDriveKinematics;
|
||||
import edu.wpi.first.math.util.Units;
|
||||
|
||||
public class DrivetrainConstants {
|
||||
// TODO Hold over from 2025, adjust?
|
||||
public static final double kMaxSpeedMetersPerSecond = 4.125;
|
||||
public static final double kMaxAngularSpeed = 2 * Math.PI;
|
||||
|
||||
// TODO Replace zeros with real numbers
|
||||
public static final double kTrackWidth = Units.inchesToMeters(0);
|
||||
public static final double kWheelBase = Units.inchesToMeters(0);
|
||||
|
||||
// TODO Replace zeros with real numbers
|
||||
// These values should be determinable by writing the magnetic encoder output
|
||||
// to the dashboard, and manually aligning all wheels such that the bevel gears
|
||||
// on the side of the wheel all face left. Some known straight edge (like 1x1 or similar)
|
||||
// should be used as the alignment medium. If done correctly, and the modules aren't disassembled,
|
||||
// then these values should work throughout the season the first time they are set.
|
||||
public static final double kFrontLeftMagEncoderOffset = 0;
|
||||
public static final double kFrontRightMagEncoderOffset = 0;
|
||||
public static final double kRearLeftMagEncoderOffset = 0;
|
||||
public static final double kRearRightMagEncoderOffset = 0;
|
||||
|
||||
// Kraken CAN IDs
|
||||
// TODO Real CAN IDs
|
||||
public static final int kFrontLeftDrivingCANID = 0;
|
||||
public static final int kFrontRightDrivingCANID = 0;
|
||||
public static final int kRearLeftDrivingCANID = 0;
|
||||
public static final int kRearRightDrivingCANID = 0;
|
||||
|
||||
// SparkMAX CAN IDs
|
||||
// TODO Real CAN IDs
|
||||
public static final int kFrontLeftTurningCANID = 0;
|
||||
public static final int kFrontRightTurningCANID = 0;
|
||||
public static final int kRearLeftTurningCANID = 0;
|
||||
public static final int kRearRightTurningCANID = 0;
|
||||
|
||||
// Analog Encoder Input Ports
|
||||
// TODO Real Port IDs
|
||||
public static final int kFrontLeftAnalogInPort = 0;
|
||||
public static final int kFrontRightAnalogInPort = 0;
|
||||
public static final int kRearLeftAnalogInPort = 0;
|
||||
public static final int kRearRightAnalogInPort = 0;
|
||||
|
||||
public static final boolean kGyroReversed = true;
|
||||
|
||||
// TODO Hold over from 2025, adjust?
|
||||
public static final double kHeadingP = .1;
|
||||
public static final double kXTranslationP = .5;
|
||||
public static final double kYTranslationP = .5;
|
||||
|
||||
// YOU SHOULDN'T NEED TO CHANGE ANYTHING BELOW THIS LINE UNLESS YOU'RE ADDING A NEW CONFIGURATION ITEM
|
||||
public static final SwerveDriveKinematics kDriveKinematics = new SwerveDriveKinematics(
|
||||
new Translation2d(kWheelBase / 2, kTrackWidth / 2),
|
||||
new Translation2d(kWheelBase / 2, -kTrackWidth / 2),
|
||||
new Translation2d(-kWheelBase / 2, kTrackWidth / 2),
|
||||
new Translation2d(-kWheelBase / 2, -kTrackWidth / 2)
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
package frc.robot.constants;
|
||||
|
||||
public class KrakenMotorConstants {
|
||||
public static final double kFreeSpeedRPM = 6000;
|
||||
}
|
||||
102
src/main/java/frc/robot/constants/ModuleConstants.java
Normal file
102
src/main/java/frc/robot/constants/ModuleConstants.java
Normal file
@@ -0,0 +1,102 @@
|
||||
package frc.robot.constants;
|
||||
|
||||
import com.ctre.phoenix6.configs.AudioConfigs;
|
||||
import com.ctre.phoenix6.configs.CurrentLimitsConfigs;
|
||||
import com.ctre.phoenix6.configs.FeedbackConfigs;
|
||||
import com.ctre.phoenix6.configs.MotorOutputConfigs;
|
||||
import com.ctre.phoenix6.configs.Slot0Configs;
|
||||
import com.ctre.phoenix6.signals.InvertedValue;
|
||||
import com.ctre.phoenix6.signals.NeutralModeValue;
|
||||
import com.revrobotics.spark.FeedbackSensor;
|
||||
import com.revrobotics.spark.config.SparkMaxConfig;
|
||||
import com.revrobotics.spark.config.SparkBaseConfig.IdleMode;
|
||||
|
||||
import edu.wpi.first.math.util.Units;
|
||||
|
||||
public class ModuleConstants {
|
||||
// DRIVING MOTOR CONFIG (Kraken)
|
||||
// TODO Replace with something other than 0
|
||||
public static final double kDrivingMotorReduction = 0;
|
||||
|
||||
public static final double kDrivingMotorFeedSpeedRPS = KrakenMotorConstants.kFreeSpeedRPM / 60;
|
||||
public static final double kWheelDiameterMeters = Units.inchesToMeters(4);
|
||||
public static final double kWheelCircumferenceMeters = kWheelDiameterMeters * Math.PI;
|
||||
public static final double kDriveWheelFreeSpeedRPS = (kDrivingMotorFeedSpeedRPS * kWheelCircumferenceMeters) /
|
||||
kDrivingMotorReduction;
|
||||
public static final double kDrivingFactor = kWheelDiameterMeters * Math.PI / kDrivingMotorReduction;
|
||||
public static final double kDrivingVelocityFeedForward = 1 / kDriveWheelFreeSpeedRPS;
|
||||
|
||||
// TODO Hold over from 2025, adjust?
|
||||
public static final double kDriveP = .04;
|
||||
public static final double kDriveI = 0;
|
||||
public static final double kDriveD = 0;
|
||||
public static final double kDriveS = 0;
|
||||
public static final double kDriveV = kDrivingVelocityFeedForward;
|
||||
public static final double kDriveA = 0;
|
||||
|
||||
// TODO Hold over from 2025, adjust?
|
||||
public static final int kDriveMotorStatorCurrentLimit = 100;
|
||||
public static final int kDriveMotorSupplyCurrentLimit = 65;
|
||||
|
||||
// TODO Hold over from 2025, adjust?
|
||||
public static final InvertedValue kDriveInversionState = InvertedValue.Clockwise_Positive;
|
||||
public static final NeutralModeValue kDriveIdleMode = NeutralModeValue.Brake;
|
||||
|
||||
// TURNING MOTOR CONFIG (NEO)
|
||||
|
||||
// TODO Hold over from 2025, adjust?
|
||||
public static final double kTurningMotorReduction = 0;
|
||||
public static final double kTurningFactor = 2 * Math.PI / kTurningMotorReduction;
|
||||
public static final double kTurnP = 1;
|
||||
public static final double kTurnI = 0;
|
||||
public static final double kTurnD = 0;
|
||||
|
||||
public static final int kTurnMotorCurrentLimit = 20;
|
||||
|
||||
public static final IdleMode kTurnIdleMode = IdleMode.kBrake;
|
||||
|
||||
// YOU SHOULDN'T NEED TO CHANGE ANYTHING BELOW THIS LINE UNLESS YOU'RE ADDING A CONFIGURATION ITEM
|
||||
|
||||
public static final SparkMaxConfig turningConfig = new SparkMaxConfig();
|
||||
|
||||
public static final FeedbackConfigs kDriveFeedConfig = new FeedbackConfigs();
|
||||
public static final CurrentLimitsConfigs kDriveCurrentLimitConfig = new CurrentLimitsConfigs();
|
||||
public static final MotorOutputConfigs kDriveMotorConfig = new MotorOutputConfigs();
|
||||
public static final AudioConfigs kAudioConfig = new AudioConfigs();
|
||||
public static final Slot0Configs kDriveSlot0Config = new Slot0Configs();
|
||||
|
||||
static {
|
||||
kDriveFeedConfig.SensorToMechanismRatio = kDrivingMotorReduction;
|
||||
|
||||
kDriveCurrentLimitConfig.StatorCurrentLimitEnable = true;
|
||||
kDriveCurrentLimitConfig.SupplyCurrentLimitEnable = true;
|
||||
kDriveCurrentLimitConfig.StatorCurrentLimit = kDriveMotorStatorCurrentLimit;
|
||||
kDriveCurrentLimitConfig.SupplyCurrentLimit = kDriveMotorSupplyCurrentLimit;
|
||||
|
||||
kDriveMotorConfig.Inverted = kDriveInversionState;
|
||||
kDriveMotorConfig.NeutralMode = kDriveIdleMode;
|
||||
|
||||
kAudioConfig.AllowMusicDurDisable = true;
|
||||
|
||||
kDriveSlot0Config.kP = kDriveP;
|
||||
kDriveSlot0Config.kI = kDriveI;
|
||||
kDriveSlot0Config.kD = kDriveD;
|
||||
kDriveSlot0Config.kS = kDriveS;
|
||||
kDriveSlot0Config.kV = kDriveV;
|
||||
kDriveSlot0Config.kA = kDriveA;
|
||||
|
||||
turningConfig
|
||||
.idleMode(kTurnIdleMode)
|
||||
.smartCurrentLimit(kTurnMotorCurrentLimit);
|
||||
turningConfig.encoder
|
||||
.inverted(true)
|
||||
.positionConversionFactor(kTurningFactor)
|
||||
.velocityConversionFactor(kTurningFactor / 60.0);
|
||||
turningConfig.closedLoop
|
||||
.feedbackSensor(FeedbackSensor.kPrimaryEncoder)
|
||||
.pid(kTurnP, kTurnI, kTurnD)
|
||||
.outputRange(-1, 1)
|
||||
.positionWrappingEnabled(true)
|
||||
.positionWrappingInputRange(0, 2 * Math.PI);
|
||||
}
|
||||
}
|
||||
0
src/main/java/frc/robot/constants/OIConstants.java
Normal file
0
src/main/java/frc/robot/constants/OIConstants.java
Normal file
Reference in New Issue
Block a user