Skip to content

Commit

Permalink
Sendable Chooser
Browse files Browse the repository at this point in the history
  • Loading branch information
ProgrammingSR committed Mar 5, 2024
1 parent fcdde8b commit 8b52aa3
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/main/java/frc/robot/RobotContainer.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
import edu.wpi.first.wpilibj.DriverStation;
import edu.wpi.first.wpilibj.XboxController;
import edu.wpi.first.wpilibj.XboxController.Button;
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 edu.wpi.first.wpilibj2.command.RunCommand;
Expand All @@ -36,11 +38,15 @@ public class RobotContainer {
private final DriveSubsystem m_robotDrive = new DriveSubsystem();

private final XboxController m_driverController = new XboxController(IOConstants.kDriverControllerPort);
private final SendableChooser<Command> autoChooser;


/**
* The container for the robot. Contains subsystems, OI devices, and commands.
*/
public RobotContainer() {
autoChooser = AutoBuilder.buildAutoChooser();
SmartDashboard.putData("Auto Chooser", autoChooser);

AutoBuilder.configureHolonomic(m_robotDrive::getPose, m_robotDrive::resetOdometry,
m_robotDrive::getChassisSpeeds,
Expand Down Expand Up @@ -105,7 +111,8 @@ private void configureBindings() {
* @return the command to run in autonomous
*/
public Command getAutonomousCommand() {
PathPlannerPath path = PathPlannerPath.fromPathFile("New New Path");
Command follow = autoChooser.getSelected();
PathPlannerPath path = PathPlannerPath.fromPathFile(follow.getName());

var alliance = DriverStation.getAlliance();
PathPlannerPath autonPath = path;
Expand All @@ -115,10 +122,5 @@ public Command getAutonomousCommand() {
m_robotDrive.resetOdometry(autonPath.getPreviewStartingHolonomicPose());

return AutoBuilder.followPath(autonPath);
// return null;

// PathPlannerAuto pathPlannerAuto = new PathPlannerAuto("New Auto");

// return pathPlannerAuto;
}
}

0 comments on commit 8b52aa3

Please sign in to comment.