From 958f9f41122a2139a5ab88ec26c099398be42566 Mon Sep 17 00:00:00 2001 From: iefomit <108955303+iefomit@users.noreply.github.com> Date: Sun, 23 Aug 2026 22:40:31 -0700 Subject: [PATCH] more api --- build.gradle | 1 + src/main/java/frc/robot/Robot.java | 10 +++++----- src/main/java/frc/robot/RobotContainer.java | 18 +++++++++--------- .../auto_comm/ChoreoPathCommandBuilder.java | 2 +- .../commands/auto_comm/DynamicAutoBuilder.java | 1 - .../drive_comm/DefaultDriveCommand.java | 4 ++-- .../robot/commands/drive_comm/GoToPose.java | 6 +++--- .../commands/drive_comm/SetFormationX.java | 1 - .../TrajectoryPresetSteerAngles.java | 4 ++-- .../frc/robot/constants/AutoConstants.java | 2 +- .../controls/GameControllerDriverConfig.java | 4 ++-- .../controls/PS5ControllerDriverConfig.java | 4 ++-- .../controls/PS5XboxModeDriverConfig.java | 4 ++-- .../java/frc/robot/subsystems/LED/LED.java | 6 +++--- .../subsystems/drivetrain/Drivetrain.java | 3 ++- .../robot/subsystems/drivetrain/Module.java | 5 ++--- .../java/frc/robot/util/AngledElevatorSim.java | 2 +- src/main/java/frc/robot/util/ClimbArmSim.java | 9 ++++----- .../java/frc/robot/util/ConversionUtils.java | 4 ++-- src/main/java/frc/robot/util/Elastic.java | 8 ++++++-- .../java/frc/robot/util/PathGroupLoader.java | 6 +++--- .../SwerveStuff/SwerveSetpointGenerator.java | 6 +++--- .../frc/robot/util/Vision/DetectedObject.java | 6 +++--- .../java/frc/robot/util/Vision/Vision.java | 3 ++- 24 files changed, 61 insertions(+), 58 deletions(-) diff --git a/build.gradle b/build.gradle index 55508d0..92b86a0 100644 --- a/build.gradle +++ b/build.gradle @@ -60,6 +60,7 @@ dependencies { annotationProcessor wpi.java.deps.wpilibAnnotations() implementation wpi.java.deps.wpilib() implementation wpi.java.vendor.java() + implementation "com.fasterxml.jackson.core:jackson-databind:2.17.2" systemcoreDebug wpi.java.deps.wpilibJniDebug(wpi.platforms.systemcore) systemcoreDebug wpi.java.vendor.jniDebug(wpi.platforms.systemcore) diff --git a/src/main/java/frc/robot/Robot.java b/src/main/java/frc/robot/Robot.java index 4218cf7..1627b83 100644 --- a/src/main/java/frc/robot/Robot.java +++ b/src/main/java/frc/robot/Robot.java @@ -12,11 +12,11 @@ import org.littletonrobotics.junction.Logger; import org.littletonrobotics.junction.networktables.NT4Publisher; import org.littletonrobotics.junction.wpilog.WPILOGReader; import org.littletonrobotics.junction.wpilog.WPILOGWriter; - -import au.grapplerobotics.CanBridge; +// TODO: 2027-ALPHA-FIX - Re-enable grapplerobotics dep when updated +// import au.grapplerobotics.CanBridge; import org.wpilib.net.PortForwarder; import org.wpilib.driverstation.DriverStation; -import org.wpilib.driverstation.DriverStation.Alliance; +import org.wpilib.driverstation.Alliance; import org.wpilib.system.RobotController; import org.wpilib.command2.Command; import org.wpilib.command2.CommandScheduler; @@ -36,7 +36,7 @@ public class Robot extends LoggedRobot { private RobotContainer robotContainer; public Robot() { - CanBridge.runTCP(); + // CanBridge.runTCP(); PortForwarder.add(5800, Constants.VISION_CAMERA_HOST, 5800); PortForwarder.add(1182, Constants.VISION_CAMERA_HOST, 1182); @@ -198,6 +198,6 @@ public class Robot extends LoggedRobot { public static Alliance getAlliance() { Optional dsAlliance = DriverStation.getAlliance(); if (dsAlliance.isPresent()) return dsAlliance.get(); - else return Alliance.Red; // default to Red alliance + else return Alliance.RED; // default to RED alliance } } diff --git a/src/main/java/frc/robot/RobotContainer.java b/src/main/java/frc/robot/RobotContainer.java index 5d21939..3105089 100644 --- a/src/main/java/frc/robot/RobotContainer.java +++ b/src/main/java/frc/robot/RobotContainer.java @@ -7,10 +7,10 @@ import org.littletonrobotics.junction.Logger; import com.pathplanner.lib.auto.AutoBuilder; import com.pathplanner.lib.auto.AutoBuilderException; import com.pathplanner.lib.commands.PathPlannerAuto; - -import choreo.auto.AutoChooser; -import choreo.auto.AutoFactory; -import choreo.auto.AutoRoutine; +// TODO: 2027-ALPHA-FIX - Re-enable Choreo when updated +// import choreo.auto.AutoChooser; +// import choreo.auto.AutoFactory; +// import choreo.auto.AutoRoutine; import org.wpilib.math.geometry.Pose3d; import org.wpilib.driverstation.DriverStation; import org.wpilib.system.RobotController; @@ -21,7 +21,7 @@ import org.wpilib.command2.Command; import org.wpilib.command2.CommandScheduler; import frc.robot.commands.DoNothing; import frc.robot.commands.LogCommand; -import frc.robot.commands.auto_comm.ChoreoPathCommandBuilder; +// import frc.robot.commands.auto_comm.ChoreoPathCommandBuilder; import frc.robot.commands.auto_comm.DynamicAutoBuilder; import frc.robot.commands.drive_comm.SysIDDriveCommand; import frc.robot.constants.AutoConstants; @@ -230,15 +230,15 @@ public class RobotContainer { String rightDynamicConservativeDoubleSwipe = "RightDynamicDoubleConservativeSwipe"; // String leftDynamicShallowDoubleSwipe = "LeftDynamicShallowDoubleSwipe"; // String rightDynamicShallowDoubleSwipe = "RightDynamicShallowDoubleSwipe"; - - ChoreoPathCommandBuilder choreo = new ChoreoPathCommandBuilder(); + // TODO: 2027-ALPHA-FIX - Re-enable Choreo vendordep when JSON is updated + // ChoreoPathCommandBuilder choreo = new ChoreoPathCommandBuilder(); // addAuto("testChoreo", ChoreoPathCommandBuilder.basicTrajectoryAuto("test.traj", true, // autoFactory)); // put the Chooser on the SmartDashboard SmartDashboard.putData("Auto chooser", autoChooser); - SmartDashboard.putData("Choreo auto chooser", choreoAutoChooser); + // SmartDashboard.putData("Choreo auto chooser", choreoAutoChooser); } public static BooleanSupplier getAllianceColorBooleanSupplier() { @@ -250,7 +250,7 @@ public class RobotContainer { var alliance = DriverStation.getAlliance(); if (alliance.isPresent()) { - return alliance.get() == DriverStation.Alliance.Red; + return alliance.get() == DriverStation.Alliance.RED; } return false; }; diff --git a/src/main/java/frc/robot/commands/auto_comm/ChoreoPathCommandBuilder.java b/src/main/java/frc/robot/commands/auto_comm/ChoreoPathCommandBuilder.java index 393aec6..8279379 100644 --- a/src/main/java/frc/robot/commands/auto_comm/ChoreoPathCommandBuilder.java +++ b/src/main/java/frc/robot/commands/auto_comm/ChoreoPathCommandBuilder.java @@ -1,4 +1,4 @@ -// TODO: 2027-ALPHA-FIX - Re-enable Choreo vendordep when JSON is updated +// TODO: 2027-ALPHA-FIX - Re-enable Choreo dep when updated // package frc.robot.commands.auto_comm; // import choreo.auto.AutoFactory; diff --git a/src/main/java/frc/robot/commands/auto_comm/DynamicAutoBuilder.java b/src/main/java/frc/robot/commands/auto_comm/DynamicAutoBuilder.java index 517ea16..cbd0985 100644 --- a/src/main/java/frc/robot/commands/auto_comm/DynamicAutoBuilder.java +++ b/src/main/java/frc/robot/commands/auto_comm/DynamicAutoBuilder.java @@ -1,6 +1,5 @@ package frc.robot.commands.auto_comm; -import org.wpilib.command2.*; public class DynamicAutoBuilder { diff --git a/src/main/java/frc/robot/commands/drive_comm/DefaultDriveCommand.java b/src/main/java/frc/robot/commands/drive_comm/DefaultDriveCommand.java index f955075..b1fa897 100644 --- a/src/main/java/frc/robot/commands/drive_comm/DefaultDriveCommand.java +++ b/src/main/java/frc/robot/commands/drive_comm/DefaultDriveCommand.java @@ -2,7 +2,7 @@ package frc.robot.commands.drive_comm; import org.wpilib.math.controller.PIDController; import org.wpilib.math.kinematics.ChassisVelocities; -import org.wpilib.driverstation.DriverStation.Alliance; +import org.wpilib.driverstation.Alliance; import org.wpilib.smartdashboard.SmartDashboard; import org.wpilib.command2.Command; import frc.robot.Robot; @@ -49,7 +49,7 @@ public class DefaultDriveCommand extends Command { sideTranslation *= slowFactor; rotation *= driver.getIsSlowMode() ? DriveConstants.SLOW_ROT_FACTOR : 1; - int allianceReversal = Robot.getAlliance() == Alliance.Red ? 1 : -1; + int allianceReversal = Robot.getAlliance() == Alliance.RED ? 1 : -1; forwardTranslation *= allianceReversal; sideTranslation *= allianceReversal; diff --git a/src/main/java/frc/robot/commands/drive_comm/GoToPose.java b/src/main/java/frc/robot/commands/drive_comm/GoToPose.java index 14e191b..eb5884b 100644 --- a/src/main/java/frc/robot/commands/drive_comm/GoToPose.java +++ b/src/main/java/frc/robot/commands/drive_comm/GoToPose.java @@ -6,7 +6,7 @@ import com.pathplanner.lib.auto.AutoBuilder; import com.pathplanner.lib.path.PathConstraints; import org.wpilib.math.geometry.Pose2d; -import org.wpilib.driverstation.DriverStation; +import org.wpilib.driverstation.DriverStationErrors; import org.wpilib.command2.Command; import org.wpilib.command2.InstantCommand; import org.wpilib.command2.SequentialCommandGroup; @@ -83,10 +83,10 @@ public class GoToPose extends SequentialCommandGroup { // makes weird paths. if (dist > 3) { command = new DoNothing(); - DriverStation.reportWarning("Alignment Path too long, doing nothing, GoToPose.java", false); + DriverStationErrors.reportWarning("Alignment Path too long, doing nothing, GoToPose.java", false); } else if (dist < 0.02) { command = new DoNothing(); - DriverStation.reportWarning("Alignment Path too short, doing nothing, GoToPose.java", false); + DriverStationErrors.reportWarning("Alignment Path too short, doing nothing, GoToPose.java", false); } return command; diff --git a/src/main/java/frc/robot/commands/drive_comm/SetFormationX.java b/src/main/java/frc/robot/commands/drive_comm/SetFormationX.java index 7d6ba31..87c6776 100644 --- a/src/main/java/frc/robot/commands/drive_comm/SetFormationX.java +++ b/src/main/java/frc/robot/commands/drive_comm/SetFormationX.java @@ -2,7 +2,6 @@ package frc.robot.commands.drive_comm; import org.wpilib.math.geometry.Rotation2d; import org.wpilib.math.kinematics.SwerveModuleVelocity; -import org.wpilib.math.kinematics.SwerveModuleVelocity; import org.wpilib.math.util.Units; import org.wpilib.command2.InstantCommand; import org.wpilib.command2.RunCommand; diff --git a/src/main/java/frc/robot/commands/drive_comm/TrajectoryPresetSteerAngles.java b/src/main/java/frc/robot/commands/drive_comm/TrajectoryPresetSteerAngles.java index 3ba8916..4430824 100644 --- a/src/main/java/frc/robot/commands/drive_comm/TrajectoryPresetSteerAngles.java +++ b/src/main/java/frc/robot/commands/drive_comm/TrajectoryPresetSteerAngles.java @@ -27,7 +27,7 @@ public class TrajectoryPresetSteerAngles extends InstantCommand { Pose2d initialPose = trajectory.getInitialPose(); State sample = trajectory.sample(time); - Pose2d nextPose = sample.poseMeters; + Pose2d nextPose = sample.pose; double xVelocity = sample.velocity * nextPose.getRotation().getCos(); double yVelocity = sample.velocity * nextPose.getRotation().getSin(); @@ -39,7 +39,7 @@ public class TrajectoryPresetSteerAngles extends InstantCommand { ChassisVelocities.fromFieldRelativeSpeeds(chassisSpeeds, initialPose.getRotation()); SwerveModuleVelocity[] SwerveModuleVelocitys = - DriveConstants.KINEMATICS.toSwerveModuleVelocitys(chassisSpeeds); + DriveConstants.KINEMATICS.toSwerveModuleVelocities(chassisSpeeds); for (SwerveModuleVelocity SwerveModuleVelocity : SwerveModuleVelocitys) { SwerveModuleVelocity.speedMetersPerSecond = 0; } diff --git a/src/main/java/frc/robot/constants/AutoConstants.java b/src/main/java/frc/robot/constants/AutoConstants.java index 984f8b9..7ea81e5 100644 --- a/src/main/java/frc/robot/constants/AutoConstants.java +++ b/src/main/java/frc/robot/constants/AutoConstants.java @@ -5,7 +5,7 @@ import com.pathplanner.lib.config.PIDConstants; import com.pathplanner.lib.config.RobotConfig; import com.pathplanner.lib.controllers.PPHolonomicDriveController; -import org.wpilib.math.system.plant.DCMotor; +import org.wpilib.math.system.DCMotor; import frc.robot.constants.swerve.DriveConstants; /** Container class for auto constants. */ diff --git a/src/main/java/frc/robot/controls/GameControllerDriverConfig.java b/src/main/java/frc/robot/controls/GameControllerDriverConfig.java index b59eed3..d5f0834 100644 --- a/src/main/java/frc/robot/controls/GameControllerDriverConfig.java +++ b/src/main/java/frc/robot/controls/GameControllerDriverConfig.java @@ -3,7 +3,7 @@ package frc.robot.controls; import java.util.function.BooleanSupplier; import org.wpilib.math.geometry.Rotation2d; -import org.wpilib.driverstation.DriverStation.Alliance; +import org.wpilib.driverstation.Alliance; import org.wpilib.command2.CommandScheduler; import org.wpilib.command2.InstantCommand; import frc.robot.Robot; @@ -32,7 +32,7 @@ public class GameControllerDriverConfig extends BaseDriverConfig { () -> super.getDrivetrain() .setYaw( - new Rotation2d(Robot.getAlliance() == Alliance.Blue ? 0 : Math.PI)))); + new Rotation2d(Robot.getAlliance() == Alliance.BLUE ? 0 : Math.PI)))); // Cancel commands driver diff --git a/src/main/java/frc/robot/controls/PS5ControllerDriverConfig.java b/src/main/java/frc/robot/controls/PS5ControllerDriverConfig.java index 7b8117d..f785ef4 100644 --- a/src/main/java/frc/robot/controls/PS5ControllerDriverConfig.java +++ b/src/main/java/frc/robot/controls/PS5ControllerDriverConfig.java @@ -3,7 +3,7 @@ package frc.robot.controls; import java.util.function.BooleanSupplier; import org.wpilib.math.geometry.Rotation2d; -import org.wpilib.driverstation.DriverStation.Alliance; +import org.wpilib.driverstation.Alliance; import org.wpilib.command2.CommandScheduler; import org.wpilib.command2.InstantCommand; import frc.robot.Robot; @@ -31,7 +31,7 @@ public class PS5ControllerDriverConfig extends BaseDriverConfig { () -> getDrivetrain() .setYaw( - new Rotation2d(Robot.getAlliance() == Alliance.Blue ? 0 : Math.PI)))); + new Rotation2d(Robot.getAlliance() == Alliance.BLUE ? 0 : Math.PI)))); // Cancel commands controller diff --git a/src/main/java/frc/robot/controls/PS5XboxModeDriverConfig.java b/src/main/java/frc/robot/controls/PS5XboxModeDriverConfig.java index fd48429..57c51a9 100644 --- a/src/main/java/frc/robot/controls/PS5XboxModeDriverConfig.java +++ b/src/main/java/frc/robot/controls/PS5XboxModeDriverConfig.java @@ -3,7 +3,7 @@ package frc.robot.controls; import java.util.function.BooleanSupplier; import org.wpilib.math.geometry.Rotation2d; -import org.wpilib.driverstation.DriverStation.Alliance; +import org.wpilib.driverstation.Alliance; import org.wpilib.command2.Command; import org.wpilib.command2.CommandScheduler; import org.wpilib.command2.FunctionalCommand; @@ -71,7 +71,7 @@ public class PS5XboxModeDriverConfig extends BaseDriverConfig { () -> getDrivetrain() .setYaw( - new Rotation2d(Robot.getAlliance() == Alliance.Blue ? 0 : Math.PI)))); + new Rotation2d(Robot.getAlliance() == Alliance.BLUE ? 0 : Math.PI)))); // Cancel commands controller diff --git a/src/main/java/frc/robot/subsystems/LED/LED.java b/src/main/java/frc/robot/subsystems/LED/LED.java index 73c7725..ca91ff7 100644 --- a/src/main/java/frc/robot/subsystems/LED/LED.java +++ b/src/main/java/frc/robot/subsystems/LED/LED.java @@ -19,7 +19,7 @@ import com.ctre.phoenix6.signals.StripTypeValue; import com.ctre.phoenix6.signals.VBatOutputModeValue; import org.wpilib.driverstation.DriverStation; -import org.wpilib.driverstation.DriverStation.Alliance; +import org.wpilib.driverstation.Alliance; import org.wpilib.util.Color; import org.wpilib.command2.SubsystemBase; import frc.robot.constants.Constants; @@ -66,9 +66,9 @@ public class LED extends SubsystemBase { var alliance = DriverStation.getAlliance(); if (alliance.isEmpty()) { color = Color.kOrangeRed; - } else if (alliance.get() == Alliance.Red) { + } else if (alliance.get() == Alliance.RED) { color = Color.kRed; - } else if (alliance.get() == Alliance.Blue) { + } else if (alliance.get() == Alliance.BLUE) { color = Color.kBlue; } else { color = Color.kOrangeRed; diff --git a/src/main/java/frc/robot/subsystems/drivetrain/Drivetrain.java b/src/main/java/frc/robot/subsystems/drivetrain/Drivetrain.java index 1e2d12c..13d1801 100644 --- a/src/main/java/frc/robot/subsystems/drivetrain/Drivetrain.java +++ b/src/main/java/frc/robot/subsystems/drivetrain/Drivetrain.java @@ -37,6 +37,7 @@ import frc.robot.constants.GyroBiasConstants; import frc.robot.constants.VisionConstants; import frc.robot.constants.swerve.DriveConstants; import frc.robot.constants.swerve.ModuleConstants; +import frc.robot.subsystems.drivetrain.GyroIO.GyroIOInputs; import frc.robot.util.EqualsUtil; import frc.robot.util.PhoenixOdometryThread; import frc.robot.util.SwerveModulePose; @@ -467,7 +468,7 @@ public class Drivetrain extends SubsystemBase { */ public void setModuleStates(SwerveModuleVelocity[] SwerveModuleVelocitys, boolean isOpenLoop) { // makes sure speeds of modules don't exceed maximum allowed - SwerveDriveKinematics.desaturateWheelSpeeds(SwerveModuleVelocitys, DriveConstants.MAX_SPEED); + SwerveDriveKinematics.desaturateWheelVelocities(SwerveModuleVelocitys, DriveConstants.MAX_SPEED); for (int i = 0; i < 4; i++) { modules[i].setDesiredState(SwerveModuleVelocitys[i], isOpenLoop); diff --git a/src/main/java/frc/robot/subsystems/drivetrain/Module.java b/src/main/java/frc/robot/subsystems/drivetrain/Module.java index 1affc0d..f573523 100644 --- a/src/main/java/frc/robot/subsystems/drivetrain/Module.java +++ b/src/main/java/frc/robot/subsystems/drivetrain/Module.java @@ -33,8 +33,8 @@ import frc.robot.constants.Constants; import org.wpilib.units.measure.AngularVelocity; import org.wpilib.units.measure.Current; import org.wpilib.units.measure.Voltage; -import org.wpilib.util.Alert; -import org.wpilib.util.Alert.AlertType; +import org.wpilib.driverstation.Alert; +import org.wpilib.driverstation.Alert.AlertType; import frc.robot.constants.swerve.DriveConstants; import frc.robot.constants.swerve.ModuleConstants; import frc.robot.constants.swerve.ModuleType; @@ -85,7 +85,6 @@ public class Module implements ModuleIO { private final Alert turnDisconnectedAlert; private final Alert turnEncoderDisconnectedAlert; - protected final ModuleIOInputsAutoLogged inputs = new ModuleIOInputsAutoLogged(); private ModuleConstants moduleConstants; private final MotionMagicVelocityVoltage velocityRequest = diff --git a/src/main/java/frc/robot/util/AngledElevatorSim.java b/src/main/java/frc/robot/util/AngledElevatorSim.java index e7f65ae..bd7897a 100644 --- a/src/main/java/frc/robot/util/AngledElevatorSim.java +++ b/src/main/java/frc/robot/util/AngledElevatorSim.java @@ -5,7 +5,7 @@ import org.wpilib.math.linalg.VecBuilder; import org.wpilib.math.numbers.N1; import org.wpilib.math.numbers.N2; import org.wpilib.math.system.NumericalIntegration; -import org.wpilib.math.system.plant.DCMotor; +import org.wpilib.math.system..DCMotor; import org.wpilib.simulation.ElevatorSim; /** Exactly the same as ElevatorSim, except it can be angled and have a constant force spring */ diff --git a/src/main/java/frc/robot/util/ClimbArmSim.java b/src/main/java/frc/robot/util/ClimbArmSim.java index bfbd9da..5c10dfc 100644 --- a/src/main/java/frc/robot/util/ClimbArmSim.java +++ b/src/main/java/frc/robot/util/ClimbArmSim.java @@ -6,8 +6,8 @@ import org.wpilib.math.numbers.N1; import org.wpilib.math.numbers.N2; import org.wpilib.math.system.LinearSystem; import org.wpilib.math.system.NumericalIntegration; -import org.wpilib.math.system.plant.DCMotor; -import org.wpilib.math.system.plant.LinearSystemId; +import org.wpilib.math.system.DCMotor; +import org.wpilib.math.system.Models; import org.wpilib.simulation.SingleJointedArmSim; /** @@ -28,8 +28,7 @@ public class ClimbArmSim extends SingleJointedArmSim { * Creates a simulated arm mechanism. * * @param plant The linear system that represents the arm. This system can be created with {@link - * org.wpilib.math.system.plant.LinearSystemId#createSingleJointedArmSystem(DCMotor, - * double, double)}. + * org.wpilib.math.system.Models#singleJointedArmFromPhysicalConstants(DCMotor, double, double)}. * @param gearbox The type of and number of motors in the arm gearbox. * @param gearing The gearing of the arm (numbers greater than 1 represent reductions). * @param armLengthMeters The length of the arm. @@ -99,7 +98,7 @@ public class ClimbArmSim extends SingleJointedArmSim { double robotMassKilograms, double... measurementStdDevs) { this( - LinearSystemId.createSingleJointedArmSystem(gearbox, jKgMetersSquared, gearing), + Models.singleJointedArmFromPhysicalConstants(gearbox, jKgMetersSquared, gearing), gearbox, gearing, armLengthMeters, diff --git a/src/main/java/frc/robot/util/ConversionUtils.java b/src/main/java/frc/robot/util/ConversionUtils.java index a89b3ae..6a3a4b5 100644 --- a/src/main/java/frc/robot/util/ConversionUtils.java +++ b/src/main/java/frc/robot/util/ConversionUtils.java @@ -2,7 +2,7 @@ package frc.robot.util; import org.wpilib.math.geometry.Pose2d; import org.wpilib.math.geometry.Rotation2d; -import org.wpilib.driverstation.DriverStation.Alliance; +import org.wpilib.driverstation.Alliance; import frc.robot.constants.FieldConstants; public class ConversionUtils { @@ -140,7 +140,7 @@ public class ConversionUtils { * @return converted pose */ public static Pose2d absolutePoseToPathPlannerPose(Pose2d pose, Alliance alliance) { - if (alliance == Alliance.Red) { + if (alliance == Alliance.RED) { return pose.relativeTo( new Pose2d( FieldConstants.field.getFieldLength(), diff --git a/src/main/java/frc/robot/util/Elastic.java b/src/main/java/frc/robot/util/Elastic.java index 4e7d6a3..110788b 100644 --- a/src/main/java/frc/robot/util/Elastic.java +++ b/src/main/java/frc/robot/util/Elastic.java @@ -14,14 +14,18 @@ import org.wpilib.networktables.StringPublisher; import org.wpilib.networktables.StringTopic; public final class Elastic { + PubSubOption optionTrue = PubSubOption.SEND_ALL; + PubSubOption optionFalse = PubSubOption.SEND_CHANGES; + PubSubOption keepDuplicates = PubSubOption.KEEP_DUPLICATES; + private static final StringTopic notificationTopic = NetworkTableInstance.getDefault().getStringTopic("/Elastic/RobotNotifications"); private static final StringPublisher notificationPublisher = - notificationTopic.publish(PubSubOption.sendAll(true), PubSubOption.keepDuplicates(true)); + notificationTopic.publish(PubSubOption.SEND_ALL, PubSubOption.KEEP_DUPLICATES); private static final StringTopic selectedTabTopic = NetworkTableInstance.getDefault().getStringTopic("/Elastic/SelectedTab"); private static final StringPublisher selectedTabPublisher = - selectedTabTopic.publish(PubSubOption.keepDuplicates(true)); + selectedTabTopic.publish(PubSubOption.KEEP_DUPLICATES); private static final ObjectMapper objectMapper = new ObjectMapper(); /** diff --git a/src/main/java/frc/robot/util/PathGroupLoader.java b/src/main/java/frc/robot/util/PathGroupLoader.java index 9650dff..b7a7a46 100644 --- a/src/main/java/frc/robot/util/PathGroupLoader.java +++ b/src/main/java/frc/robot/util/PathGroupLoader.java @@ -1,6 +1,6 @@ package frc.robot.util; -import org.wpilib.driverstation.DriverStation; +import org.wpilib.driverstation.DriverStationErrors; import org.wpilib.system.Filesystem; import frc.robot.constants.AutoConstants; @@ -41,13 +41,13 @@ public class PathGroupLoader { System.out.println( "Processed file: " + file.getName() + ", took " + time + " milliseconds."); } catch (Exception e) { - DriverStation.reportError(e.getMessage(), true); + DriverStationErrors.reportError(e.getMessage(), true); } } } } else { System.out.println("Error processing file"); - DriverStation.reportWarning("Issue with finding path files. Paths will not be loaded.", true); + DriverStationErrors.reportWarning("Issue with finding path files. Paths will not be loaded.", true); } System.out.println("File processing took a total of " + totalTime + " milliseconds"); } diff --git a/src/main/java/frc/robot/util/SwerveStuff/SwerveSetpointGenerator.java b/src/main/java/frc/robot/util/SwerveStuff/SwerveSetpointGenerator.java index 0c8f7bc..b414422 100644 --- a/src/main/java/frc/robot/util/SwerveStuff/SwerveSetpointGenerator.java +++ b/src/main/java/frc/robot/util/SwerveStuff/SwerveSetpointGenerator.java @@ -266,10 +266,10 @@ public class SwerveSetpointGenerator { double dt) { final Translation2d[] modules = moduleLocations; - SwerveModuleVelocity[] desiredModuleState = kinematics.toSwerveModuleVelocitys(desiredState); + SwerveModuleVelocity[] desiredModuleState = kinematics.toSwerveModuleVelocities(desiredState); // Make sure desiredState respects velocity limits. if (limits.maxDriveVelocity() > 0.0) { - SwerveDriveKinematics.desaturateWheelSpeeds(desiredModuleState, limits.maxDriveVelocity()); + SwerveDriveKinematics.desaturateWheelVelocities(desiredModuleState, dt)(desiredModuleState, limits.maxDriveVelocity()); desiredState = kinematics.toChassisVelocities(desiredModuleState); } @@ -475,7 +475,7 @@ public class SwerveSetpointGenerator { prevSetpoint.chassisSpeeds().vx + min_s * dx, prevSetpoint.chassisSpeeds().vy + min_s * dy, prevSetpoint.chassisSpeeds().omega + min_s * dtheta); - var retStates = kinematics.toSwerveModuleVelocitys(retSpeeds); + var retStates = kinematics.toSwerveModuleVelocities(retSpeeds); for (int i = 0; i < modules.length; ++i) { final var maybeOverride = overrideSteering.get(i); if (maybeOverride.isPresent()) { diff --git a/src/main/java/frc/robot/util/Vision/DetectedObject.java b/src/main/java/frc/robot/util/Vision/DetectedObject.java index b9f81d4..bbe3368 100644 --- a/src/main/java/frc/robot/util/Vision/DetectedObject.java +++ b/src/main/java/frc/robot/util/Vision/DetectedObject.java @@ -8,7 +8,7 @@ import org.wpilib.math.geometry.Transform3d; import org.wpilib.math.geometry.Translation3d; import org.wpilib.math.kinematics.ChassisVelocities; import org.wpilib.math.util.Units; -import org.wpilib.driverstation.DriverStation.Alliance; +import org.wpilib.driverstation.Alliance; import frc.robot.Robot; import frc.robot.subsystems.drivetrain.Drivetrain; @@ -321,7 +321,7 @@ public class DetectedObject { */ public boolean isSameAllianceRobot() { return type - == (Robot.getAlliance() == Alliance.Red ? ObjectType.RED_ROBOT : ObjectType.BLUE_ROBOT); + == (Robot.getAlliance() == Alliance.RED ? ObjectType.RED_ROBOT : ObjectType.BLUE_ROBOT); } /** @@ -331,7 +331,7 @@ public class DetectedObject { */ public boolean isOtherAllianceRobot() { return type - == (Robot.getAlliance() == Alliance.Red ? ObjectType.BLUE_ROBOT : ObjectType.RED_ROBOT); + == (Robot.getAlliance() == Alliance.RED ? ObjectType.BLUE_ROBOT : ObjectType.RED_ROBOT); } /** diff --git a/src/main/java/frc/robot/util/Vision/Vision.java b/src/main/java/frc/robot/util/Vision/Vision.java index 7c1a444..92085a7 100644 --- a/src/main/java/frc/robot/util/Vision/Vision.java +++ b/src/main/java/frc/robot/util/Vision/Vision.java @@ -30,6 +30,7 @@ import org.wpilib.networktables.NetworkTable; import org.wpilib.networktables.NetworkTableEntry; import org.wpilib.networktables.NetworkTableInstance; import org.wpilib.driverstation.DriverStation; +import org.wpilib.driverstation.DriverStationErrors; import org.wpilib.framework.RobotBase; import org.wpilib.system.Timer; import frc.robot.constants.Constants; @@ -434,7 +435,7 @@ public class Vision { try { cameras.get(index).enable(enabled); } catch (IndexOutOfBoundsException e) { - DriverStation.reportWarning("Camera index " + index + " is out of bounds", false); + DriverStationErrors.reportWarning("Camera index " + index + " is out of bounds", false); } } -- 2.47.3