Skip to content

Commit

Permalink
Stub of Autonomous Motion Stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
Java4First committed Mar 15, 2024
1 parent b23bce9 commit fd3a747
Show file tree
Hide file tree
Showing 3 changed files with 136 additions and 45 deletions.
25 changes: 25 additions & 0 deletions src/main/deploy/pathplanner/autos/West Test Auto.auto
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"version": 1.0,
"startingPose": {
"position": {
"x": 2.0,
"y": 7.0
},
"rotation": 0
},
"command": {
"type": "sequential",
"data": {
"commands": [
{
"type": "path",
"data": {
"pathName": "West Test Path"
}
}
]
}
},
"folder": null,
"choreoAuto": false
}
52 changes: 52 additions & 0 deletions src/main/deploy/pathplanner/paths/West Test Path.path
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{
"version": 1.0,
"waypoints": [
{
"anchor": {
"x": 2.0,
"y": 7.0
},
"prevControl": null,
"nextControl": {
"x": 3.0,
"y": 7.0
},
"isLocked": false,
"linkedName": null
},
{
"anchor": {
"x": 4.502775862694583,
"y": 7.0
},
"prevControl": {
"x": 3.502775862694583,
"y": 7.0
},
"nextControl": null,
"isLocked": false,
"linkedName": null
}
],
"rotationTargets": [],
"constraintZones": [],
"eventMarkers": [],
"globalConstraints": {
"maxVelocity": 3.0,
"maxAcceleration": 3.0,
"maxAngularVelocity": 540.0,
"maxAngularAcceleration": 720.0
},
"goalEndState": {
"velocity": 0,
"rotation": 0,
"rotateFast": false
},
"reversed": false,
"folder": null,
"previewStartingState": {
"rotation": 0,
"velocity": 0
},
"useDefaultConstraints": true
}
104 changes: 59 additions & 45 deletions src/main/java/frc/robot/RobotContainer.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

package frc.robot;

import com.pathplanner.lib.commands.PathPlannerAuto;

import edu.wpi.first.math.MathUtil;
import edu.wpi.first.wpilibj.GenericHID;
import edu.wpi.first.wpilibj.XboxController;
Expand Down Expand Up @@ -40,9 +42,12 @@
import frc.robot.subsystems.drive.ModuleIOSparkMax;

