Skip to content

Commit

Permalink
Create AutoBuilder and SendableChooser for autos. (Not working)
Browse files Browse the repository at this point in the history
  • Loading branch information
KPatel008 committed Feb 1, 2025
1 parent d863fe5 commit cf0cae0
Show file tree
Hide file tree
Showing 8 changed files with 599 additions and 359 deletions.
51 changes: 51 additions & 0 deletions .Glass/glass.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
{
"NetworkTables": {
"transitory": {
"SmartDashboard": {
"Alerts": {
"open": true
},
"Auto Chooser": {
"open": true,
"string[]##v_/SmartDashboard/Auto Chooser/options": {
"open": true
}
},
"Auto mode": {
"open": true,
"string[]##v_/SmartDashboard/Auto mode/options": {
"open": true
}
},
"open": true
}
},
"types": {
"/AdvantageKit/RealOutputs/Alerts": "Alerts",
"/FMSInfo": "FMSInfo",
"/Pose": "Field2d",
"/SmartDashboard/Alerts": "Alerts",
"/SmartDashboard/Auto Chooser": "String Chooser",
"/SmartDashboard/Auto mode": "String Chooser",
"/SmartDashboard/AutoChooser": "String Chooser",
"/SmartDashboard/Module 0": "Mechanism2d",
"/SmartDashboard/Module 1": "Mechanism2d",
"/SmartDashboard/Module 2": "Mechanism2d",
"/SmartDashboard/Module 3": "Mechanism2d"
},
"windows": {
"/SmartDashboard/Auto Chooser": {
"window": {
"visible": true
}
}
}
},
"NetworkTables Info": {
"visible": true
},
"NetworkTables Settings": {
"mode": "Client (NT4)",
"serverTeam": "4909"
}
}
49 changes: 49 additions & 0 deletions src/main/deploy/pathplanner/autos/Score L4.auto
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
{
"version": "2025.0",
"command": {
"type": "sequential",
"data": {
"commands": [
{
"type": "path",
"data": {
"pathName": "Top Reef"
}
},
{
"type": "named",
"data": {
"name": "L4"
}
},
{
"type": "wait",
"data": {
"waitTime": 1.0
}
},
{
"type": "named",
"data": {
"name": "score"
}
},
{
"type": "wait",
"data": {
"waitTime": 0.3
}
},
{
"type": "named",
"data": {
"name": "L1"
}
}
]
}
},
"resetOdom": true,
"folder": null,
"choreoAuto": false
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
{
"type": "path",
"data": {
"pathName": "Example Path"
"pathName": "TAXI"
}
}
]
Expand Down
54 changes: 54 additions & 0 deletions src/main/deploy/pathplanner/paths/TAXI.path
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{
"version": "2025.0",
"waypoints": [
{
"anchor": {
"x": 7.197,
"y": 4.077589897260274
},
"prevControl": null,
"nextControl": {
"x": 5.959044040523948,
"y": 4.077589897260274
},
"isLocked": false,
"linkedName": null
},
{
"anchor": {
"x": 6.0,
"y": 4.078
},
"prevControl": {
"x": 7.3686576306595395,
"y": 4.078
},
"nextControl": null,
"isLocked": false,
"linkedName": null
}
],
"rotationTargets": [],
"constraintZones": [],
"pointTowardsZones": [],
"eventMarkers": [],
"globalConstraints": {
"maxVelocity": 1.0,
"maxAcceleration": 3.0,
"maxAngularVelocity": 540.0,
"maxAngularAcceleration": 720.0,
"nominalVoltage": 12.0,
"unlimited": false
},
"goalEndState": {
"velocity": 0,
"rotation": 180.0
},
"reversed": false,
"folder": null,
"idealStartingState": {
"velocity": 0,
"rotation": 180.0
},
"useDefaultConstraints": false
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,41 +3,25 @@
"waypoints": [
{
"anchor": {
"x": 2.0,
"y": 7.0
"x": 7.197,
"y": 3.972
},
"prevControl": null,
"nextControl": {
"x": 3.013282910175676,
"y": 6.5274984191074985
"x": 5.959044040523948,
"y": 3.972
},
"isLocked": false,
"linkedName": null
},
{
"anchor": {
"x": 5.166769560390973,
"y": 5.0964860911203305
"x": 5.799914383561644,
"y": 3.972410102739726
},
"prevControl": {
"x": 4.166769560390973,
"y": 6.0964860911203305
},
"nextControl": {
"x": 6.166769560390973,
"y": 4.0964860911203305
},
"isLocked": false,
"linkedName": null
},
{
"anchor": {
"x": 7.0,
"y": 1.0
},
"prevControl": {
"x": 6.75,
"y": 2.5
"x": 7.1685720142211835,
"y": 3.972410102739726
},
"nextControl": null,
"isLocked": false,
Expand All @@ -58,13 +42,13 @@
},
"goalEndState": {
"velocity": 0,
"rotation": 0.0
"rotation": 180.0
},
"reversed": false,
"folder": null,
"idealStartingState": {
"velocity": 0,
"rotation": 0.0
"rotation": 180.0
},
"useDefaultConstraints": false
}
31 changes: 21 additions & 10 deletions src/main/deploy/pathplanner/settings.json
Original file line number Diff line number Diff line change
@@ -1,21 +1,32 @@
{
"robotWidth": 0.9,
"robotLength": 0.9,
"robotWidth": 0.8,
"robotLength": 0.8,
"holonomicMode": true,
"pathFolders": [],
"autoFolders": [],
"defaultMaxVel": 3.0,
"defaultMaxAccel": 3.0,
"defaultMaxAngVel": 540.0,
"defaultMaxAngAccel": 720.0,
"robotMass": 74.088,
"defaultNominalVoltage": 12.0,
"robotMass": 45.3,
"robotMOI": 6.883,
"robotWheelbase": 0.546,
"robotTrackwidth": 0.546,
"driveWheelRadius": 0.048,
"driveGearing": 5.143,
"maxDriveSpeed": 5.45,
"driveWheelRadius": 0.0508,
"driveGearing": 6.122448979591837,
"maxDriveSpeed": 5.21,
"driveMotorType": "krakenX60FOC",
"driveCurrentLimit": 60.0,
"wheelCOF": 1.2
}
"driveCurrentLimit": 40.0,
"wheelCOF": 1.2,
"flModuleX": 0.2667,
"flModuleY": 0.2667,
"frModuleX": 0.2667,
"frModuleY": -0.2667,
"blModuleX": -0.2667,
"blModuleY": 0.2667,
"brModuleX": -0.2667,
"brModuleY": -0.2667,
"bumperOffsetX": 0.0,
"bumperOffsetY": 0.0,
"robotFeatures": []
}
24 changes: 22 additions & 2 deletions src/main/java/frc/robot/RobotContainer.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@

