Skip to content

Commit

Permalink
Added RobotAutonomous
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeannrg committed Jan 14, 2024
1 parent 83abe4a commit e8791a7
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 1 deletion.
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,6 @@
}
},
],
"java.test.defaultConfig": "WPIlibUnitTests"
"java.test.defaultConfig": "WPIlibUnitTests",
"java.compile.nullAnalysis.mode": "automatic"
}
53 changes: 53 additions & 0 deletions src/main/java/frc/robot/RobotAutonomous.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
// Copyright (c) FIRST and other WPILib contributors.
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.


package frc.robot;

import com.nrg948.autonomous.Autonomous;

import edu.wpi.first.wpilibj.shuffleboard.BuiltInLayouts;
import edu.wpi.first.wpilibj.shuffleboard.ShuffleboardLayout;
import edu.wpi.first.wpilibj.shuffleboard.ShuffleboardTab;
import edu.wpi.first.wpilibj.smartdashboard.SendableChooser;
import edu.wpi.first.wpilibj2.command.Command;
import frc.robot.subsystems.Subsystems;

/**
* This class creates and manages the user interface operators used to select
* and configure autonomous routines.
*/
public class RobotAutonomous {
private final SendableChooser<Command> chooser;

/**
* Creates a new RobotAutonomous.
*
* @param subsystems The subsystems container.
*/
public RobotAutonomous(Subsystems subsystems) {
this.chooser = Autonomous.getChooser(subsystems, "frc.robot");
}

/**
* Returns the autonomous command selected in the chooser.
*
* @return The autonomous command selected in the chooser.
*/
public Command getAutonomousCommand(){
return this.chooser.getSelected();
}

/**
* Adds the autonomous layout to the shuffleboard tab.
*
* @param tab The tab to add the layout.
*/
public void addShuffleboardLayout(ShuffleboardTab tab) {
ShuffleboardLayout layout = tab.getLayout("Autonomous", BuiltInLayouts.kList)
.withPosition(0, 0)
.withSize(2, 2);
layout.add("Routine", chooser);
}
}

0 comments on commit e8791a7

Please sign in to comment.