-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathRobotContainer.java
More file actions
97 lines (77 loc) · 3.4 KB
/
RobotContainer.java
File metadata and controls
97 lines (77 loc) · 3.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
package frc.robot;
import java.io.File;
import com.pathplanner.lib.auto.AutoBuilder;
import com.pathplanner.lib.auto.NamedCommands;
import edu.wpi.first.math.geometry.Pose2d;
import edu.wpi.first.wpilibj.DriverStation;
import edu.wpi.first.wpilibj.Filesystem;
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 frc.robot.Constants.ControllerConstants;
import frc.robot.controls.DriverControls;
import frc.robot.controls.OperatorControls;
import frc.robot.controls.PoseControls;
import frc.robot.subsystems.HopperSubsystem;
import frc.robot.subsystems.IntakeSubsystem;
import frc.robot.subsystems.KickerSubsystem;
import frc.robot.subsystems.ShooterSubsystem;
import frc.robot.subsystems.Superstructure;
import frc.robot.subsystems.SwerveSubsystem;
import swervelib.SwerveDrive;
public class RobotContainer {
private final SwerveSubsystem drivebase = new SwerveSubsystem(new File(Filesystem.getDeployDirectory(), "swerve"));
private final IntakeSubsystem intake = new IntakeSubsystem();
private final HopperSubsystem hopper = new HopperSubsystem();
private final KickerSubsystem kicker = new KickerSubsystem();
private final ShooterSubsystem shooter = new ShooterSubsystem();
private final Superstructure superstructure = new Superstructure(shooter, null, null, intake, hopper, kicker);
private final SendableChooser<Command> autoChooser;
/**
* The container for the robot. Contains subsystems, I/O devices, and commands.
*/
public RobotContainer() {
// Configure the trigger bindings
configureBindings();
buildNamedAutoCommands();
if (!Robot.isReal()) {
DriverStation.silenceJoystickConnectionWarning(true);
}
// Have the autoChooser pull in all PathPlanner autos as options
autoChooser = AutoBuilder.buildAutoChooser();
// Set the default auto (do nothing)
autoChooser.setDefaultOption("Do Nothing", Commands.none());
// Add a simple auto option to have the robot drive forward for 1 second then
// stop
autoChooser.addOption("Drive Forward", drivebase.driveForward().withTimeout(10));
// Put the autoChooser on the SmartDashboard
SmartDashboard.putData("Auto Chooser", autoChooser);
}
private void configureBindings() {
// Set up controllers
DriverControls.configure(ControllerConstants.kDriverControllerPort, drivebase, superstructure);
OperatorControls.configure(ControllerConstants.kOperatorControllerPort, drivebase, superstructure);
PoseControls.configure(ControllerConstants.kPoseControllerPort, drivebase);
}
private void buildNamedAutoCommands() {
// Add any auto commands to the NamedCommands here
NamedCommands.registerCommand("ScoreCoral",
Commands.runOnce(() -> System.out.println("Scoring Coral!"), drivebase)
.andThen(Commands.waitSeconds(1))
.withName("Auto.ScoreCoral"));
NamedCommands.registerCommand("Dealgae",
Commands.runOnce(() -> System.out.println("Dealgae!"), drivebase)
.andThen(Commands.waitSeconds(1))
.withName("Auto.Dealgae"));
}
public Command getAutonomousCommand() {
return autoChooser.getSelected();
}
public SwerveDrive getSwerveDrive() {
return drivebase.getSwerveDrive();
}
public Pose2d getRobotPose() {
return drivebase.getPose();
}
}