Class JoystickAxisTrigger
java.lang.Object
io.github.tigerbotics7125.tigerlib.input.trigger.Trigger
io.github.tigerbotics7125.tigerlib.input.trigger.JoystickAxisTrigger
- All Implemented Interfaces:
edu.wpi.first.util.sendable.Sendable
,BooleanSupplier
A
Trigger
wrapper for axes.-
Nested Class Summary
Nested classes/interfaces inherited from class io.github.tigerbotics7125.tigerlib.input.trigger.Trigger
Trigger.ActivationCondition
-
Constructor Summary
ConstructorDescriptionJoystickAxisTrigger
(edu.wpi.first.wpilibj.GenericHID joystick, int axis, double threshold, JoystickAxisTrigger.ThresholdType thresholdType, boolean invert) Create a newJoystickAxisTrigger
Object. -
Method Summary
Modifier and TypeMethodDescriptionvoid
double
getRaw()
double
getVal()
Unless overriden, the default implementation is to:void
initSendable
(edu.wpi.first.util.sendable.SendableBuilder builder) withThreshold
(JoystickAxisTrigger.ThresholdType thresholdType, double threshold) Create a newJoystickAxisTrigger
representing the same joystick axis, but with a different threshold condition.
-
Constructor Details
-
JoystickAxisTrigger
public JoystickAxisTrigger(edu.wpi.first.wpilibj.GenericHID joystick, int axis, double threshold, JoystickAxisTrigger.ThresholdType thresholdType, boolean invert) Create a newJoystickAxisTrigger
Object.- Parameters:
joystick
- The HID device to read the axis from.axis
- The axis index to read from.threshold
- The threshold to determine if the axis is pressed.thresholdType
- How to interpret the threshold.invert
- Whether the axis is inverted.
-
-
Method Details
-
getRaw
public double getRaw()- Returns:
- The axis value without inversion.
-
getVal
public double getVal()Unless overriden, the default implementation is to:JoystickUtil.deadband(double, double)
the value by .075.JoystickUtil.ramp(double, double)
the value by 3.JoystickUtil.clamp(double, double, double)
the value [-1, 1].- Returns:
- A cleansed joystick input.
-
clean
-
withThreshold
public JoystickAxisTrigger withThreshold(JoystickAxisTrigger.ThresholdType thresholdType, double threshold) Create a newJoystickAxisTrigger
representing the same joystick axis, but with a different threshold condition.- Parameters:
thresholdType
- The newJoystickAxisTrigger.ThresholdType
.threshold
- The new threshold.- Returns:
- A
JoystickAxisTrigger
with a new threshold.
-
initSendable
public void initSendable(edu.wpi.first.util.sendable.SendableBuilder builder) - Specified by:
initSendable
in interfaceedu.wpi.first.util.sendable.Sendable
- Overrides:
initSendable
in classTrigger
-