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 ClassesNested classes/interfaces inherited from class io.github.tigerbotics7125.tigerlib.input.trigger.Trigger
Trigger.ActivationCondition -
Constructor Summary
ConstructorsConstructorDescriptionJoystickAxisTrigger(edu.wpi.first.wpilibj.GenericHID joystick, int axis, double threshold, JoystickAxisTrigger.ThresholdType thresholdType, boolean invert) Create a newJoystickAxisTriggerObject. -
Method Summary
Modifier and TypeMethodDescriptionvoiddoublegetRaw()doublegetVal()Unless overriden, the default implementation is to:voidinitSendable(edu.wpi.first.util.sendable.SendableBuilder builder) withThreshold(JoystickAxisTrigger.ThresholdType thresholdType, double threshold) Create a newJoystickAxisTriggerrepresenting 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 newJoystickAxisTriggerObject.- 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 newJoystickAxisTriggerrepresenting the same joystick axis, but with a different threshold condition.- Parameters:
thresholdType- The newJoystickAxisTrigger.ThresholdType.threshold- The new threshold.- Returns:
- A
JoystickAxisTriggerwith a new threshold.
-
initSendable
public void initSendable(edu.wpi.first.util.sendable.SendableBuilder builder) - Specified by:
initSendablein interfaceedu.wpi.first.util.sendable.Sendable- Overrides:
initSendablein classTrigger
-