import static edu.wpi.first.units.Units.*;

import org.littletonrobotics.junction.networktables.LoggedDashboardChooser;

import com.ctre.phoenix6.swerve.SwerveModule.DriveRequestType;
import com.pathplanner.lib.auto.AutoBuilder;
import com.pathplanner.lib.auto.NamedCommands;
import com.pathplanner.lib.commands.PathPlannerAuto;
import com.ctre.phoenix6.swerve.SwerveRequest;

import edu.wpi.first.apriltag.AprilTagFieldLayout;
Expand All @@ -22,6 +27,8 @@
import edu.wpi.first.math.util.Units;
import edu.wpi.first.units.Unit;
import edu.wpi.first.wpilibj.RobotBase;
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.Commands;
import edu.wpi.first.wpilibj2.command.button.CommandXboxController;
Expand Down Expand Up @@ -62,7 +69,7 @@ public class RobotContainer {
private final CommandXboxController joystick = new CommandXboxController(0);

public final CommandSwerveDrivetrain drivetrain = TunerConstants.createDrivetrain();

private final SendableChooser<Command> m_chooser;
private final Shooter s_Shooter;
private final Elevator s_Elevator;
private final Vision m_vision;
Expand All @@ -72,6 +79,19 @@ public class RobotContainer {
public RobotContainer(){
s_Shooter = new Shooter(new ShooterIOTalonFX());
s_Elevator = new Elevator(new ElevatorIOTalonFX());

//Auto Named Commands
NamedCommands.registerCommand("score", s_Shooter.shootTrough());
NamedCommands.registerCommand("L4", s_Elevator.goToL4());
NamedCommands.registerCommand("L3", s_Elevator.goToL3());
NamedCommands.registerCommand("L2", s_Elevator.goToL2());
NamedCommands.registerCommand("L1", s_Elevator.goToL1());



m_chooser = AutoBuilder.buildAutoChooser();
SmartDashboard.putData("Auto Chooser", m_chooser);

configureBindings();

m_vision = new Vision(drivetrain::addVisionMeasurement, new VisionIOPhotonVision("front-cam", new Transform3d(new Translation3d(
Expand Down Expand Up @@ -186,6 +206,6 @@ private void configureBindings() {
}

public Command getAutonomousCommand() {
return Commands.print("No autonomous command configured");
return m_chooser.getSelected();
}
}
Loading

0 comments on commit cf0cae0

Please sign in to comment.