From d94d0abf652d80878e649faa809247dcd7c4eed7 Mon Sep 17 00:00:00 2001 From: eileha Date: Wed, 11 Feb 2026 16:30:25 -0800 Subject: [PATCH] autos --- simgui-ds.json | 92 +++++++++++++++++++++ src/main/java/frc/robot/Robot.java | 8 +- src/main/java/frc/robot/RobotContainer.java | 33 +++++++- 3 files changed, 130 insertions(+), 3 deletions(-) create mode 100644 simgui-ds.json diff --git a/simgui-ds.json b/simgui-ds.json new file mode 100644 index 0000000..73cc713 --- /dev/null +++ b/simgui-ds.json @@ -0,0 +1,92 @@ +{ + "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 + } + ] +} diff --git a/src/main/java/frc/robot/Robot.java b/src/main/java/frc/robot/Robot.java index ac05b79..18e51d0 100644 --- a/src/main/java/frc/robot/Robot.java +++ b/src/main/java/frc/robot/Robot.java @@ -18,6 +18,7 @@ import edu.wpi.first.net.PortForwarder; import edu.wpi.first.wpilibj.DriverStation; import edu.wpi.first.wpilibj.DriverStation.Alliance; import edu.wpi.first.wpilibj.RobotController; +import edu.wpi.first.wpilibj.smartdashboard.SendableChooser; import edu.wpi.first.wpilibj2.command.Command; import edu.wpi.first.wpilibj2.command.CommandScheduler; import frc.robot.constants.Constants; @@ -40,6 +41,9 @@ public class Robot extends LoggedRobot { PortForwarder.add(5800,"10.9.72.12",5800); PortForwarder.add(1182,"10.9.72.12",1182); + // Adding auto options on to SendableChooser on SmartDashboard + + // Set up data receivers & replay source switch (Constants.CURRENT_MODE) { case REAL: @@ -75,11 +79,13 @@ public class Robot extends LoggedRobot { // changes networktables.json, networktables.json.bck (both Untracked) // Uncomment the next line, set the desired RobotId, deploy, and then comment the line out // RobotId.setRobotId(RobotId.SwerveCompetition); - DriveConstants.update(RobotId.getRobotId()); + RobotController.setBrownoutVoltage(6.0); // obtain this robot's identity RobotId robotId = RobotId.getRobotId(); + DriveConstants.update(robotId); + // Record metadata Logger.recordMetadata("ProjectName", BuildData.MAVEN_NAME); Logger.recordMetadata("BuildDate", BuildData.BUILD_DATE); diff --git a/src/main/java/frc/robot/RobotContainer.java b/src/main/java/frc/robot/RobotContainer.java index 86104d2..4e4abc2 100644 --- a/src/main/java/frc/robot/RobotContainer.java +++ b/src/main/java/frc/robot/RobotContainer.java @@ -7,14 +7,17 @@ import org.json.simple.parser.ParseException; import org.littletonrobotics.junction.Logger; import com.pathplanner.lib.auto.AutoBuilder; +import com.pathplanner.lib.auto.NamedCommands; import com.pathplanner.lib.commands.PathPlannerAuto; import edu.wpi.first.math.geometry.Pose3d; import edu.wpi.first.wpilibj.DriverStation; import edu.wpi.first.wpilibj.RobotController; import edu.wpi.first.wpilibj.livewindow.LiveWindow; +import edu.wpi.first.wpilibj.smartdashboard.SendableChooser; import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard; import edu.wpi.first.wpilibj2.command.Command; +import edu.wpi.first.wpilibj2.command.InstantCommand; import frc.robot.commands.DoNothing; import frc.robot.commands.drive_comm.DefaultDriveCommand; import frc.robot.commands.vision.ShutdownAllPis; @@ -49,12 +52,22 @@ public class RobotContainer { private BaseDriverConfig driver = null; private Operator operator = null; + // Auto + private final SendableChooser autoChooser = new SendableChooser<>(); + private Command autoSelected; + /** * The container for the robot. Contains subsystems, OI devices, and commands. *

* Different robots may have different subsystems. */ public RobotContainer(RobotId robotId) { + // display the current robot id on smartdashboard + SmartDashboard.putString("RobotID", robotId.toString()); + + // Filling the SendableChooser on SmartDashboard + chooserInit(); + // dispatch on the robot switch (robotId) { case TestBed1: @@ -117,6 +130,14 @@ public class RobotContainer { SmartDashboard.putData("Shutdown Orange Pis", new ShutdownAllPis()); } + public void chooserInit(){ + autoChooser.setDefaultOption("Do nothing", new DoNothing()); + autoChooser.addOption("Do nada", new DoNothing()); + autoChooser.addOption("Spin my wheels", new DoNothing()); + autoChooser.addOption("Hello world", new InstantCommand(() -> System.out.println("Hello world"))); + SmartDashboard.putData("Auto chooser", autoChooser); + } + /** * Sets whether the drivetrain uses vision toupdate odometry */ @@ -144,7 +165,6 @@ public class RobotContainer { } public void registerCommands() { - } public static BooleanSupplier getAllianceColorBooleanSupplier() { @@ -171,8 +191,17 @@ public class RobotContainer { } } +// Autos + + + + /** + * Gets the auto command from SmartDashboard + * @return + */ public Command getAutoCommand(){ - return auto; + autoSelected = autoChooser.getSelected(); + return autoSelected; } public void logComponents(){ -- 2.39.5