2026-02-19 16:33:09 -05:00
|
|
|
// 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;
|
|
|
|
|
|
2026-02-20 17:09:46 -05:00
|
|
|
import org.photonvision.PhotonCamera;
|
|
|
|
|
import org.photonvision.PhotonPoseEstimator;
|
|
|
|
|
|
2026-02-19 16:33:09 -05:00
|
|
|
import edu.wpi.first.apriltag.AprilTagFieldLayout;
|
|
|
|
|
import edu.wpi.first.apriltag.AprilTagFields;
|
|
|
|
|
import edu.wpi.first.math.geometry.Pose2d;
|
|
|
|
|
import edu.wpi.first.math.geometry.Rotation2d;
|
2026-02-20 17:09:46 -05:00
|
|
|
import edu.wpi.first.math.geometry.Rotation3d;
|
2026-02-19 16:33:09 -05:00
|
|
|
import edu.wpi.first.math.geometry.Transform2d;
|
2026-02-20 17:09:46 -05:00
|
|
|
import edu.wpi.first.math.geometry.Transform3d;
|
2026-02-19 16:33:09 -05:00
|
|
|
import edu.wpi.first.math.geometry.Translation3d;
|
|
|
|
|
import edu.wpi.first.math.util.Units;
|
|
|
|
|
import edu.wpi.first.networktables.GenericEntry;
|
|
|
|
|
import edu.wpi.first.wpilibj.shuffleboard.BuiltInWidgets;
|
|
|
|
|
import edu.wpi.first.wpilibj.shuffleboard.Shuffleboard;
|
|
|
|
|
import edu.wpi.first.wpilibj.shuffleboard.ShuffleboardTab;
|
|
|
|
|
import swervelib.math.Matter;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* The Constants class provides a convenient place for teams to hold robot-wide
|
|
|
|
|
* numerical or boolean constants. This
|
|
|
|
|
* class should not be used for any other purpose. All constants should be
|
|
|
|
|
* declared globally (i.e. public static). Do
|
|
|
|
|
* not put anything functional in this class.
|
|
|
|
|
*
|
|
|
|
|
* <p>
|
|
|
|
|
* It is advised to statically import this class (or one of its inner classes)
|
|
|
|
|
* wherever the
|
|
|
|
|
* constants are needed, to reduce verbosity.
|
|
|
|
|
*/
|
|
|
|
|
public final class Constants {
|
|
|
|
|
|
|
|
|
|
private static ShuffleboardTab programmingTab = Shuffleboard.getTab("Programming");
|
|
|
|
|
|
2026-03-03 19:35:30 -05:00
|
|
|
public static final double ROBOT_MASS = 140 * 0.453592; // 32lbs * kg per pound
|
2026-02-19 16:33:09 -05:00
|
|
|
public static final Matter CHASSIS = new Matter(new Translation3d(0, 0, Units.inchesToMeters(8)), ROBOT_MASS);
|
|
|
|
|
public static final double LOOP_TIME = 0.13; // s, 20ms + 110ms sprk max velocity lag
|
2026-03-03 19:35:30 -05:00
|
|
|
public static final double MAX_SPEED = Units.feetToMeters(25);
|
2026-02-19 16:33:09 -05:00
|
|
|
// Maximum speed of the robot in meters per second, used to limit acceleration.
|
|
|
|
|
|
|
|
|
|
// public static final class AutonConstants
|
|
|
|
|
// {
|
|
|
|
|
//
|
|
|
|
|
// public static final PIDConstants TRANSLATION_PID = new PIDConstants(0.7, 0,
|
|
|
|
|
// 0);
|
|
|
|
|
// public static final PIDConstants ANGLE_PID = new PIDConstants(0.4, 0, 0.01);
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
public static final class DrivebaseConstants {
|
|
|
|
|
|
|
|
|
|
// Hold time on motor brakes when disabled
|
|
|
|
|
public static final double WHEEL_LOCK_TIME = 10; // seconds
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static class OperatorConstants {
|
|
|
|
|
|
|
|
|
|
// Joystick Deadband
|
|
|
|
|
public static final double DEADBAND = 0.1;
|
|
|
|
|
public static final double LEFT_Y_DEADBAND = 0.1;
|
|
|
|
|
public static final double RIGHT_X_DEADBAND = 0.1;
|
|
|
|
|
public static final double TURN_CONSTANT = 6;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static class ShooterConstants {
|
2026-02-21 17:26:10 -05:00
|
|
|
private static GenericEntry shooterRPM = programmingTab.add("Desired Shooter RPM", -4000)
|
2026-02-19 16:33:09 -05:00
|
|
|
.withWidget(BuiltInWidgets.kNumberBar).getEntry();
|
|
|
|
|
|
2026-02-20 17:55:41 -05:00
|
|
|
public static double SHOOTER_RPM;
|
2026-02-19 16:33:09 -05:00
|
|
|
|
2026-02-21 09:23:04 -05:00
|
|
|
public static void updateShooterRPM() {
|
2026-02-21 17:26:10 -05:00
|
|
|
SHOOTER_RPM = shooterRPM.getDouble(-4000);
|
2026-02-19 16:33:09 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static final int CENTER_SHOOTER_MOTOR_ID = 42;
|
|
|
|
|
public static final int LEFT_SHOOTER_MOTOR_ID = 41;
|
|
|
|
|
public static final int RIGHT_SHOOTER_MOTOR_ID = 40;
|
|
|
|
|
public static final int INDEXER_MOTOR_ID = 43;
|
|
|
|
|
|
2026-03-02 16:25:15 -05:00
|
|
|
public static double SHOOTER_MOTOR_P = 0.001;
|
2026-02-19 17:51:31 -05:00
|
|
|
public static double SHOOTER_MOTOR_I = 0;
|
2026-03-02 16:25:15 -05:00
|
|
|
public static double SHOOTER_MOTOR_D = 0.001;
|
|
|
|
|
public static double SHOOTER_MOTOR_S = 0.2;
|
|
|
|
|
public static double SHOOTER_MOTOR_V = 0.0015;
|
2026-02-20 17:55:41 -05:00
|
|
|
|
2026-02-21 17:26:10 -05:00
|
|
|
public static double INDEXER_MOTOR_P = 0.0001;
|
|
|
|
|
public static double INDEXER_MOTOR_I = 0;
|
|
|
|
|
public static double INDEXER_MOTOR_D = 0;
|
|
|
|
|
|
2026-03-02 16:25:15 -05:00
|
|
|
/*
|
|
|
|
|
* private static GenericEntry indexerAndRampRPM =
|
|
|
|
|
* programmingTab.add("Desired Ramp + Indexer RPM", 2000)
|
|
|
|
|
* .withWidget(BuiltInWidgets.kNumberBar).getEntry();
|
|
|
|
|
*/
|
2026-02-21 17:26:10 -05:00
|
|
|
|
2026-03-03 19:35:30 -05:00
|
|
|
public static double INDEXER_AND_RAMP_MOTOR_RPM = 20000;
|
2026-02-19 16:33:09 -05:00
|
|
|
|
|
|
|
|
// this method called in robot periodic so values updated in elastic are
|
|
|
|
|
// constantly read and applied to RAMP_MOTOR_SPEED
|
2026-03-02 16:25:15 -05:00
|
|
|
/*
|
|
|
|
|
* public static void updateIndexerAndRampMotorRPM() {
|
|
|
|
|
* INDEXER_AND_RAMP_MOTOR_RPM = indexerAndRampRPM.getDouble(2000);
|
|
|
|
|
* }
|
|
|
|
|
*/
|
2026-02-19 16:33:09 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static class IntakeConstants {
|
2026-02-20 16:20:26 -05:00
|
|
|
|
2026-03-02 16:25:15 -05:00
|
|
|
/*
|
|
|
|
|
* private static GenericEntry intakeRPM =
|
|
|
|
|
* programmingTab.add("Desired Intake RPM", -1000)
|
|
|
|
|
* .withWidget(BuiltInWidgets.kNumberBar).getEntry();
|
|
|
|
|
*/
|
2026-03-03 19:35:30 -05:00
|
|
|
public static double INTAKE_WHEELS_MOTOR_RPM = -6250;
|
2026-02-19 16:33:09 -05:00
|
|
|
|
2026-03-02 16:25:15 -05:00
|
|
|
/*
|
|
|
|
|
* public static void updateIntakeWheelsRPM() {
|
|
|
|
|
* INTAKE_WHEELS_MOTOR_RPM = intakeRPM.getDouble(-1000);
|
|
|
|
|
* }
|
|
|
|
|
*/
|
2026-02-19 16:33:09 -05:00
|
|
|
|
|
|
|
|
public static final int INTAKE_WHEELS_MOTOR_ID = 50;
|
|
|
|
|
public static final int INTAKE_ROTATOR_MOTOR_ID = 51;
|
|
|
|
|
|
|
|
|
|
public static class IntakeRotatorPID {
|
2026-03-03 19:35:30 -05:00
|
|
|
public static final double INTAKE_ROTATOR_P = .5;
|
|
|
|
|
public static final double INTAKE_ROTATOR_I = 0.01;
|
|
|
|
|
public static final double INTAKE_ROTATOR_D = 0;
|
2026-02-19 16:33:09 -05:00
|
|
|
}
|
2026-03-02 16:25:15 -05:00
|
|
|
|
2026-02-21 17:26:10 -05:00
|
|
|
public static final double INTAKE_MOTOR_P = 0.0001;
|
|
|
|
|
public static final double INTAKE_MOTOR_I = 0;
|
|
|
|
|
public static final double INTAKE_MOTOR_D = 0;
|
2026-02-19 16:33:09 -05:00
|
|
|
|
2026-03-02 16:25:15 -05:00
|
|
|
public static final double INTAKE_COLLECT_ENCODER_VALUE = 0;
|
2026-03-03 10:27:14 -05:00
|
|
|
public static final double INTAKE_MIDDLE_ENCODER_VALUE = -2.5;
|
2026-03-02 16:25:15 -05:00
|
|
|
public static final double INTAKE_RETRACT_ENCODER_VALUE = -5;
|
2026-03-03 10:27:14 -05:00
|
|
|
|
2026-03-03 19:35:30 -05:00
|
|
|
public static final double INTAKE_THROUGHBORE_ENCODER_DEPLOY = .13;
|
|
|
|
|
public static final double INTAKE_THROUGHBORE_ENCODER_RETRACT = .49;
|
|
|
|
|
public static final double INTAKE_THROUGHBORE_ENCODER_MIDDLE = .389;
|
2026-03-03 10:27:14 -05:00
|
|
|
|
2026-02-20 17:55:41 -05:00
|
|
|
}
|
2026-02-19 16:33:09 -05:00
|
|
|
|
2026-03-02 16:25:15 -05:00
|
|
|
// create object and a new widget under programming tab in Elastic where object
|
|
|
|
|
// retrieves value from widget
|
2026-02-19 16:33:09 -05:00
|
|
|
|
|
|
|
|
public static class TargetingConstants {
|
|
|
|
|
public static final Pose2d RIGHT_CLIMB_POSE = new Pose2d(1.075, 4.75, Rotation2d.fromDegrees(90));
|
|
|
|
|
public static final Pose2d LEFT_CLIMB_POSE = new Pose2d(1.075, 2.75, Rotation2d.fromDegrees(-90));
|
2026-02-20 17:09:46 -05:00
|
|
|
|
2026-03-02 16:25:15 -05:00
|
|
|
public static final PhotonCamera ORANGE_PHOTON_CAM = new PhotonCamera("Back Left Camera");
|
|
|
|
|
public static final PhotonCamera BLACK_PHOTON_CAM = new PhotonCamera("Back Right Camera");
|
2026-02-21 17:26:10 -05:00
|
|
|
public static final PhotonCamera RED_PHOTON_CAM = new PhotonCamera("Front Left Camera");
|
|
|
|
|
public static final PhotonCamera PURPLE_PHOTON_CAM = new PhotonCamera("Front Right Camera");
|
2026-02-20 17:09:46 -05:00
|
|
|
|
2026-03-02 16:25:15 -05:00
|
|
|
public static Rotation2d HUB_ROTATION_BLUE;
|
|
|
|
|
public static Rotation2d HUB_ROTATION_RED;
|
2026-02-21 09:23:04 -05:00
|
|
|
|
2026-03-02 16:25:15 -05:00
|
|
|
public static final double HUB_X_POSE_BLUE = 4.625;
|
|
|
|
|
public static final double HUB_Y_POSE_BLUE = 4.03;
|
|
|
|
|
|
|
|
|
|
public static final double HUB_X_POSE_RED = 4.625;
|
|
|
|
|
public static final double HUB_Y_POSE_RED = 0;
|
|
|
|
|
|
|
|
|
|
public static final Transform3d ROBOT_TO_BACK_LEFT_CAM = new Transform3d(
|
|
|
|
|
new Translation3d(-Units.inchesToMeters(12.75), Units.inchesToMeters(6.25), Units.inchesToMeters(13.1875)),
|
|
|
|
|
new Rotation3d(0, 0, Math.toRadians(-205)));
|
|
|
|
|
|
|
|
|
|
public static final Transform3d ROBOT_TO_BACK_RIGHT_CAM = new Transform3d(
|
|
|
|
|
new Translation3d(-Units.inchesToMeters(12.75), -Units.inchesToMeters(6.25), Units.inchesToMeters(14)),
|
|
|
|
|
new Rotation3d(0, 0, Math.toRadians(200)));
|
|
|
|
|
|
|
|
|
|
public static final Transform3d ROBOT_TO_FRONT_LEFT_CAM = new Transform3d(
|
|
|
|
|
new Translation3d(Units.inchesToMeters(23.375), 0, Units.inchesToMeters(13)),
|
2026-03-03 19:35:30 -05:00
|
|
|
new Rotation3d(0, 74, 0));
|
2026-02-20 17:09:46 -05:00
|
|
|
|
2026-03-02 16:25:15 -05:00
|
|
|
public static final Transform3d ROBOT_TO_FRONT_RIGHT_CAM = new Transform3d(
|
|
|
|
|
new Translation3d(0, 0, 0),
|
|
|
|
|
new Rotation3d(0, 0, 0));
|
2026-02-19 16:33:09 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static class ClimberConstants {
|
2026-03-02 16:25:15 -05:00
|
|
|
public static final int CLIMB_MOTOR_ID = 52;
|
2026-02-19 16:33:09 -05:00
|
|
|
|
|
|
|
|
public static final double CLIMBER_SPEED = .5;
|
2026-03-02 16:25:15 -05:00
|
|
|
|
|
|
|
|
public static final double CLIMBER_PID_P = 5;
|
|
|
|
|
public static final double CLIMBER_PID_I = 0;
|
|
|
|
|
public static final double CLIMBER_PID_D = 0;
|
|
|
|
|
|
|
|
|
|
public static final double CLIMBER_LIFTED_SETPOINT_VALUE = 45;
|
|
|
|
|
public static final double CLIMBER_LOWERED_SETPOINT_VALUE = 0;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static class LEDConstants {
|
2026-03-03 10:27:14 -05:00
|
|
|
public static final int LED_PWM_PORT = 6;
|
|
|
|
|
|
2026-03-02 16:25:15 -05:00
|
|
|
|
2026-02-19 16:33:09 -05:00
|
|
|
}
|
|
|
|
|
}
|