diff --git a/.gitignore b/.gitignore index 34cbaac..c301306 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,192 @@ +<<<<<<< HEAD +# This gitignore has been specially created by the WPILib team. +# If you remove items from this file, intellisense might break. + +### C++ ### +# Prerequisites +*.d + +# Compiled Object files +*.slo +*.lo +*.o +*.obj + +# Precompiled Headers +*.gch +*.pch + +# Compiled Dynamic libraries +*.so +*.dylib +*.dll + +# Fortran module files +*.mod +*.smod + +# Compiled Static libraries +*.lai +*.la +*.a +*.lib + +# Executables +*.exe +*.out +*.app + +### Java ### +# Compiled class file +*.class + +# Log file +*.log + +# BlueJ files +*.ctxt + +# Mobile Tools for Java (J2ME) +.mtj.tmp/ + +# Package Files # +*.jar +*.war +*.nar +*.ear +*.zip +*.tar.gz +*.rar + +# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml +hs_err_pid* + +### Linux ### +*~ + +# temporary files which can be created if a process still has a handle open of a deleted file +.fuse_hidden* + +# KDE directory preferences +.directory + +# Linux trash folder which might appear on any partition or disk +.Trash-* + +# .nfs files are created when an open file is removed but is still being accessed +.nfs* + +### macOS ### +# General +.DS_Store +.AppleDouble +.LSOverride + +# Icon must end with two \r +Icon + +# Thumbnails +._* + +# Files that might appear in the root of a volume +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns +.com.apple.timemachine.donotpresent + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk + +### VisualStudioCode ### +.vscode/* +!.vscode/settings.json +!.vscode/tasks.json +!.vscode/launch.json +!.vscode/extensions.json + +### Windows ### +# Windows thumbnail cache files +Thumbs.db +ehthumbs.db +ehthumbs_vista.db + +# Dump file +*.stackdump + +# Folder config file +[Dd]esktop.ini + +# Recycle Bin used on file shares +$RECYCLE.BIN/ + +# Windows Installer files +*.cab +*.msi +*.msix +*.msm +*.msp + +# Windows shortcuts +*.lnk + +### Gradle ### +.gradle +/build/ + +# Ignore Gradle GUI config +gradle-app.setting + +# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored) +!gradle-wrapper.jar + +# Cache of project +.gradletasknamecache + +# # Work around https://youtrack.jetbrains.com/issue/IDEA-116898 +# gradle/wrapper/gradle-wrapper.properties + +# # VS Code Specific Java Settings +# DO NOT REMOVE .classpath and .project +.classpath +.project +.settings/ +bin/ + +# IntelliJ +*.iml +*.ipr +*.iws +.idea/ +out/ + +# Fleet +.fleet + +# Simulation GUI and other tools window save file +networktables.json +simgui.json +*-window.json + +# Simulation data log directory +logs/ + +# Folder that has CTRE Phoenix Sim device config storage +ctre_sim/ + +# clangd +/.cache +compile_commands.json + +# Eclipse generated file for annotation processors +.factorypath +======= # This gitignore has been specially created by the WPILib team. # If you remove items from this file, intellisense might break. @@ -185,3 +374,4 @@ compile_commands.json # Eclipse generated file for annotation processors .factorypath +>>>>>>> protobot/intake diff --git a/.vscode/settings.json b/.vscode/settings.json index 612cdd0..5e93e0e 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -56,5 +56,10 @@ "edu.wpi.first.math.proto.*", "edu.wpi.first.math.**.proto.*", "edu.wpi.first.math.**.struct.*", +<<<<<<< HEAD + ], + "java.dependency.enableDependencyCheckup": false +======= ] +>>>>>>> protobot/intake } diff --git a/.wpilib/wpilib_preferences.json b/.wpilib/wpilib_preferences.json index 29edf90..d23db87 100644 --- a/.wpilib/wpilib_preferences.json +++ b/.wpilib/wpilib_preferences.json @@ -1,6 +1,6 @@ { "enableCppIntellisense": false, "currentLanguage": "java", - "projectYear": "2025", + "projectYear": "2026", "teamNumber": 422 } diff --git a/build.gradle b/build.gradle index e385ab0..ef503b1 100644 --- a/build.gradle +++ b/build.gradle @@ -2,9 +2,9 @@ import java.text.SimpleDateFormat plugins { id "java" - id "edu.wpi.first.GradleRIO" version "2025.3.2" + id "edu.wpi.first.GradleRIO" version "2026.2.1" id "com.peterabeles.gversion" version "1.10" - id "com.diffplug.spotless" version "6.12.0" + id "com.diffplug.spotless" version "6.25.0" id "org.ajoberstar.grgit" version "5.2.1" id "io.freefair.lombok" version "8.4" } @@ -50,9 +50,8 @@ deploy { frcStaticFileDeploy(getArtifactTypeClass('FileTreeArtifact')) { files = project.fileTree('src/main/deploy') directory = '/home/lvuser/deploy' - // Change to true to delete files on roboRIO that no - // longer exist in deploy directory on roboRIO - deleteOldFiles = true + deleteOldFiles = false // Change to true to delete files on roboRIO that no + // longer exist in deploy directory of this project } } } @@ -61,11 +60,12 @@ deploy { def deployArtifact = deploy.targets.roborio.artifacts.frcJava -// Set to true to use debug for JNI. +// Set to true to use debug for all targets including JNI, which will drastically impact +// performance. wpi.java.debugJni = false // Set this to true to enable desktop support. -def includeDesktopSupport = true +def includeDesktopSupport = false // Configuration for AdvantageKit task(replayWatch, type: JavaExec) { @@ -74,7 +74,7 @@ task(replayWatch, type: JavaExec) { } // Defining my dependencies. In this case, WPILib (+ friends), and vendor libraries. -// Also defines JUnit 4. +// Also defines JUnit 5. dependencies { annotationProcessor wpi.java.deps.wpilibAnnotations() implementation wpi.java.deps.wpilib() @@ -107,19 +107,18 @@ test { } // Simulation configuration (e.g. environment variables). -// -// The sim GUI is *disabled* by default to support running -// AdvantageKit log replay from the command line. Set the -// value to "true" to enable the sim GUI by default (this -// is the standard WPILib behavior). -wpi.sim.addGui().defaultEnabled = false +wpi.sim.addGui().defaultEnabled = true wpi.sim.addDriverstation() // Setting up my Jar File. In this case, adding all libraries into the main jar ('fat jar') // in order to make them all available at runtime. Also adding the manifest so WPILib // knows where to look for our Robot Class. jar { - from { configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) } } + from { + configurations.runtimeClasspath.collect { + it.isDirectory() ? it : zipTree(it) + } + } from sourceSets.main.allSource manifest edu.wpi.first.gradlerio.GradleRIOPlugin.javaManifest(ROBOT_MAIN_CLASS) duplicatesStrategy = DuplicatesStrategy.INCLUDE diff --git a/simgui-ds.json b/simgui-ds.json deleted file mode 100644 index c4b7efd..0000000 --- a/simgui-ds.json +++ /dev/null @@ -1,98 +0,0 @@ -{ - "keyboardJoysticks": [ - { - "axisConfig": [ - { - "decKey": 65, - "incKey": 68 - }, - { - "decKey": 87, - "incKey": 83 - }, - { - "decKey": 69, - "decayRate": 0.0, - "incKey": 82, - "keyRate": 0.009999999776482582 - } - ], - "axisCount": 3, - "buttonCount": 4, - "buttonKeys": [ - 90, - 88, - 67, - 86 - ], - "povConfig": [ - { - "key0": 328, - "key135": 323, - "key180": 322, - "key225": 321, - "key270": 324, - "key315": 327, - "key45": 329, - "key90": 326 - } - ], - "povCount": 1 - }, - { - "axisConfig": [ - { - "decKey": 74, - "incKey": 76 - }, - { - "decKey": 73, - "incKey": 75 - } - ], - "axisCount": 2, - "buttonCount": 4, - "buttonKeys": [ - 77, - 44, - 46, - 47 - ], - "povCount": 0 - }, - { - "axisConfig": [ - { - "decKey": 263, - "incKey": 262 - }, - { - "decKey": 265, - "incKey": 264 - } - ], - "axisCount": 2, - "buttonCount": 6, - "buttonKeys": [ - 260, - 268, - 266, - 261, - 269, - 267 - ], - "povCount": 0 - }, - { - "axisCount": 0, - "buttonCount": 0, - "povCount": 0 - } - ], - "robotJoysticks": [ - { - "guid": "78696e70757401000000000000000000", - "useGamepad": true - } - ] -} diff --git a/src/main/java/frc/robot/BuildConstants.java b/src/main/java/frc/robot/BuildConstants.java index dca2b59..5178643 100644 --- a/src/main/java/frc/robot/BuildConstants.java +++ b/src/main/java/frc/robot/BuildConstants.java @@ -3,15 +3,15 @@ /** Automatically generated file containing build version information. */ public final class BuildConstants { public static final String MAVEN_GROUP = ""; - public static final String MAVEN_NAME = "ProtoBot"; + public static final String MAVEN_NAME = "protobot"; public static final String VERSION = "unspecified"; - public static final int GIT_REVISION = 1; - public static final String GIT_SHA = "198f6928a042cfff7c9cdeddccc41561e11e157f"; - public static final String GIT_DATE = "2025-12-14 17:00:40 EST"; - public static final String GIT_BRANCH = "protobot"; - public static final String BUILD_DATE = "2026-01-08 17:10:42 EST"; - public static final long BUILD_UNIX_TIME = 1767910242436L; - public static final int DIRTY = 1; + public static final int GIT_REVISION = 34; + public static final String GIT_SHA = "1ad7b710f1e189562fc971b4faa6d74e1f7eab3e"; + public static final String GIT_DATE = "2026-01-23 18:41:54 EST"; + public static final String GIT_BRANCH = "intake"; + public static final String BUILD_DATE = "2026-01-24 13:49:23 EST"; + public static final long BUILD_UNIX_TIME = 1769280563277L; + public static final int DIRTY = 0; private BuildConstants() {} } diff --git a/src/main/java/frc/robot/Constants.java b/src/main/java/frc/robot/Constants.java index 917f8e6..ed7a67f 100644 --- a/src/main/java/frc/robot/Constants.java +++ b/src/main/java/frc/robot/Constants.java @@ -5,6 +5,7 @@ import static edu.wpi.first.units.Units.KilogramSquareMeters; import static edu.wpi.first.units.Units.Pounds; +import com.ctre.phoenix6.CANBus; import edu.wpi.first.apriltag.AprilTagFieldLayout; import edu.wpi.first.apriltag.AprilTagFields; import edu.wpi.first.math.geometry.Pose2d; @@ -18,12 +19,9 @@ import edu.wpi.first.math.kinematics.SwerveDriveKinematics; import edu.wpi.first.math.system.plant.DCMotor; import edu.wpi.first.math.util.Units; -import edu.wpi.first.units.measure.Angle; import edu.wpi.first.units.measure.Mass; import edu.wpi.first.units.measure.MomentOfInertia; import edu.wpi.first.wpilibj.RobotBase; -import edu.wpi.first.wpilibj.simulation.SingleJointedArmSim; -import edu.wpi.first.wpilibj.util.Color; import frc.lib.littletonUtils.GeomUtil; import frc.lib.littletonUtils.LoggedTunableNumber; import frc.lib.littletonUtils.SwerveSetpointGenerator.ModuleLimits; @@ -41,7 +39,7 @@ public final class Constants { public static final Mode kSimMode = Mode.SIM; public static final Mode kCurrentMode = RobotBase.isReal() ? kRealMode : kSimMode; - public static final boolean kUsePhoenixDiagnosticServer = false; + public static final boolean kUsePhoenixDiagnosticServer = true; // set to false to disable the base refresh manager public static final boolean kUseBaseRefreshManager = false; @@ -187,157 +185,17 @@ public static final class DriveConstants { public static final MomentOfInertia kRobotMOI = KilogramSquareMeters.of(6.5); } - public static final class ClimbConstants { - - public static final LoggedTunableNumber kClimbP = new LoggedTunableNumber("Climb P", 30.0); - public static final LoggedTunableNumber kClimbI = new LoggedTunableNumber("Climb I", 0.0); - public static final LoggedTunableNumber kClimbD = new LoggedTunableNumber("Climb D", 0.0); - public static final double kClimbTolerance = 5.0; // degrees - - public static final LoggedTunableNumber kStowFeedforward = - new LoggedTunableNumber("Climb Stow Feedforward", 0.0); - - // these are magic units - public static final LoggedTunableNumber kClimbStowPos = - new LoggedTunableNumber("Climb Stow Angle", -225.0); - public static final LoggedTunableNumber kClimbMatchPos = - new LoggedTunableNumber("Climb Match Angle", 300.0); - public static final LoggedTunableNumber kClimbDeployPos = - new LoggedTunableNumber("Climb Deploy Angle", 600.0); - - public static final double kClimbReduction = (5.0 / 1.0) * (4.0 / 1.0) * (68.0 / 18.0); + public static final class IntakeConstants { + public static final LoggedTunableNumber kIntakingVoltage = + new LoggedTunableNumber("Intake/intakingVoltage", 8.5); + public static final LoggedTunableNumber kIdleVoltage = + new LoggedTunableNumber("Intake/idleVoltage", 0.0); - public static final Rotation2d kMinAngle = Rotation2d.fromDegrees(-350.0); - public static final Rotation2d kMaxAngle = Rotation2d.fromDegrees(600.0); + public static final double kGearRatio = 2.125 / 1.0; - // sim constants - public static final double kSimGearing = 1.0; + // sim public static final DCMotor kSimGearbox = DCMotor.getKrakenX60(1); - public static final double kSimClimbArmLengthMeters = 0.25; - public static final double kSimMOI = 2.0; - public static final double kSimStartingAngleRad = Units.degreesToRadians(0); - public static final boolean kSimGravity = false; - public static final double kSimClimbP = 0.5; - public static final double kSimClimbI = 0.0; - public static final double kSimClimbD = 0.35; - } - - public static final class LedConstants { - public static final int kStripLength = 22; - - public static final Color kOff = Color.kBlack; - public static final Color kL1 = Color.kBlue; - public static final Color kL2 = Color.kRed; - public static final Color kL3 = Color.kYellow; - public static final Color kL4 = Color.kGreen; - public static final Color kDisabled = Color.kMagenta; - public static final Color kLocationCheckYaw = Color.kDarkGreen; - public static final Color kLocationCheckDistance = Color.kLightBlue; - public static final Color kAlert = Color.kRed; - public static final Color kFullTuning = Color.kWhite; - public static final Color kVisionOff = Color.kBlack; - public static final Color kAutoscoreMeasurementsBad = Color.kOrange; - public static final Color kAutoscoreMeasurementsGood = Color.kDarkOliveGreen; - public static final Color kHasGamePiece = Color.kBrown; - } - - public static final class ElevatorConstants { - public static final LoggedTunableNumber kP0 = new LoggedTunableNumber("Elevator P0", 2.0); - public static final LoggedTunableNumber kI = new LoggedTunableNumber("Elevator I", 0.0); - public static final LoggedTunableNumber kD = new LoggedTunableNumber("Elevator D", 0.08); - public static final LoggedTunableNumber kKG0 = new LoggedTunableNumber("Elevator kG0", 0.18); - - public static final LoggedTunableNumber kP1 = new LoggedTunableNumber("Elevator P1", 2.0); - public static final LoggedTunableNumber kKG1 = new LoggedTunableNumber("Elevator kG1", 0.28); - - public static final LoggedTunableNumber kP2 = new LoggedTunableNumber("Elevator P2", 2.0); - public static final LoggedTunableNumber kKG2 = new LoggedTunableNumber("Elevator kG2", 0.40); - - public static final LoggedTunableNumber kMagicMotionCruiseVelocity = - new LoggedTunableNumber("Elevator MagicMotion cruise velocity", 5.0); - public static final LoggedTunableNumber kMagicMotionAcceleration = - new LoggedTunableNumber("Elevator MagicMotion acceleration", 10.0); - public static final LoggedTunableNumber kMagicMotionJerk = - new LoggedTunableNumber("Elevator MagicMotion Jerk", 100.0); - - public static final LoggedTunableNumber kStowHeight = - new LoggedTunableNumber("Elevator Stow Height", 0.0); - public static final LoggedTunableNumber kIntakingHeight = - new LoggedTunableNumber("Elevator Intake Height", 0.0); - public static final LoggedTunableNumber kAlgaeDescoringIntialHeightL2 = - new LoggedTunableNumber("Elevator Algae Descore Initial Height L2", 19.0); - public static final LoggedTunableNumber kAlgaeDescoringFinalHeightL2 = - new LoggedTunableNumber("Elevator Algae Descore Final Height L2", 23.5); - public static final LoggedTunableNumber kAlgaeDescoringIntialHeightL3 = - new LoggedTunableNumber("Elevator Algae Descore Initial Height L3", 29.5); - public static final LoggedTunableNumber kAlgaeDescoringFinalHeightL3 = - new LoggedTunableNumber("Elevator Algae Descore Final Height L3", 38.5); - public static final LoggedTunableNumber kBargeScoreHeight = - new LoggedTunableNumber("Elevator Barge Score Height", 72.5); - public static final LoggedTunableNumber kAlgaeHoldHeight = - new LoggedTunableNumber("Elevator Algae Hold Height", 14.5); - public static final LoggedTunableNumber kAlgaeOuttakeHeight = - new LoggedTunableNumber("Elevator Algae Outtake Height", 3.5); - public static final LoggedTunableNumber kLollipopIntakeHeight = - new LoggedTunableNumber("Elevator Lollipop Intake Height", 3.0); - public static final LoggedTunableNumber kDriveUpHeight = - new LoggedTunableNumber("Drive Up Height", 11.5); - - public static final LoggedTunableNumber kBargeThrowHeight = - new LoggedTunableNumber("Elevator Barge Throw Height", 17.0); - - public static final double kDiameter = 2.256; // inches - public static final double kGearRatio = 54.0 / 12.0; - // public static final double kSensorToMechanismRatio = kDiameter * Math.PI / kGearRatio; - public static final double kSensorToMechanismRatio = (kGearRatio / (kDiameter * Math.PI)); - // public static final double kSensorToMechanismRatio = 1.0; - public static final LoggedTunableNumber kElevatorOffset = - new LoggedTunableNumber("Elevator Offset", Units.inchesToMeters(0)); - - // this is the more than the max amount that the belts will ever skip - public static final double kMaxSkip = 2.0; - public static final LoggedTunableNumber kSlamTime = new LoggedTunableNumber("Slam Time", 0.2); - public static final LoggedTunableNumber kSlamVoltage = - new LoggedTunableNumber("Slam Voltage", -3.0); - - public static final double kZeroVelocityThreshold = 0.03; - public static final double kZeroCurrentTheshold = 10.0; - - public static final LoggedTunableNumber kL1 = - new LoggedTunableNumber("Elevator L1 Height", 9.5); - public static final LoggedTunableNumber kL2 = - new LoggedTunableNumber("Elevator L2 Height", 27.0); - public static final LoggedTunableNumber kL3 = - new LoggedTunableNumber("Elevator L3 Height", 43.25); - public static final LoggedTunableNumber kL4 = - new LoggedTunableNumber("Elevator L4 Height", 71.0); - - // Simulation constants - public static final double kSimGearing = kGearRatio; - public static final double kSimMOI = .001; - public static final DCMotor kSimGearbox = DCMotor.getKrakenX60(2); - public static final double kMinHeight = 0; - public static final double kMaxHeight = 73.5; - public static final double kHeightTolerance = 0.25; - public static final double kSimElevatorP = 0.5; - public static final double kSimElevatorI = 0.0; - public static final double kSimElevatorD = 0.0; - public static final double kSimElevatorkG = 0.0; - } - - public static final class FullTuningConstants { - public static final boolean kFullTuningMode = false; - - public static final LoggedTunableNumber kElevatorSetpoint = - new LoggedTunableNumber("Full Tuning Elevator Setpoint", 0.0); - public static final LoggedTunableNumber kIntakePivotSetpoint = - new LoggedTunableNumber("Full Tuning Intake Pivot Setpoint", 0.0); - public static final LoggedTunableNumber kManipulatorWristSetpoint = - new LoggedTunableNumber("Full Tuning Manipulator Wrist Setpoint", 0.0); - public static final LoggedTunableNumber kManipulatorRollerVoltage = - new LoggedTunableNumber("Full Tuning Manipulator Roller Voltage", 0.0); - public static final LoggedTunableNumber kIndexerVoltage = - new LoggedTunableNumber("Full Tuning Indexer Voltage", 0.0); + public static final double kSimMOI = .005; } public static final class AprilTagVisionConstants { @@ -417,220 +275,6 @@ public static final class AprilTagVisionConstants { public static final double kRotationSpeedThreshold = 0.2; // m/s } - public static final class IntakeConstants { - public static final double kPivotGearRatio = (72.0 / 8.0) * (36.0 / 14.0); - public static final double kPivotAbsoluteEncoderGearRatio = 3.2; - public static final double kRollerGearRatio = (30.0 / 12.0); - public static final double kRollerRadius = Units.inchesToMeters(1.5); - - public static final LoggedTunableNumber kPivotTolerance = - new LoggedTunableNumber("Pivot Tolerance", 65.0); // degrees - - // the offset needs to be so that it starts at 90 degrees (top) - // public static final Rotation2d kPivotOffset = - // Rotation2d.fromDegrees(87.451171875).plus(Rotation2d.fromDegrees(90.0)); - // public static final Rotation2d kPivotOffset = Rotation2d.fromDegrees(0.0); - public static final Rotation2d kPivotOffset = - Rotation2d.fromDegrees( - (24.0 + 134.0 + 8.0 + 16.1 + 3.0 + 9.0 - 6.0 - 2.0) * kPivotAbsoluteEncoderGearRatio); - - public static final Rotation2d kPivotFakeToRealOffset = Rotation2d.fromDegrees(75.0); - - public static final LoggedTunableNumber kZeroEncoderThreshold = - new LoggedTunableNumber("Pivot Zero Threshikd", 122.0); // degrees - - public static final Angle kZeroEncoderValue = Degrees.of(137.0); - - // current to be considered holding a game piece - // unused rn - public static final double kRollerCoralCurrentThreshold = 99.0; - - public static final double kRollerCoralCurrentDebounce = 0.2; // seconds - // L1 SETUP - public static final LoggedTunableNumber kPivotP0 = new LoggedTunableNumber("Pivot P0", 16.0); - // PASSTHROUGH SETUP - // public static final LoggedTunableNumber kPivotP0 = new LoggedTunableNumber("Pivot P0", 20.0); - public static final LoggedTunableNumber kPivotI = new LoggedTunableNumber("Pivot I", 0.0); - public static final LoggedTunableNumber kPivotD0 = new LoggedTunableNumber("Pivot D0", 0.2); - public static final LoggedTunableNumber kPivotP1 = new LoggedTunableNumber("Pivot P1", 30.0); - public static final LoggedTunableNumber kPivotD1 = new LoggedTunableNumber("Pivot D1", 0.2); - public static final LoggedTunableNumber kPivotP2 = new LoggedTunableNumber("Pivot P2", 30.0); - public static final LoggedTunableNumber kPivotD2 = new LoggedTunableNumber("Pivot D2", 0.2); - public static final LoggedTunableNumber kPivotKS = new LoggedTunableNumber("Pivot kS", 0.23); - - public static final LoggedTunableNumber kPivotStowAngle = - new LoggedTunableNumber("Pivot Stow Angle", 30.0); - public static final LoggedTunableNumber kPivotIntakeAngle = - new LoggedTunableNumber("Pivot Intake Angle", 139.0); - public static final LoggedTunableNumber kPivotHoldAngle = - new LoggedTunableNumber("Pivot Hold Angle", 30.0); - public static final LoggedTunableNumber kPivotOuttakeAngle = - new LoggedTunableNumber("Pivot Outtake Angle", 48.0); - public static final LoggedTunableNumber kPivotFunnelIntakeAngle = - new LoggedTunableNumber("Pivot Funnel Intake Angle", 64.0); - public static final LoggedTunableNumber kPivotCoralRunThroughAngle = - new LoggedTunableNumber("Pivot Coral Run Through Angle", 30.0); - public static final LoggedTunableNumber kPivotClimbAngle = - new LoggedTunableNumber("Pivot Climb Angle", 50.0); - public static final LoggedTunableNumber kIntakingFeedforward = - new LoggedTunableNumber("Pivot Intaking Feedforward", 0.0); - - public static final LoggedTunableNumber kZeroVelocityThreshold = - new LoggedTunableNumber("Pivot Zero Velocity Threshold", 1.0); - public static final LoggedTunableNumber kIntakingFeedforwardThreshold = - new LoggedTunableNumber("Pivot Intaking Feedforward Threshold", 125.0); - - public static final LoggedTunableNumber kRollerStowVoltage = - new LoggedTunableNumber("Intake Roller Stow Voltage", 0.0); - public static final LoggedTunableNumber kRollerIntakeVoltage = - new LoggedTunableNumber("Intake Roller Intake Voltage", 3.5); - public static final LoggedTunableNumber kRollerL1IntakeVoltage = - new LoggedTunableNumber("Intake Roller L1 Intake Voltage", 3.0); - public static final LoggedTunableNumber kRollerHoldVoltage = - new LoggedTunableNumber("Intake Roller Hold Voltage", 0.29); - public static final LoggedTunableNumber kRollerOuttakeVoltage = - new LoggedTunableNumber("Intake Roller Outtake Voltage", -2.0); - public static final LoggedTunableNumber kRollerFunnelIntakeVoltage = - new LoggedTunableNumber("Intake Roller Funnel Intake Voltage", -2.0); - public static final LoggedTunableNumber kRollerCoralRunThroughVoltage = - new LoggedTunableNumber("Intake Roller Coral Run Through Voltage", 4.0); - public static final LoggedTunableNumber kRollerEjectVoltage = - new LoggedTunableNumber("Intake Roller Coral Eject Voltage", -3.0); - - public static final LoggedTunableNumber kCoralRunThroughTimeout = - new LoggedTunableNumber("Coral Runthrough Timeout", 0.5); - public static final LoggedTunableNumber kCoralRaiseTimeout = - new LoggedTunableNumber("Coral Raise Timeout", 0.1); - - // Simulation constants - public static final DCMotor kPivotSimGearbox = DCMotor.getKrakenX60Foc(1); - public static final double kPivotSimGearing = kPivotGearRatio; - public static final double kPivotArmMass = Units.lbsToKilograms(3.419); - public static final double kPivotArmLength = Units.inchesToMeters(17.5); - public static final double kPivotSimMOI = - SingleJointedArmSim.estimateMOI(kPivotArmLength, kPivotArmMass); - public static final Rotation2d kPivotMinAngle = Rotation2d.fromDegrees(30.0); - public static final Rotation2d kPivotMaxAngle = Rotation2d.fromDegrees(140.0); - public static final boolean kSimSimulateGravity = false; - public static final Rotation2d kSimStartingAngle = - Rotation2d.fromDegrees(Math.random() * kPivotMaxAngle.getDegrees()); - - public static final DCMotor kRollerSimGearbox = DCMotor.getKrakenX60Foc(1); - public static final double kRollerSimGearing = kRollerGearRatio; - public static final double kRollerSimMOI = 0.004; - - public static final double kPivotSimP = .15; - public static final double kPivotSimI = 0.0; - public static final double kPivotSimD = 0.0; - } - - public static final class ManipulatorConstants { - public static final double kWristGearRatio = (66.0 / 10.0) * (32.0 / 14.0); - // public static final double kWristGearRatio = 1.0; - public static final double kWristAbsoluteEncoderGearRatio = 32.0 / 14.0; - public static final double kRollerGearRatio = (58.0 / 16.0); - public static final double kRollerRadius = Units.inchesToMeters(3); - - public static final double kWristTolerance = 2.0; // degrees - - // the offset needs to be so that it starts at 180 degrees (all the way out) - // public static final Rotation2d kWristOffset = - // Rotation2d.fromDegrees(-78.662).plus(Rotation2d.fromDegrees(180.0)); - public static final Rotation2d kWristOffset = - Rotation2d.fromDegrees((-37.4) * kWristAbsoluteEncoderGearRatio); - // get owned shrihari - sri b is a better coder - // public static final Rotation2d kWristOffset = Rotation2d.fromDegrees(0.0); - - public static final double kRollerPositionTolerance = 10.0; // degrees - public static final LoggedTunableNumber kRollerFeedErrorTolerance = - new LoggedTunableNumber("Manipulator Roller Feed Error Tolerance", 75.0); - - // how many degrees to move after photoelectric is tripped - public static final LoggedTunableNumber kRollerIndexingPosition = - new LoggedTunableNumber("Manipulator Roller Indexing Position", 150.0); - - public static final LoggedTunableNumber kWristP = new LoggedTunableNumber("Wrist P", 55.0); - public static final LoggedTunableNumber kWristI = new LoggedTunableNumber("Wrist I", 0.0); - public static final LoggedTunableNumber kWristD = new LoggedTunableNumber("Wrist D", 0.3); - public static final LoggedTunableNumber kWristKS = new LoggedTunableNumber("Wrist kS", 0.25); - - public static final LoggedTunableNumber kWristStowAngle = - new LoggedTunableNumber("Wrist Stow Angle", 100.0); - public static final LoggedTunableNumber kWristIntakeAngle = - new LoggedTunableNumber("Wrist Intake Angle", 100.0); - public static final LoggedTunableNumber kWristScoringOffset = - new LoggedTunableNumber("Wrist Scoring Offset", 0.0); - public static final LoggedTunableNumber kWristAlgaeDescoringAngle = - new LoggedTunableNumber("Wrist Algae Descoring Angle", 30.0); - public static final LoggedTunableNumber kWristAlgaeHoldAngle = - new LoggedTunableNumber("Wrist Algae Hold Angle", 35.0); - public static final LoggedTunableNumber kWristAlgaeOuttakeAngle = - new LoggedTunableNumber("Wrist Algae Outtake Angle", 0.0); - - public static final LoggedTunableNumber kRollerStowVoltage = - new LoggedTunableNumber("Manipulator Roller Stow Voltage", 0.0); - public static final LoggedTunableNumber kRollerIntakeVoltage = - new LoggedTunableNumber("Manipulator Roller Intake Voltage", 2.0); - public static final LoggedTunableNumber kRollerIndexingVoltage = - new LoggedTunableNumber("Manipulator Roller Indexing Voltage", 1.0); - public static final LoggedTunableNumber kRollerEjectVoltage = - new LoggedTunableNumber("Manipulator Roller Eject Voltage", -3.0); - public static final LoggedTunableNumber kRollerL1ScoringVoltageAutoscore = - new LoggedTunableNumber("Manipulator Roller L1 Scoring Voltage Autoscore", 3.5); - public static final LoggedTunableNumber kRollerL1ScoringVoltageManual = - new LoggedTunableNumber("Manipulator Roller L1 Scoring Voltage Manual", 2.25); - public static final LoggedTunableNumber kRollerL2L3ScoringVoltage = - new LoggedTunableNumber("Manipulator Roller L2 L3 Scoring Voltage", 3.0); - public static final LoggedTunableNumber kRollerL4ScoringVoltage = - new LoggedTunableNumber("Manipulator Roller L4 Scoring Voltage", 3.0); - public static final LoggedTunableNumber kRollerAlgaeDescoringVoltage = - new LoggedTunableNumber("Manipulator Roller Algae Descoring Voltage", 3.0); - public static final LoggedTunableNumber kRollerAlgaeHoldVoltage = - new LoggedTunableNumber("Manipulator Roller Algae Hold Voltage", 1.0); - public static final LoggedTunableNumber kRollerAlgaeOuttakeVoltage = - new LoggedTunableNumber("Manipulator Roller Algae Outtake Voltage", -4.0); - public static final LoggedTunableNumber kRollerBargeVoltage = - new LoggedTunableNumber("Manipulator Roller Barge Voltage", -12.0); - - public static final LoggedTunableNumber kRollerP = - new LoggedTunableNumber("Manipulator Roller P", 20.0); - public static final LoggedTunableNumber kRollerI = - new LoggedTunableNumber("Manipulator Roller I", 0.0); - public static final LoggedTunableNumber kRollerD = - new LoggedTunableNumber("Manipulator Roller D", 0.0); - public static final LoggedTunableNumber kRollerKS = - new LoggedTunableNumber("Manipulator Roller kS", 0.22); - - public static final LoggedTunableNumber kCoralOuttakeTimeout = - new LoggedTunableNumber("Coral Outtake Timeout", 0.15); - - public static final LoggedTunableNumber kL1 = new LoggedTunableNumber("Wrist L1 Angle", 112.0); - public static final LoggedTunableNumber kL2 = new LoggedTunableNumber("Wrist L2 Angle", 55.0); - public static final LoggedTunableNumber kL3 = new LoggedTunableNumber("Wrist L3 Angle", 55.0); - public static final LoggedTunableNumber kL4 = new LoggedTunableNumber("Wrist L4 Angle", 40.0); - // Simulation constants - public static final DCMotor kWristSimGearbox = DCMotor.getKrakenX60Foc(1); - public static final double kWristSimGearing = kWristGearRatio; - public static final double kWristArmMass = Units.lbsToKilograms(3.373); - public static final double kWristArmLength = Units.inchesToMeters(7.75); - public static final double kWristSimMOI = - SingleJointedArmSim.estimateMOI(kWristArmLength, kWristArmMass); - public static final Rotation2d kWristMinAngle = Rotation2d.fromDegrees(0.0); - public static final Rotation2d kWristMaxAngle = Rotation2d.fromDegrees(130.0); - public static final boolean kSimSimulateGravity = false; - public static final Rotation2d kSimStartingAngle = Rotation2d.fromDegrees(Math.random() * 130); - public static final double kSimRollerP = 0.01; - public static final double kSimRollerI = 0.0; - public static final double kSimRollerD = 0.0; - public static final double kSimWristP = 0.150000; - public static final double kSimWristI = 0.0; - public static final double kSimWristD = 0.0; - - public static final DCMotor kRollerSimGearbox = DCMotor.getKrakenX60Foc(1); - public static final double kRollerSimGearing = kRollerGearRatio; - public static final double kRollerSimMOI = 0.004; - } - public static final class CurrentLimitConstants { // Drive public static final double kDriveDefaultSupplyCurrentLimit = 75.0; @@ -640,52 +284,8 @@ public static final class CurrentLimitConstants { public static final double kTurnDefaultStatorCurrentLimit = 120.0; // Intake - public static final double kIntakePivotDefaultSupplyLimit = 80.0; - public static final double kIntakePivotDefaultStatorLimit = 120.0; - - public static final double kIntakeRollerDefaultSupplyLimit = 80.0; - public static final double kIntakeRollerDefaultStatorLimit = 120.0; - - // Indexer - public static final double kIndexerDefaultSupplyLimit = 30.0; - public static final double kIndexerDefaultStatorLimit = 120.0; - - // Manipulator - public static final double kManipulatorWristDefaultSupplyLimit = 80.0; - public static final double kManipulatorWristDefaultStatorLimit = 120.0; - - public static final double kManipulatorRollerDefaultSupplyLimit = 80.0; - public static final double kManipulatorRollerDefaultStatorLimit = 120.0; - - // Elevator - public static final double kElevatorDefaultSupplyLimit = 65.0; - public static final double kElevatorDefaultStatorLimit = 95.0; - - // Climb - public static final double kClimbDefaultSupplyLimit = 80.0; - public static final double kClimbDefaultStatorLimit = 120.0; - } - - public static final class IndexerConstants { - - public static final double kGearRatio = 30.0 / 8.0; - public static final double kRollerRadius = Units.inchesToMeters(2); - - public static final LoggedTunableNumber kIndexerIdleVoltage = - new LoggedTunableNumber("Indexer Idle Voltage", 0.0); - public static final LoggedTunableNumber kIndexerIndexingVoltage = - new LoggedTunableNumber("Indexer Indexing Voltage", 3.71); - public static final LoggedTunableNumber kIndexerTopIndexingVoltage = - new LoggedTunableNumber("Indexer Top Indexing Voltage", 2.5); - public static final LoggedTunableNumber kIndexerEjectVoltage = - new LoggedTunableNumber("Indexer Eject Voltage", -5.0); - public static final LoggedTunableNumber kIndexerTopEjectVoltage = - new LoggedTunableNumber("Indexer Top Eject Voltage", -2.5); - - // Simulation constants - public static final DCMotor kSimGearbox = DCMotor.getKrakenX60Foc(2); - public static final double kSimGearing = kGearRatio; - public static final double kSimMOI = 0.005; + public static final double kIntakeDefaultSupplyLimit = 30.0; + public static final double kIntakeDefaultStatorLimit = 120.0; } public static final class Ports { @@ -707,41 +307,11 @@ public static final class Ports { public static final int kPigeon = 22; - public static final String kDriveCanivoreName = "Drivetrain"; - - public static final int kClimbMotor = 36; - - public static final int kIntakeRoller = 45; - public static final int kIntakePivot = 46; - public static final int kIntakeAbsoluteEncoder = 9; + public static final CANBus kDriveCanivoreName = new CANBus("Drivetrain"); - public static final int kManipulatorRoller = 29; - public static final int kManipulatorWrist = 30; - public static final int kManipulatorAbsoluteEncoder = 8; - public static final int kManipulatorPhotoElectricOne = 6; - public static final int kManipulatorPhotoElectricTwo = 7; - public static final int kFunnelPhotoElectricOne = 4; - public static final int kFunnelPhotoElectricTwo = 5; - - public static final int kIndexerSideMotor = 25; - public static final int kIndexerTopMotor = 26; - - public static final int kLed = 9; - - public static final int kElevatorLead = 23; - public static final int kElevatorFollowing = 24; - - public static final String kMainCanivoreName = "Main"; - } + public static final int kIntake = 12; - /** Whether or not subsystems are enabled on the proto board */ - public static final class ProtoConstants { - public static final boolean kRealDrive = true; - public static final boolean kRealIntake = true; - public static final boolean kRealIndexer = true; - public static final boolean kRealManipulator = true; - public static final boolean kRealClimb = false; - public static final boolean kRealElevator = false; + public static final CANBus kMainCanivoreName = new CANBus("Main"); } public static final class FieldConstants { diff --git a/src/main/java/frc/robot/RobotContainer.java b/src/main/java/frc/robot/RobotContainer.java index fc5d710..b0fa8f0 100644 --- a/src/main/java/frc/robot/RobotContainer.java +++ b/src/main/java/frc/robot/RobotContainer.java @@ -4,21 +4,26 @@ import edu.wpi.first.wpilibj.RobotBase; import edu.wpi.first.wpilibj2.command.Command; import edu.wpi.first.wpilibj2.command.Commands; -import frc.robot.commands.drive.DriveCommands; +import frc.robot.Constants.Ports; +import frc.robot.RobotState.RobotAction; import frc.robot.oi.DriverControls; import frc.robot.oi.DriverControlsPS5; import frc.robot.subsystems.drive.Drive; import frc.robot.subsystems.drive.GyroIOPigeon2; import frc.robot.subsystems.drive.ModuleIOSim; import frc.robot.subsystems.drive.ModuleIOTalonFX; +import frc.robot.subsystems.intake.Intake; +import frc.robot.subsystems.intake.IntakeIOKraken; +import frc.robot.subsystems.intake.IntakeIOSim; import org.littletonrobotics.junction.networktables.LoggedDashboardChooser; public class RobotContainer { private Drive m_drive; + private Intake m_intake; // Controller - private DriverControls m_driverControls; + private DriverControls m_controller; // Dashboard inputs private LoggedDashboardChooser m_autoChooser; @@ -27,7 +32,7 @@ public RobotContainer() { configureSubsystems(); configureCommands(); configureControllers(); - configureBindings(); + configureButtonBindings(); } public void configureSubsystems() { @@ -39,6 +44,7 @@ public void configureSubsystems() { new ModuleIOTalonFX(1), new ModuleIOTalonFX(2), new ModuleIOTalonFX(3)); + m_intake = new Intake(new IntakeIOKraken(Ports.kIntake, Ports.kDriveCanivoreName)); } else { m_drive = new Drive( @@ -47,32 +53,44 @@ public void configureSubsystems() { new ModuleIOSim(), new ModuleIOSim(), new ModuleIOSim()); + m_intake = new Intake(new IntakeIOSim()); } } public void configureCommands() { - RobotState.startInstance(m_drive); + RobotState.startInstance(m_drive, m_intake); } public void configureControllers() { - m_driverControls = new DriverControlsPS5(0); + m_controller = new DriverControlsPS5(0); } - public void configureBindings() { - m_drive.setDefaultCommand( - DriveCommands.joystickDrive( - m_drive, - m_driverControls::getForward, - m_driverControls::getStrafe, - m_driverControls::getTurn, - false)); - m_driverControls + public void configureButtonBindings() { + // m_drive.setDefaultCommand( + // DriveCommands.joystickDrive( + // m_drive, + // m_controller::getForward, + // m_controller::getStrafe, + // m_controller::getTurn, + // false)); + m_controller .resetFieldCentric() .onTrue( Commands.runOnce( () -> { m_drive.setPose(new Pose2d()); })); + m_controller + .intake() + .onTrue( + Commands.runOnce( + (() -> { + if (RobotState.getInstance().getCurrAction() != RobotAction.kIntaking) { + RobotState.getInstance().updateRobotAction(RobotAction.kIntaking); + } else { + RobotState.getInstance().updateRobotAction(RobotAction.kTeleopDefault); + } + }))); } public Command getAutonomousCommand() { diff --git a/src/main/java/frc/robot/RobotState.java b/src/main/java/frc/robot/RobotState.java index 00dfaa4..866fed9 100644 --- a/src/main/java/frc/robot/RobotState.java +++ b/src/main/java/frc/robot/RobotState.java @@ -2,6 +2,8 @@ import frc.robot.subsystems.drive.Drive; import frc.robot.subsystems.drive.Drive.DriveProfiles; +import frc.robot.subsystems.intake.Intake; +import frc.robot.subsystems.intake.Intake.IntakeState; import frc.robot.util.SubsystemProfiles; import java.util.HashMap; import org.littletonrobotics.junction.Logger; @@ -10,19 +12,23 @@ public class RobotState { public enum RobotAction { kAutoDefault, - kTeleopDefault + kTeleopDefault, + kIntaking } private Drive m_drive; + private Intake m_intake; private SubsystemProfiles m_profiles; private static RobotState m_instance; - public RobotState(Drive drive) { + public RobotState(Drive drive, Intake intake) { m_drive = drive; + m_intake = intake; HashMap hash = new HashMap<>(); hash.put(RobotAction.kAutoDefault, () -> {}); hash.put(RobotAction.kTeleopDefault, () -> {}); + hash.put(RobotAction.kIntaking, () -> {}); m_profiles = new SubsystemProfiles<>(hash, RobotAction.kTeleopDefault); } @@ -34,6 +40,7 @@ public void updateRobotState() { public void updateRobotAction(RobotAction action) { DriveProfiles newDriveState = DriveProfiles.kDefault; + IntakeState newIntakeState = IntakeState.kIdle; switch (action) { case kAutoDefault: @@ -42,6 +49,9 @@ public void updateRobotAction(RobotAction action) { case kTeleopDefault: newDriveState = DriveProfiles.kDefault; break; + case kIntaking: + newIntakeState = IntakeState.kIntaking; + break; default: break; } @@ -50,6 +60,10 @@ public void updateRobotAction(RobotAction action) { m_drive.updateProfile(newDriveState); } + if (newIntakeState != m_intake.getState()) { + m_intake.updateState(newIntakeState); + } + m_profiles.setCurrentProfile(action); } @@ -57,9 +71,9 @@ public static RobotState getInstance() { return m_instance; } - public static RobotState startInstance(Drive drive) { + public static RobotState startInstance(Drive drive, Intake intake) { if (m_instance == null) { - m_instance = new RobotState(drive); + m_instance = new RobotState(drive, intake); } return m_instance; } diff --git a/src/main/java/frc/robot/oi/DriverControls.java b/src/main/java/frc/robot/oi/DriverControls.java index afe64cc..e0a516f 100644 --- a/src/main/java/frc/robot/oi/DriverControls.java +++ b/src/main/java/frc/robot/oi/DriverControls.java @@ -10,4 +10,6 @@ public interface DriverControls { public double getTurn(); public Trigger resetFieldCentric(); + + public Trigger intake(); } diff --git a/src/main/java/frc/robot/oi/DriverControlsPS5.java b/src/main/java/frc/robot/oi/DriverControlsPS5.java index 881f590..7e257fd 100644 --- a/src/main/java/frc/robot/oi/DriverControlsPS5.java +++ b/src/main/java/frc/robot/oi/DriverControlsPS5.java @@ -22,11 +22,16 @@ public double getStrafe() { @Override public double getTurn() { - return -m_controller.getRightX(); + return m_controller.getRightX(); } @Override public Trigger resetFieldCentric() { return m_controller.touchpad(); } + + @Override + public Trigger intake() { + return m_controller.R1(); + } } diff --git a/src/main/java/frc/robot/oi/DriverControlsXbox.java b/src/main/java/frc/robot/oi/DriverControlsXbox.java index 2774ca3..0555daf 100644 --- a/src/main/java/frc/robot/oi/DriverControlsXbox.java +++ b/src/main/java/frc/robot/oi/DriverControlsXbox.java @@ -29,4 +29,9 @@ public double getTurn() { public Trigger resetFieldCentric() { return m_controller.start(); } + + @Override + public Trigger intake() { + return m_controller.rightBumper(); + } } diff --git a/src/main/java/frc/robot/subsystems/drive/ModuleIOTalonFX.java b/src/main/java/frc/robot/subsystems/drive/ModuleIOTalonFX.java index 43e475f..24e028f 100644 --- a/src/main/java/frc/robot/subsystems/drive/ModuleIOTalonFX.java +++ b/src/main/java/frc/robot/subsystems/drive/ModuleIOTalonFX.java @@ -80,7 +80,7 @@ public class ModuleIOTalonFX implements ModuleIO { private final StatusSignal m_cancoderSupplyVoltage; // for checking if cancoder is connected - private final boolean m_isTurnMotorInverted = true; + private final boolean m_isTurnMotorInverted = false; private final boolean m_isCancoderInverted = false; private final Rotation2d m_absoluteEncoderOffset; diff --git a/src/main/java/frc/robot/subsystems/intake/Intake.java b/src/main/java/frc/robot/subsystems/intake/Intake.java new file mode 100644 index 0000000..d1c252d --- /dev/null +++ b/src/main/java/frc/robot/subsystems/intake/Intake.java @@ -0,0 +1,52 @@ +package frc.robot.subsystems.intake; + +import edu.wpi.first.wpilibj2.command.SubsystemBase; +import frc.robot.Constants.IntakeConstants; +import frc.robot.util.SubsystemProfiles; +import java.util.HashMap; +import org.littletonrobotics.junction.Logger; + +public class Intake extends SubsystemBase { + private IntakeIO m_io; + private IntakeInputsAutoLogged m_inputs; + private SubsystemProfiles m_profiles; + + public enum IntakeState { + kIdle, + kIntaking + } + + public Intake(IntakeIO io) { + m_io = io; + m_inputs = new IntakeInputsAutoLogged(); + + HashMap hash = new HashMap<>(); + hash.put(IntakeState.kIdle, this::idlePeriodic); + hash.put(IntakeState.kIntaking, this::intakingPeriodic); + m_profiles = new SubsystemProfiles<>(hash, IntakeState.kIdle); + } + + @Override + public void periodic() { + m_io.updateInputs(m_inputs); + m_profiles.getPeriodicFunctionTimed().run(); + Logger.processInputs("Intake", m_inputs); + Logger.recordOutput("Intake/IntakeState", m_profiles.getCurrentProfile()); + } + + public void idlePeriodic() { + m_io.setVoltage(IntakeConstants.kIdleVoltage.get()); + } + + public void intakingPeriodic() { + m_io.setVoltage(IntakeConstants.kIntakingVoltage.get()); + } + + public IntakeState getState() { + return m_profiles.getCurrentProfile(); + } + + public void updateState(IntakeState state) { + m_profiles.setCurrentProfile(state); + } +} diff --git a/src/main/java/frc/robot/subsystems/intake/IntakeIO.java b/src/main/java/frc/robot/subsystems/intake/IntakeIO.java new file mode 100644 index 0000000..22618ad --- /dev/null +++ b/src/main/java/frc/robot/subsystems/intake/IntakeIO.java @@ -0,0 +1,22 @@ +package frc.robot.subsystems.intake; + +import org.littletonrobotics.junction.AutoLog; + +public interface IntakeIO { + @AutoLog + public static class IntakeInputs { + public double position; + public double velocityRPS; + public double supplyCurrent; + public double statorCurrent; + public double voltage; + public double temperature; + public boolean connected; + } + + public void updateInputs(IntakeInputs inputs); + + public void setVoltage(double volts); + + public void setCurrentLimits(double supplyLimit); +} diff --git a/src/main/java/frc/robot/subsystems/intake/IntakeIOKraken.java b/src/main/java/frc/robot/subsystems/intake/IntakeIOKraken.java new file mode 100644 index 0000000..d59231d --- /dev/null +++ b/src/main/java/frc/robot/subsystems/intake/IntakeIOKraken.java @@ -0,0 +1,102 @@ +package frc.robot.subsystems.intake; + +import com.ctre.phoenix6.CANBus; +import com.ctre.phoenix6.StatusSignal; +import com.ctre.phoenix6.configs.CurrentLimitsConfigs; +import com.ctre.phoenix6.configs.FeedbackConfigs; +import com.ctre.phoenix6.configs.MotorOutputConfigs; +import com.ctre.phoenix6.configs.TalonFXConfiguration; +import com.ctre.phoenix6.controls.VoltageOut; +import com.ctre.phoenix6.hardware.TalonFX; +import com.ctre.phoenix6.signals.ConnectedMotorValue; +import com.ctre.phoenix6.signals.InvertedValue; +import com.ctre.phoenix6.signals.NeutralModeValue; +import edu.wpi.first.units.measure.AngularVelocity; +import edu.wpi.first.units.measure.Current; +import edu.wpi.first.units.measure.Temperature; +import edu.wpi.first.units.measure.Voltage; +import frc.robot.Constants.CurrentLimitConstants; +import frc.robot.Constants.IntakeConstants; + +public class IntakeIOKraken implements IntakeIO { + private TalonFX m_motor; + + private TalonFXConfiguration m_config; + + private VoltageOut m_voltage = new VoltageOut(0).withEnableFOC(true); + + private StatusSignal m_connected; + private StatusSignal m_voltageSignal; + private StatusSignal m_velocity; + private StatusSignal m_supplyCurrent; + private StatusSignal m_statorCurrent; + private StatusSignal m_temperature; + + public IntakeIOKraken(int port, CANBus bus) { + m_motor = new TalonFX(port, bus); + + var currentLimits = + new CurrentLimitsConfigs() + .withSupplyCurrentLimitEnable(true) + .withSupplyCurrentLimit(CurrentLimitConstants.kIntakeDefaultSupplyLimit) + .withStatorCurrentLimitEnable(true) + .withStatorCurrentLimit(CurrentLimitConstants.kIntakeDefaultStatorLimit); + + var feedbackConfig = + new FeedbackConfigs().withSensorToMechanismRatio(IntakeConstants.kGearRatio); + + var motorOutput = + new MotorOutputConfigs() + .withNeutralMode(NeutralModeValue.Brake) + .withInverted(InvertedValue.Clockwise_Positive); + + m_config = + new TalonFXConfiguration() + .withCurrentLimits(currentLimits) + .withFeedback(feedbackConfig) + .withMotorOutput(motorOutput); + + m_motor.getConfigurator().apply(m_config); + + m_connected = m_motor.getConnectedMotor(); + m_voltageSignal = m_motor.getMotorVoltage(); + m_velocity = m_motor.getVelocity(); + m_supplyCurrent = m_motor.getSupplyCurrent(); + m_statorCurrent = m_motor.getStatorCurrent(); + m_temperature = m_motor.getDeviceTemp(); + + StatusSignal.setUpdateFrequencyForAll( + 50, + m_connected, + m_voltageSignal, + m_velocity, + m_supplyCurrent, + m_statorCurrent, + m_temperature); + } + + @Override + public void updateInputs(IntakeInputs inputs) { + StatusSignal.refreshAll( + m_connected, m_voltageSignal, m_velocity, m_supplyCurrent, m_statorCurrent, m_temperature); + + inputs.connected = m_connected.getValue() != ConnectedMotorValue.Unknown; + inputs.voltage = m_voltageSignal.getValueAsDouble(); + inputs.velocityRPS = m_velocity.getValueAsDouble(); + inputs.supplyCurrent = m_supplyCurrent.getValueAsDouble(); + inputs.statorCurrent = m_statorCurrent.getValueAsDouble(); + inputs.temperature = m_temperature.getValueAsDouble(); + } + + @Override + public void setVoltage(double volts) { + m_motor.setControl(m_voltage.withOutput(volts)); + } + + @Override + public void setCurrentLimits(double supplyLimit) { + m_motor + .getConfigurator() + .apply(m_config.CurrentLimits.withSupplyCurrentLimit(supplyLimit), 0.0); + } +} diff --git a/src/main/java/frc/robot/subsystems/intake/IntakeIOReplay.java b/src/main/java/frc/robot/subsystems/intake/IntakeIOReplay.java new file mode 100644 index 0000000..ac0aab0 --- /dev/null +++ b/src/main/java/frc/robot/subsystems/intake/IntakeIOReplay.java @@ -0,0 +1,12 @@ +package frc.robot.subsystems.intake; + +public class IntakeIOReplay implements IntakeIO { + @Override + public void updateInputs(IntakeInputs inputs) {} + + @Override + public void setVoltage(double Voltage) {} + + @Override + public void setCurrentLimits(double supplyLimit) {} +} diff --git a/src/main/java/frc/robot/subsystems/intake/IntakeIOSim.java b/src/main/java/frc/robot/subsystems/intake/IntakeIOSim.java new file mode 100644 index 0000000..a5b63b5 --- /dev/null +++ b/src/main/java/frc/robot/subsystems/intake/IntakeIOSim.java @@ -0,0 +1,39 @@ +package frc.robot.subsystems.intake; + +import edu.wpi.first.math.system.plant.LinearSystemId; +import edu.wpi.first.wpilibj.simulation.DCMotorSim; +import frc.robot.Constants.IntakeConstants; + +public class IntakeIOSim implements IntakeIO { + private DCMotorSim m_sim; + + private double m_voltage = 0.0; + + public IntakeIOSim() { + var plant = + LinearSystemId.createDCMotorSystem( + IntakeConstants.kSimGearbox, IntakeConstants.kSimMOI, IntakeConstants.kGearRatio); + + m_sim = new DCMotorSim(plant, IntakeConstants.kSimGearbox); + } + + @Override + public void updateInputs(IntakeInputs inputs) { + m_sim.setInputVoltage(m_voltage); + m_sim.update(0.02); + + inputs.position = m_sim.getAngularPositionRotations(); + inputs.velocityRPS = m_sim.getAngularVelocityRPM() / 60; + inputs.supplyCurrent = m_sim.getCurrentDrawAmps(); + inputs.voltage = m_voltage; + inputs.connected = true; + } + + @Override + public void setVoltage(double volts) { + m_voltage = volts; + } + + @Override + public void setCurrentLimits(double supplyLimit) {} +} diff --git a/vendordeps/AdvantageKit.json b/vendordeps/AdvantageKit.json index 2707c2b..2faa4db 100644 --- a/vendordeps/AdvantageKit.json +++ b/vendordeps/AdvantageKit.json @@ -1,9 +1,9 @@ { "fileName": "AdvantageKit.json", "name": "AdvantageKit", - "version": "4.1.2", + "version": "26.0.0", "uuid": "d820cc26-74e3-11ec-90d6-0242ac120003", - "frcYear": "2025", + "frcYear": "2026", "mavenUrls": [ "https://frcmaven.wpi.edu/artifactory/littletonrobotics-mvn-release/" ], @@ -12,14 +12,14 @@ { "groupId": "org.littletonrobotics.akit", "artifactId": "akit-java", - "version": "4.1.2" + "version": "26.0.0" } ], "jniDependencies": [ { "groupId": "org.littletonrobotics.akit", "artifactId": "akit-wpilibio", - "version": "4.1.2", + "version": "26.0.0", "skipInvalidPlatforms": false, "isJar": false, "validPlatforms": [ diff --git a/vendordeps/PathplannerLib-2025.2.7.json b/vendordeps/PathplannerLib-2026.1.2.json similarity index 84% rename from vendordeps/PathplannerLib-2025.2.7.json rename to vendordeps/PathplannerLib-2026.1.2.json index d0b6939..5f04ffa 100644 --- a/vendordeps/PathplannerLib-2025.2.7.json +++ b/vendordeps/PathplannerLib-2026.1.2.json @@ -1,9 +1,9 @@ { - "fileName": "PathplannerLib-2025.2.7.json", + "fileName": "PathplannerLib-2026.1.2.json", "name": "PathplannerLib", - "version": "2025.2.7", + "version": "2026.1.2", "uuid": "1b42324f-17c6-4875-8e77-1c312bc8c786", - "frcYear": "2025", + "frcYear": "2026", "mavenUrls": [ "https://3015rangerrobotics.github.io/pathplannerlib/repo" ], @@ -12,7 +12,7 @@ { "groupId": "com.pathplanner.lib", "artifactId": "PathplannerLib-java", - "version": "2025.2.7" + "version": "2026.1.2" } ], "jniDependencies": [], @@ -20,7 +20,7 @@ { "groupId": "com.pathplanner.lib", "artifactId": "PathplannerLib-cpp", - "version": "2025.2.7", + "version": "2026.1.2", "libName": "PathplannerLib", "headerClassifier": "headers", "sharedLibrary": false, diff --git a/vendordeps/Phoenix6-frc2025-latest.json b/vendordeps/Phoenix6-26.1.0.json similarity index 85% rename from vendordeps/Phoenix6-frc2025-latest.json rename to vendordeps/Phoenix6-26.1.0.json index ce44ce4..5d2d04d 100644 --- a/vendordeps/Phoenix6-frc2025-latest.json +++ b/vendordeps/Phoenix6-26.1.0.json @@ -1,32 +1,32 @@ { - "fileName": "Phoenix6-frc2025-latest.json", + "fileName": "Phoenix6-26.1.0.json", "name": "CTRE-Phoenix (v6)", - "version": "25.4.0", - "frcYear": "2025", + "version": "26.1.0", + "frcYear": "2026", "uuid": "e995de00-2c64-4df5-8831-c1441420ff19", "mavenUrls": [ "https://maven.ctr-electronics.com/release/" ], - "jsonUrl": "https://maven.ctr-electronics.com/release/com/ctre/phoenix6/latest/Phoenix6-frc2025-latest.json", + "jsonUrl": "https://maven.ctr-electronics.com/release/com/ctre/phoenix6/latest/Phoenix6-frc2026-latest.json", "conflictsWith": [ { "uuid": "e7900d8d-826f-4dca-a1ff-182f658e98af", "errorMessage": "Users can not have both the replay and regular Phoenix 6 vendordeps in their robot program.", - "offlineFileName": "Phoenix6-replay-frc2025-latest.json" + "offlineFileName": "Phoenix6-replay-frc2026-latest.json" } ], "javaDependencies": [ { "groupId": "com.ctre.phoenix6", "artifactId": "wpiapi-java", - "version": "25.4.0" + "version": "26.1.0" } ], "jniDependencies": [ { "groupId": "com.ctre.phoenix6", "artifactId": "api-cpp", - "version": "25.4.0", + "version": "26.1.0", "isJar": false, "skipInvalidPlatforms": true, "validPlatforms": [ @@ -40,7 +40,7 @@ { "groupId": "com.ctre.phoenix6", "artifactId": "tools", - "version": "25.4.0", + "version": "26.1.0", "isJar": false, "skipInvalidPlatforms": true, "validPlatforms": [ @@ -54,7 +54,7 @@ { "groupId": "com.ctre.phoenix6.sim", "artifactId": "api-cpp-sim", - "version": "25.4.0", + "version": "26.1.0", "isJar": false, "skipInvalidPlatforms": true, "validPlatforms": [ @@ -68,7 +68,7 @@ { "groupId": "com.ctre.phoenix6.sim", "artifactId": "tools-sim", - "version": "25.4.0", + "version": "26.1.0", "isJar": false, "skipInvalidPlatforms": true, "validPlatforms": [ @@ -82,7 +82,7 @@ { "groupId": "com.ctre.phoenix6.sim", "artifactId": "simTalonSRX", - "version": "25.4.0", + "version": "26.1.0", "isJar": false, "skipInvalidPlatforms": true, "validPlatforms": [ @@ -96,7 +96,7 @@ { "groupId": "com.ctre.phoenix6.sim", "artifactId": "simVictorSPX", - "version": "25.4.0", + "version": "26.1.0", "isJar": false, "skipInvalidPlatforms": true, "validPlatforms": [ @@ -110,21 +110,7 @@ { "groupId": "com.ctre.phoenix6.sim", "artifactId": "simPigeonIMU", - "version": "25.4.0", - "isJar": false, - "skipInvalidPlatforms": true, - "validPlatforms": [ - "windowsx86-64", - "linuxx86-64", - "linuxarm64", - "osxuniversal" - ], - "simMode": "swsim" - }, - { - "groupId": "com.ctre.phoenix6.sim", - "artifactId": "simCANCoder", - "version": "25.4.0", + "version": "26.1.0", "isJar": false, "skipInvalidPlatforms": true, "validPlatforms": [ @@ -138,7 +124,7 @@ { "groupId": "com.ctre.phoenix6.sim", "artifactId": "simProTalonFX", - "version": "25.4.0", + "version": "26.1.0", "isJar": false, "skipInvalidPlatforms": true, "validPlatforms": [ @@ -152,7 +138,7 @@ { "groupId": "com.ctre.phoenix6.sim", "artifactId": "simProTalonFXS", - "version": "25.4.0", + "version": "26.1.0", "isJar": false, "skipInvalidPlatforms": true, "validPlatforms": [ @@ -166,7 +152,7 @@ { "groupId": "com.ctre.phoenix6.sim", "artifactId": "simProCANcoder", - "version": "25.4.0", + "version": "26.1.0", "isJar": false, "skipInvalidPlatforms": true, "validPlatforms": [ @@ -180,7 +166,7 @@ { "groupId": "com.ctre.phoenix6.sim", "artifactId": "simProPigeon2", - "version": "25.4.0", + "version": "26.1.0", "isJar": false, "skipInvalidPlatforms": true, "validPlatforms": [ @@ -194,7 +180,7 @@ { "groupId": "com.ctre.phoenix6.sim", "artifactId": "simProCANrange", - "version": "25.4.0", + "version": "26.1.0", "isJar": false, "skipInvalidPlatforms": true, "validPlatforms": [ @@ -208,7 +194,7 @@ { "groupId": "com.ctre.phoenix6.sim", "artifactId": "simProCANdi", - "version": "25.4.0", + "version": "26.1.0", "isJar": false, "skipInvalidPlatforms": true, "validPlatforms": [ @@ -222,7 +208,7 @@ { "groupId": "com.ctre.phoenix6.sim", "artifactId": "simProCANdle", - "version": "25.4.0", + "version": "26.1.0", "isJar": false, "skipInvalidPlatforms": true, "validPlatforms": [ @@ -238,7 +224,7 @@ { "groupId": "com.ctre.phoenix6", "artifactId": "wpiapi-cpp", - "version": "25.4.0", + "version": "26.1.0", "libName": "CTRE_Phoenix6_WPI", "headerClassifier": "headers", "sharedLibrary": true, @@ -254,7 +240,7 @@ { "groupId": "com.ctre.phoenix6", "artifactId": "tools", - "version": "25.4.0", + "version": "26.1.0", "libName": "CTRE_PhoenixTools", "headerClassifier": "headers", "sharedLibrary": true, @@ -270,7 +256,7 @@ { "groupId": "com.ctre.phoenix6.sim", "artifactId": "wpiapi-cpp-sim", - "version": "25.4.0", + "version": "26.1.0", "libName": "CTRE_Phoenix6_WPISim", "headerClassifier": "headers", "sharedLibrary": true, @@ -286,7 +272,7 @@ { "groupId": "com.ctre.phoenix6.sim", "artifactId": "tools-sim", - "version": "25.4.0", + "version": "26.1.0", "libName": "CTRE_PhoenixTools_Sim", "headerClassifier": "headers", "sharedLibrary": true, @@ -302,7 +288,7 @@ { "groupId": "com.ctre.phoenix6.sim", "artifactId": "simTalonSRX", - "version": "25.4.0", + "version": "26.1.0", "libName": "CTRE_SimTalonSRX", "headerClassifier": "headers", "sharedLibrary": true, @@ -318,7 +304,7 @@ { "groupId": "com.ctre.phoenix6.sim", "artifactId": "simVictorSPX", - "version": "25.4.0", + "version": "26.1.0", "libName": "CTRE_SimVictorSPX", "headerClassifier": "headers", "sharedLibrary": true, @@ -334,7 +320,7 @@ { "groupId": "com.ctre.phoenix6.sim", "artifactId": "simPigeonIMU", - "version": "25.4.0", + "version": "26.1.0", "libName": "CTRE_SimPigeonIMU", "headerClassifier": "headers", "sharedLibrary": true, @@ -347,26 +333,10 @@ ], "simMode": "swsim" }, - { - "groupId": "com.ctre.phoenix6.sim", - "artifactId": "simCANCoder", - "version": "25.4.0", - "libName": "CTRE_SimCANCoder", - "headerClassifier": "headers", - "sharedLibrary": true, - "skipInvalidPlatforms": true, - "binaryPlatforms": [ - "windowsx86-64", - "linuxx86-64", - "linuxarm64", - "osxuniversal" - ], - "simMode": "swsim" - }, { "groupId": "com.ctre.phoenix6.sim", "artifactId": "simProTalonFX", - "version": "25.4.0", + "version": "26.1.0", "libName": "CTRE_SimProTalonFX", "headerClassifier": "headers", "sharedLibrary": true, @@ -382,7 +352,7 @@ { "groupId": "com.ctre.phoenix6.sim", "artifactId": "simProTalonFXS", - "version": "25.4.0", + "version": "26.1.0", "libName": "CTRE_SimProTalonFXS", "headerClassifier": "headers", "sharedLibrary": true, @@ -398,7 +368,7 @@ { "groupId": "com.ctre.phoenix6.sim", "artifactId": "simProCANcoder", - "version": "25.4.0", + "version": "26.1.0", "libName": "CTRE_SimProCANcoder", "headerClassifier": "headers", "sharedLibrary": true, @@ -414,7 +384,7 @@ { "groupId": "com.ctre.phoenix6.sim", "artifactId": "simProPigeon2", - "version": "25.4.0", + "version": "26.1.0", "libName": "CTRE_SimProPigeon2", "headerClassifier": "headers", "sharedLibrary": true, @@ -430,7 +400,7 @@ { "groupId": "com.ctre.phoenix6.sim", "artifactId": "simProCANrange", - "version": "25.4.0", + "version": "26.1.0", "libName": "CTRE_SimProCANrange", "headerClassifier": "headers", "sharedLibrary": true, @@ -446,7 +416,7 @@ { "groupId": "com.ctre.phoenix6.sim", "artifactId": "simProCANdi", - "version": "25.4.0", + "version": "26.1.0", "libName": "CTRE_SimProCANdi", "headerClassifier": "headers", "sharedLibrary": true, @@ -462,7 +432,7 @@ { "groupId": "com.ctre.phoenix6.sim", "artifactId": "simProCANdle", - "version": "25.4.0", + "version": "26.1.0", "libName": "CTRE_SimProCANdle", "headerClassifier": "headers", "sharedLibrary": true, diff --git a/vendordeps/WPILibNewCommands.json b/vendordeps/WPILibNewCommands.json index 3718e0a..d90630e 100644 --- a/vendordeps/WPILibNewCommands.json +++ b/vendordeps/WPILibNewCommands.json @@ -3,7 +3,7 @@ "name": "WPILib-New-Commands", "version": "1.0.0", "uuid": "111e20f7-815e-48f8-9dd6-e675ce75b266", - "frcYear": "2025", + "frcYear": "2026", "mavenUrls": [], "jsonUrl": "", "javaDependencies": [ @@ -25,6 +25,7 @@ "sharedLibrary": true, "skipInvalidPlatforms": true, "binaryPlatforms": [ + "linuxsystemcore", "linuxathena", "linuxarm32", "linuxarm64",