Skip to content
This repository has been archived by the owner on Jan 9, 2025. It is now read-only.

Commit

Permalink
locked in
Browse files Browse the repository at this point in the history
  • Loading branch information
chaoticthegreat committed Nov 7, 2024
1 parent 87e213b commit e29b2d7
Show file tree
Hide file tree
Showing 10 changed files with 113 additions and 81 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

public final class AmpevatorConstants {

public static final int ampevatorID = 62;
public static final int ampevatorID = 47;
public static final int ampevatorBeamBreakID = 0;

public static final TalonFXConfiguration motorConfigs =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

public final class RollerConstants {
/* CAN */
public static final int kRollerMotorID = 33;
public static final int kRollerMotorID = 49;

public static final double kRollerOuttakeVoltage = 12;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

public final class ClimbConstants {

public static final int kLeftClimbMotorID = 18;
public static final int kLeftClimbMotorID = 45;
public static final double gearRatio = 20; // needs to be tuned

public static final double kClimbUpPosition = 150 / 20;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

public final class IntakeConstants {
/* CAN */
public static final int kIntakeMotorID = 33;
public static final int kIntakeMotorID = 46;

public static final double kIntakeIntakeVoltage = 12;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public final class PivotShooterConstants {
public static final double kSubWooferPreset = 3.4 / 138.33; // 3.2
public static final double kFeederPreset = 5.9 / 138.33;

public static final int kPivotMotorID = 60;
public static final int kPivotMotorID = 51;

/* PID */

Expand All @@ -33,7 +33,7 @@ public final class PivotShooterConstants {

/* Misc */
public static final boolean kUseFOC = false;
public static final boolean kUseMotionMagic = true; // idk
public static final boolean kUseMotionMagic = false; // idk
public static final double updateFrequency = 50.0;
public static final int flashConfigRetries = 5;
public static final double kPivotSlamStallCurrent = 50;
Expand All @@ -44,7 +44,7 @@ public final class PivotShooterConstants {
new Slot0Configs()
.withKS(0)
.withKV(0)
.withKP(10)
.withKP(2)
.withKI(0)
.withKD(0)
.withKG(1)
Expand All @@ -54,10 +54,10 @@ public final class PivotShooterConstants {
new MotorOutputConfigs()
.withNeutralMode(NeutralModeValue.Brake)
.withInverted(InvertedValue.Clockwise_Positive))
.withMotionMagic(
new MotionMagicConfigs()
.withMotionMagicAcceleration(400)
.withMotionMagicCruiseVelocity(50))
// .withMotionMagic(
// new MotionMagicConfigs()
// .withMotionMagicAcceleration(400)
// .withMotionMagicCruiseVelocity(50))
.withCurrentLimits(
new CurrentLimitsConfigs()
.withStatorCurrentLimitEnable(true)
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/frc/robot/subsystems/shooter/ShooterConstants.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ public final class ShooterConstants {
public static final boolean kUseFOC = true;
public static final boolean kUseShooterRegenBraking = true;
/* CAN */
public static int kShooterMotorID = 11;
public static int kShooterMotorFollowerID = 23;
public static int kShooterMotorRightID = 43;
public static int kShooterMotorLeftID = 48;
/* PID */
// Shooter
public static MotorOutputConfigs motorOutputConfigs =
Expand All @@ -30,12 +30,12 @@ public final class ShooterConstants {
.withSlot0(
new Slot0Configs()
.withKS(0)
.withKV(0.145) // Original 0.145
.withKV(0.15) // Original 0.145
// .withKA(1.48)// Original 0 only for feedforward, might not
// use
.withKP(0.4)
.withKP(8)
.withKI(0)
.withKD(0))
.withKD(0.1))
// For regenerative braking
// we need to make sure that the backcurrent is below the breaker limit
// P = 2 gives us like 102 amps so that's good enough
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import frc.robot.utils.PhoenixUtil;

public class ShooterIOTalonFX implements ShooterIO {
private final TalonFX shooterMotor = new TalonFX(ShooterConstants.kShooterMotorID);
private final TalonFX shooterMotor = new TalonFX(ShooterConstants.kShooterMotorRightID);
final VelocityVoltage velocityRequest = new VelocityVoltage(0).withSlot(0);
final MotionMagicVelocityVoltage motionMagicRequest =
new MotionMagicVelocityVoltage(0).withSlot(0);
Expand All @@ -29,8 +29,7 @@ public class ShooterIOTalonFX implements ShooterIO {
private final StatusSignal<Double> shooterMotorReferenceSlope =
shooterMotor.getClosedLoopReferenceSlope();

private final TalonFX shooterMotorFollower =
new TalonFX(ShooterConstants.kShooterMotorFollowerID);
private final TalonFX shooterMotorFollower = new TalonFX(ShooterConstants.kShooterMotorLeftID);
final VelocityVoltage velocityRequestFollower = new VelocityVoltage(0).withSlot(0);
final MotionMagicVelocityVoltage motionMagicRequestFollower =
new MotionMagicVelocityVoltage(0).withSlot(0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import com.ctre.phoenix6.signals.NeutralModeValue;

public class SpindexConstants {
public static final int spindexMotorID = 0;
public static final int spindexMotorID = 50;
public static final double spindexMotorVoltage = -7;
public static TalonFXConfiguration spindexMotorConfigs =
new TalonFXConfiguration() // TODO: tune
Expand Down Expand Up @@ -52,6 +52,6 @@ public class SpindexConstants {
.withStatorCurrentLimitEnable(true)
.withStatorCurrentLimit(80));
;
public static int shooterFeederMotorID = 43;
public static int shooterFeederMotorID = 44;
public static double shooterFeederVoltage = 7;
}
147 changes: 90 additions & 57 deletions src/main/java/frc/robot/subsystems/swerve/TunerConstants.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@

package frc.robot.subsystems.swerve;

import com.ctre.phoenix6.configs.CANcoderConfiguration;
import com.ctre.phoenix6.configs.CurrentLimitsConfigs;
import com.ctre.phoenix6.configs.Pigeon2Configuration;
import com.ctre.phoenix6.configs.Slot0Configs;
import com.ctre.phoenix6.configs.TalonFXConfiguration;
import com.ctre.phoenix6.mechanisms.swerve.SwerveDrivetrainConstants;
import com.ctre.phoenix6.mechanisms.swerve.SwerveModule.ClosedLoopOutputType;
import com.ctre.phoenix6.mechanisms.swerve.SwerveModuleConstants;
Expand All @@ -28,7 +32,7 @@ public class TunerConstants {
// When using closed-loop control, the drive motor uses the control
// output type specified by SwerveModuleConstants.DriveMotorClosedLoopOutput
private static final Slot0Configs driveGains =
new Slot0Configs().withKP(.1).withKI(0).withKD(0).withKS(0).withKV(0.12).withKA(0);
new Slot0Configs().withKP(3).withKI(0).withKD(0).withKS(0).withKV(0).withKA(0);

// The closed-loop output type to use for the steer motors;
// This affects the PID/FF gains for the steer motors
Expand All @@ -39,7 +43,24 @@ public class TunerConstants {

// The stator current at which the wheels start to slip;
// This needs to be tuned to your individual robot
private static final double kSlipCurrentA = 75.0;
private static final double kSlipCurrentA = 150.0;

// Initial configs for the drive and steer motors and the CANcoder; these cannot be null.
// Some configs will be overwritten; check the `with*InitialConfigs()` API documentation.
private static final TalonFXConfiguration driveInitialConfigs = new TalonFXConfiguration();
private static final TalonFXConfiguration steerInitialConfigs =
new TalonFXConfiguration()
.withCurrentLimits(
new CurrentLimitsConfigs()
// Swerve azimuth does not require much torque output, so we can set a relatively
// low
// stator current limit to help avoid brownouts without impacting performance.
.withStatorCurrentLimit(60)
.withStatorCurrentLimitEnable(true));
private static final CANcoderConfiguration cancoderInitialConfigs = new CANcoderConfiguration();
// Configs for the Pigeon 2; leave this null to skip applying Pigeon 2 configs
private static final Pigeon2Configuration pigeonConfigs = null;

// Theoretical free speed (m/s) at 12v applied output;
// This needs to be tuned to your individual robot
public static final double kSpeedAt12VoltsMps = 5.96;
Expand All @@ -52,12 +73,11 @@ public class TunerConstants {
private static final double kSteerGearRatio = 21.428571428571427;
private static final double kWheelRadiusInches = 2;

private static final boolean kSteerMotorReversed = true;
private static final boolean kInvertLeftSide = false;
private static final boolean kInvertRightSide = true;

private static final String kCANbusName = "mani";
private static final int kPigeonId = 24;
private static final int kPigeonId = 4;

// These are only used for simulation
private static final double kSteerInertia = 0.00001;
Expand All @@ -67,7 +87,10 @@ public class TunerConstants {
private static final double kDriveFrictionVoltage = 0.25;

private static final SwerveDrivetrainConstants DrivetrainConstants =
new SwerveDrivetrainConstants().withPigeon2Id(kPigeonId).withCANbusName(kCANbusName);
new SwerveDrivetrainConstants()
.withCANbusName(kCANbusName)
.withPigeon2Id(kPigeonId)
.withPigeon2Configs(pigeonConfigs);

private static final SwerveModuleConstantsFactory ConstantCreator =
new SwerveModuleConstantsFactory()
Expand All @@ -86,80 +109,90 @@ public class TunerConstants {
.withDriveFrictionVoltage(kDriveFrictionVoltage)
.withFeedbackSource(SteerFeedbackType.FusedCANcoder)
.withCouplingGearRatio(kCoupleRatio)
.withSteerMotorInverted(kSteerMotorReversed);
.withDriveMotorInitialConfigs(driveInitialConfigs)
.withSteerMotorInitialConfigs(steerInitialConfigs)
.withCANcoderInitialConfigs(cancoderInitialConfigs);

// Front Left
private static final int kFrontLeftDriveMotorId = 1;
private static final int kFrontLeftSteerMotorId = 8;
private static final int kFrontLeftEncoderId = 2;
private static final double kFrontLeftEncoderOffset = -0.067626953125;
private static final int kFrontLeftDriveMotorId = 8;
private static final int kFrontLeftSteerMotorId = 7;
private static final int kFrontLeftEncoderId = 23;
private static final double kFrontLeftEncoderOffset = -0.399658203125;
private static final boolean kFrontLeftSteerInvert = true;

private static final double kFrontLeftXPosInches = 10.375;
private static final double kFrontLeftYPosInches = 10.375;
private static final double kFrontLeftXPosInches = 11;
private static final double kFrontLeftYPosInches = 11;

// Front Right
private static final int kFrontRightDriveMotorId = 6;
private static final int kFrontRightSteerMotorId = 7;
private static final int kFrontRightEncoderId = 9;
private static final double kFrontRightEncoderOffset = -0.27099609375;
private static final int kFrontRightDriveMotorId = 9;
private static final int kFrontRightSteerMotorId = 21;
private static final int kFrontRightEncoderId = 22;
private static final double kFrontRightEncoderOffset = -0.46142578125;
private static final boolean kFrontRightSteerInvert = true;

private static final double kFrontRightXPosInches = 10.375;
private static final double kFrontRightYPosInches = -10.375;
private static final double kFrontRightXPosInches = 11;
private static final double kFrontRightYPosInches = -11;

// Back Left
private static final int kBackLeftDriveMotorId = 2;
private static final int kBackLeftSteerMotorId = 4;
private static final int kBackLeftEncoderId = 1;
private static final double kBackLeftEncoderOffset = -0.125732421875;
private static final int kBackLeftSteerMotorId = 0;
private static final int kBackLeftEncoderId = 24;
private static final double kBackLeftEncoderOffset = 0.275390625;
private static final boolean kBackLeftSteerInvert = true;

private static final double kBackLeftXPosInches = -10.375;
private static final double kBackLeftYPosInches = 10.375;
private static final double kBackLeftXPosInches = -11;
private static final double kBackLeftYPosInches = 11;

// Back Right
private static final int kBackRightDriveMotorId = 5;
private static final int kBackRightSteerMotorId = 0;
private static final int kBackRightEncoderId = 0;
private static final double kBackRightEncoderOffset = 0.41455078125;
private static final int kBackRightDriveMotorId = 1;
private static final int kBackRightSteerMotorId = 3;
private static final int kBackRightEncoderId = 25;
private static final double kBackRightEncoderOffset = -0.2666015625;
private static final boolean kBackRightSteerInvert = true;

private static final double kBackRightXPosInches = -10.375;
private static final double kBackRightYPosInches = -10.375;
private static final double kBackRightXPosInches = -11;
private static final double kBackRightYPosInches = -11;

private static final SwerveModuleConstants FrontLeft =
ConstantCreator.createModuleConstants(
kFrontLeftSteerMotorId,
kFrontLeftDriveMotorId,
kFrontLeftEncoderId,
kFrontLeftEncoderOffset,
Units.inchesToMeters(kFrontLeftXPosInches),
Units.inchesToMeters(kFrontLeftYPosInches),
kInvertLeftSide);
kFrontLeftSteerMotorId,
kFrontLeftDriveMotorId,
kFrontLeftEncoderId,
kFrontLeftEncoderOffset,
Units.inchesToMeters(kFrontLeftXPosInches),
Units.inchesToMeters(kFrontLeftYPosInches),
kInvertLeftSide)
.withSteerMotorInverted(kFrontLeftSteerInvert);
private static final SwerveModuleConstants FrontRight =
ConstantCreator.createModuleConstants(
kFrontRightSteerMotorId,
kFrontRightDriveMotorId,
kFrontRightEncoderId,
kFrontRightEncoderOffset,
Units.inchesToMeters(kFrontRightXPosInches),
Units.inchesToMeters(kFrontRightYPosInches),
kInvertRightSide);
kFrontRightSteerMotorId,
kFrontRightDriveMotorId,
kFrontRightEncoderId,
kFrontRightEncoderOffset,
Units.inchesToMeters(kFrontRightXPosInches),
Units.inchesToMeters(kFrontRightYPosInches),
kInvertRightSide)
.withSteerMotorInverted(kFrontRightSteerInvert);
private static final SwerveModuleConstants BackLeft =
ConstantCreator.createModuleConstants(
kBackLeftSteerMotorId,
kBackLeftDriveMotorId,
kBackLeftEncoderId,
kBackLeftEncoderOffset,
Units.inchesToMeters(kBackLeftXPosInches),
Units.inchesToMeters(kBackLeftYPosInches),
kInvertLeftSide);
kBackLeftSteerMotorId,
kBackLeftDriveMotorId,
kBackLeftEncoderId,
kBackLeftEncoderOffset,
Units.inchesToMeters(kBackLeftXPosInches),
Units.inchesToMeters(kBackLeftYPosInches),
kInvertLeftSide)
.withSteerMotorInverted(kBackLeftSteerInvert);
private static final SwerveModuleConstants BackRight =
ConstantCreator.createModuleConstants(
kBackRightSteerMotorId,
kBackRightDriveMotorId,
kBackRightEncoderId,
kBackRightEncoderOffset,
Units.inchesToMeters(kBackRightXPosInches),
Units.inchesToMeters(kBackRightYPosInches),
kInvertRightSide);
kBackRightSteerMotorId,
kBackRightDriveMotorId,
kBackRightEncoderId,
kBackRightEncoderOffset,
Units.inchesToMeters(kBackRightXPosInches),
Units.inchesToMeters(kBackRightYPosInches),
kInvertRightSide)
.withSteerMotorInverted(kBackRightSteerInvert);

public static final CommandSwerveDrivetrain DriveTrain =
new CommandSwerveDrivetrain(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@

public final class TurretConstants {

public static int kCanCoderID1 = 0; // TODO: set id
public static int kCanCoderID2 = 0; // TODO: set id
public static int kCanCoderID1 = 41; // TODO: set id
public static int kCanCoderID2 = 42; // TODO: set id

public static final double gearRatio = 1; // TODO: Set gear ratio
public static final CANcoderConfiguration canCoderConfig =
new CANcoderConfiguration()
.withMagnetSensor(new MagnetSensorConfigs().withMagnetOffset(0)); // TODO: set config
public static final double updateFrequency = 50.0;

public static final int kTurretMotorID = 0; // TODO: Set ID
public static final int kTurretMotorID = 52; // TODO: Set ID

public static final double followTagP = 1;
public static final double followTagI = 0;
Expand Down

0 comments on commit e29b2d7

Please sign in to comment.