-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathRobotContainer.java
86 lines (70 loc) · 2.83 KB
/
RobotContainer.java
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
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018-2019 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/
package frc.robot;
import edu.wpi.first.wpilibj2.command.Command;
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
import edu.wpi.first.wpilibj.smartdashboard.SendableChooser;
// Import all the commands and subsystems
import frc.robot.commands.*;
import frc.robot.commands.autos.*;
import frc.robot.subsystems.*;
import com.stuypulse.stuylib.input.gamepads.*;
import com.stuypulse.stuylib.input.Gamepad;
/**
* This is where the majority of the robot code is going to be created.
*
* All button binds and commands are initialized here
*/
public class RobotContainer {
// Create new driver gamepad connected to port 0
private Gamepad driver = new PS4(0);
// Make the subsystems
private Drivetrain drivetrain = new Drivetrain();
private Shooter shooter = new Shooter();
/**
* Run at creation
*/
public RobotContainer() {
configureDefaultCommands();
configureButtonBindings();
configureSmartDashboard();
}
/**
* Creates default commands for everything to run
*/
private void configureDefaultCommands() {
drivetrain.setDefaultCommand(new DrivetrainDriveCommand(drivetrain, driver));
shooter.setDefaultCommand(new StopShooterCommand(shooter));
}
/**
* Creates button bindings for gamepad
*/
private void configureButtonBindings() {
// Basic setup that:
// runs shooter full speed while right button is held
// runs shooter half speed while bottom button is held
// aligns the robot with the target while left button is held
driver.getRightButton().whileHeld(new StartShooterCommand(shooter, 1000));
driver.getBottomButton().whileHeld(new StartShooterCommand(shooter, 500));
driver.getLeftButton().whileHeld(new DrivetrainAlignCommand(drivetrain));
}
// This lets us select an auton
private static SendableChooser<Command> autonChooser = new SendableChooser<>();
/**
* Put every auton that we made on smart dashboard
*/
private void configureSmartDashboard() {
autonChooser.addOption("Do Nothing", new DoNothingAutonCommand());
SmartDashboard.putData(autonChooser);
}
/**
* This lets us return which command we want to run during auton
*/
public Command getAutonomousCommand() {
return autonChooser.getSelected();
}
}