-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRobotContainer.java
More file actions
151 lines (130 loc) · 5.26 KB
/
RobotContainer.java
File metadata and controls
151 lines (130 loc) · 5.26 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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
// 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 edu.wpi.first.wpilibj.GenericHID;
import edu.wpi.first.wpilibj.XboxController;
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;
import edu.wpi.first.wpilibj2.command.WaitCommand;
import edu.wpi.first.wpilibj2.command.button.JoystickButton;
import edu.wpi.first.wpilibj2.command.button.Trigger;
import frc.robot.commands.ClimberBackC;
import frc.robot.commands.ClimberExtendsC;
import frc.robot.commands.ClimberForwardC;
import frc.robot.commands.ClimberRetractsC;
import frc.robot.commands.ClimberForwardC;
import frc.robot.commands.ClimberBackC;
import frc.robot.commands.ShooterC;
import frc.robot.subsystems.ClimberS;
import frc.robot.subsystems.DrivebaseS;
import frc.robot.subsystems.ShooterS;
import frc.robot.subsystems.TurretS;
import frc.robot.commands.turret.TurretCommandFactory;
/**
* 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 {
// The robot's subsystems and commands are defined here...
/**
* The container for the robot. Contains subsystems, OI devices, and commands.
*/
private XboxController driverController;
private XboxController operatorController;
private Command xboxDriveCommand;
private Command xboxShooterCommand;
private DrivebaseS drivebaseS;
private ShooterS shooterS;
private TurretS turretS;
private ClimberS climberS;
private Command runTurretC;
private Command turretHomingC;
private Command turretTurningC;
private Command climberForwardC;
private Command climberBackC;
// Trigger definitions
private Trigger spinTurretTrigger;
private Trigger turretHomeTrigger;
private Trigger turretTurnTrigger;
//private Trigger extendsClimber;
//private Trigger retractClimber;
private Trigger climberForward;
private Trigger climberBack;
public RobotContainer() {
// Configure the button bindings
createControllers();
createSubsystems();
createCommands();
configureButtonBindings();
}
/**
* 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.wpilibj2.command.button.JoystickButton}.
*/
private void configureButtonBindings() {
//new Trigger(driverController::getAButton).whileActiveOnce(xboxShooterCommand);
/*spinTurretTrigger = new Trigger(driverController::getBButton);
spinTurretTrigger.whileActiveOnce(runTurretC);
turretHomeTrigger = new Trigger(driverController::getXButton);
turretHomeTrigger.whenActive(turretHomingC);
turretTurnTrigger = new Trigger(driverController::getYButton);
turretTurnTrigger.whenActive(turretTurningC);*/
//extendsClimber = new Trigger(operatorController::getAButton);
//extendsClimber.whenActive(new ClimberExtendsC(climberS));
//retractClimber = new Trigger(operatorController::getBButton);
//retractClimber.whenActive(new ClimberRetractsC(climberS));
climberForward = new Trigger(operatorController::getAButton);
climberForward.whileActiveOnce(climberForwardC);
climberBack = new Trigger(operatorController::getBButton);
climberBack.whileActiveOnce(climberBackC);
}
private void createControllers() {
driverController = new XboxController(Constants.USB_PORT_DRIVER_CONTROLLER);
operatorController = new XboxController(Constants.USB_PORT_OPERATOR_CONTROLLER);
}
private void createCommands() {
xboxDriveCommand = new RunCommand(
()
-> {drivebaseS.curvatureDrive(
driverController.getRightTriggerAxis() - driverController.getLeftTriggerAxis(),
driverController.getLeftX()
);
}
, drivebaseS);
drivebaseS.setDefaultCommand(xboxDriveCommand);
runTurretC = TurretCommandFactory.createTurretManualC(
driverController::getRightX, turretS);
turretS.setDefaultCommand(runTurretC);
turretHomingC = TurretCommandFactory.createTurretHomingC(turretS);
turretTurningC = TurretCommandFactory.createTurretTurnC(40, turretS);
SmartDashboard.putData(new InstantCommand(turretS::resetEncoder));
climberForwardC = new ClimberForwardC(climberS);
climberBackC = new ClimberBackC(climberS);
}
private void createSubsystems() {
drivebaseS = new DrivebaseS();
turretS = new TurretS();
climberS = new ClimberS();
}
/**
* Use this to pass the autonomous command to the main {@link Robot} class.
*
* @return the command to run in autonomous
*/
public Command getAutonomousCommand() {
// An ExampleCommand will run in autonomous
return new WaitCommand(0);
}
}