/**
* This class is where the bulk of the robot should be declared. Since Command-based is a
* "declarative" paradigm, very little robot logic should actually be handled in the {@link Robot}
* periodic methods (other than the scheduler calls). Instead, the structure of the robot (including
* This class is where the bulk of the robot should be declared. Since
* Command-based is a
* "declarative" paradigm, very little robot logic should actually be handled in
* the {@link Robot}
* periodic methods (other than the scheduler calls). Instead, the structure of
* the robot (including
* subsystems, commands, and button mappings) should be declared here.
*/
public class RobotContainer {
Expand All @@ -55,27 +60,27 @@ public class RobotContainer {
private final Mast m_mast;
private final Climber m_climber;
public static final TopFeederSensor m_topFeederSensor = new TopFeederSensor();
public static final TopIncrementerSensor m_topIncrementerSensor = new TopIncrementerSensor();
;
public static final TopIncrementerSensor m_topIncrementerSensor = new TopIncrementerSensor();;

// Controller
private final CommandXboxController driverPad = new CommandXboxController(0);
private final CommandXboxController operPad = new CommandXboxController(1);

/** The container for the robot. Contains subsystems, OI devices, and commands. */
/**
* The container for the robot. Contains subsystems, OI devices, and commands.
*/
public RobotContainer() {
switch (Constants.currentMode) {
case REAL:
// Real robot, instantiate hardware IO implementations
switch (Constants.currentRobot) {
case PROTO:
drive =
new Drive(
new GyroIOPigeon2(false),
new ModuleIOSparkMax(0), // FL
new ModuleIOSparkMax(1), // FR
new ModuleIOSparkMax(2), // BL
new ModuleIOSparkMax(3)); // BR
drive = new Drive(
new GyroIOPigeon2(false),
new ModuleIOSparkMax(0), // FL
new ModuleIOSparkMax(1), // FR
new ModuleIOSparkMax(2), // BL
new ModuleIOSparkMax(3)); // BR

m_intake = null;
m_feeder = null;
Expand All @@ -86,13 +91,12 @@ public RobotContainer() {
break;

case REAL:
drive =
new Drive(
new GyroIOPigeon2(false),
new ModuleIOSparkFlex(0), // FL
new ModuleIOSparkFlex(1), // FR
new ModuleIOSparkFlex(2), // BL
new ModuleIOSparkFlex(3)); // BR
drive = new Drive(
new GyroIOPigeon2(false),
new ModuleIOSparkFlex(0), // FL
new ModuleIOSparkFlex(1), // FR
new ModuleIOSparkFlex(2), // BL
new ModuleIOSparkFlex(3)); // BR

m_intake = new Intake();
m_feeder = new Feeder();
Expand All @@ -104,13 +108,17 @@ public RobotContainer() {

case SUITCASE:
default:
drive =
new Drive(
new GyroIO() {},
new ModuleIO() {},
new ModuleIO() {},
new ModuleIO() {},
new ModuleIO() {});
drive = new Drive(
new GyroIO() {
},
new ModuleIO() {
},
new ModuleIO() {
},
new ModuleIO() {
},
new ModuleIO() {
});

m_intake = null;
m_feeder = null;
Expand All @@ -124,13 +132,13 @@ public RobotContainer() {

case SIM:
// Sim robot, instantiate physics sim IO implementations
drive =
new Drive(
new GyroIO() {},
new ModuleIOSim(),
new ModuleIOSim(),
new ModuleIOSim(),
new ModuleIOSim());
drive = new Drive(
new GyroIO() {
},
new ModuleIOSim(),
new ModuleIOSim(),
new ModuleIOSim(),
new ModuleIOSim());
m_intake = new Intake();
m_feeder = new Feeder();
m_incrementer = new Incrementer();
Expand All @@ -141,13 +149,17 @@ public RobotContainer() {

default:
// Replayed robot, disable IO implementations
drive =
new Drive(
new GyroIO() {},
new ModuleIO() {},
new ModuleIO() {},
new ModuleIO() {},
new ModuleIO() {});
drive = new Drive(
new GyroIO() {
},
new ModuleIO() {
},
new ModuleIO() {
},
new ModuleIO() {
},
new ModuleIO() {
});
m_intake = null;
m_feeder = null;
m_incrementer = null;
Expand All @@ -162,9 +174,11 @@ public RobotContainer() {
}

/**
* Use this method to define your button->command mappings. Buttons can be created by
* Use this method to define your button->command mappings. Buttons can be
* created by
* instantiating a {@link GenericHID} or one of its subclasses ({@link
* edu.wpi.first.wpilibj.Joystick} or {@link XboxController}), and then passing it to a {@link
* edu.wpi.first.wpilibj.Joystick} or {@link XboxController}), and then passing
* it to a {@link
* edu.wpi.first.wpilibj2.command.button.JoystickButton}.
*/
private void configureButtonBindings() {
Expand Down Expand Up @@ -228,7 +242,7 @@ private void configureButtonBindings() {

/********************************************************************
* Operator Commands
* *****************************************************************/
*****************************************************************/
// Mast Preset for Climbing
operPad.rightBumper().whileTrue(Commands.sequence(m_mast.setTask(Mast.Task.CLIMBING)));

Expand Down Expand Up @@ -300,6 +314,6 @@ private void configureButtonBindings() {
* @return the command to run in autonomous
*/
public Command getAutonomousCommand() {
return null;
return new PathPlannerAuto("West Test Auto");
}
}

0 comments on commit fd3a747

Please sign in to comment.