-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOI.java
More file actions
101 lines (83 loc) · 4.85 KB
/
OI.java
File metadata and controls
101 lines (83 loc) · 4.85 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
package frc.robot;
import java.util.function.DoubleSupplier;
import edu.wpi.first.wpilibj2.command.InstantCommand;
import edu.wpi.first.wpilibj2.command.button.JoystickButton;
import edu.wpi.first.wpilibj2.command.button.Trigger;
import frc.robot.subsystems.Elevator;
import edu.wpi.first.wpilibj.XboxController;
public class OI {
// Reference to RobotContainer for accessing subsystems
/**
* Initialize OI with a reference to RobotContainer
* @param container The RobotContainer instance
*/
/**
* Controller port mappings
*/
private static class PORT {
private static final int DRIVE_CONTROLLER_PORT = 0;
private static final int OPERATOR_CONTROLLER_PORT = 1; // Added operator controller port
}
// Trigger thresholds
public static final double TRIGGER_THRESHOLD = 0.1;
/**
* Bidings on driver controls
*/
private static final XboxController xboxController = new XboxController(PORT.DRIVE_CONTROLLER_PORT);
public static final XboxController operatorController = new XboxController(PORT.OPERATOR_CONTROLLER_PORT); // Changed to public
private static class DRIVER_MAP {
private static final int ABUTTON = XboxController.Button.kA.value;
private static final int BBUTTON = XboxController.Button.kB.value;
}
// drive sticks
public static DoubleSupplier xboxLeftStickXSupplier = () -> { return processDriveInput(-xboxController.getLeftX()); };
public static DoubleSupplier xboxLeftStickYSupplier = () -> { return processDriveInput(-xboxController.getLeftY()); };
public static DoubleSupplier xboxRightStickXSupplier = () -> { return processRotationInput(-xboxController.getRightX()); };
public static DoubleSupplier xboxRightStickYSupplier = () -> { return processRotationInput(xboxController.getRightY()); };
// drive buttons
public static final JoystickButton driveControllerA = new JoystickButton(xboxController, DRIVER_MAP.ABUTTON);
public static final JoystickButton driveControllerB = new JoystickButton(xboxController, DRIVER_MAP.BBUTTON);
public static final Trigger driveRightTrigger = new Trigger(() ->
xboxController.getRightTriggerAxis() > TRIGGER_THRESHOLD);
private static double processDriveInput(double raw) {
if (Math.abs(raw) < 0.1) {
raw = 0 ;
}
return raw;
}
private static double processRotationInput(double raw) {
if (Math.abs(raw) < 0.1) {
raw = 0;
}
return raw*4;
}
/**
* Bindings on operator controls
*/
private static class operatorBindings {
private static final int A_BUTTON = XboxController.Button.kA.value;
private static final int B_BUTTON = XboxController.Button.kB.value;
private static final int X_BUTTON = XboxController.Button.kX.value;
private static final int Y_BUTTON = XboxController.Button.kY.value;
private static final int LEFT_BUMPER = XboxController.Button.kLeftBumper.value;
private static final int RIGHT_BUMPER = XboxController.Button.kRightBumper.value;
private static final int START_BUTTON = XboxController.Button.kStart.value;
private static final int BACK_BUTTON = XboxController.Button.kBack.value;
}
public static final JoystickButton operatorControllerA = new JoystickButton(operatorController, operatorBindings.A_BUTTON);
public static final JoystickButton operatorControllerB = new JoystickButton(operatorController, operatorBindings.B_BUTTON);
public static final JoystickButton operatorControllerX = new JoystickButton(operatorController, operatorBindings.X_BUTTON);
public static final JoystickButton operatorControllerY = new JoystickButton(operatorController, operatorBindings.Y_BUTTON);
public static final JoystickButton operatorControllerLeftBumper = new JoystickButton(operatorController, operatorBindings.LEFT_BUMPER);
public static final JoystickButton operatorControllerRightBumper = new JoystickButton(operatorController, operatorBindings.RIGHT_BUMPER);
public static final JoystickButton operatorControllerStart = new JoystickButton(operatorController, operatorBindings.START_BUTTON);
public static final JoystickButton operatorControllerBack = new JoystickButton(operatorController, operatorBindings.BACK_BUTTON);
// Trigger controls for coral claw
public static final Trigger operatorRightTrigger = new Trigger(() ->
operatorController.getRightTriggerAxis() > TRIGGER_THRESHOLD);
public static final Trigger operatorLeftTrigger = new Trigger(() ->
operatorController.getLeftTriggerAxis() > TRIGGER_THRESHOLD);
public static double processElevatorInput(double input) {
return -Math.signum(input) * Math.pow(Math.abs(input), 2) * 0.7;
}
}