Package frclib.driverio
Class FrcDualJoystick
java.lang.Object
trclib.driverio.TrcGameController
frclib.driverio.FrcDualJoystick
This class implements the platform dependent joystick. It provides monitoring of the joystick buttons. If the
caller of this class provides a button notification handler, it will call it when there are button events.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interface
This interface, if provided, will allow this class to do a notification callback when there are button activities.static enum
Nested classes/interfaces inherited from class trclib.driverio.TrcGameController
TrcGameController.DriveMode
-
Field Summary
FieldsModifier and TypeFieldDescriptionfinal edu.wpi.first.wpilibj.Joystick
final edu.wpi.first.wpilibj.Joystick
Fields inherited from class trclib.driverio.TrcGameController
instanceName, tracer
-
Constructor Summary
ConstructorsConstructorDescriptionFrcDualJoystick
(String instanceName, int leftPort, int rightPort) Constructor: Create an instance of the object.FrcDualJoystick
(String instanceName, int leftPort, int rightPort, double deadbandThreshold) Constructor: Create an instance of the object. -
Method Summary
Modifier and TypeMethodDescriptionint
This method returns the button states in an integer by combining all the button states.double[]
getDriveInputs
(TrcGameController.DriveMode driveMode, boolean doExp) This method reads various joystick/gamepad control values and returns the drive powers for all three degrees of robot movement.double[]
getDriveInputs
(TrcGameController.DriveMode driveMode, boolean doExp, double drivePowerScale, double turnPowerScale) This method reads various joystick/gamepad control values and returns the drive powers for all three degrees of robot movement.double
This method returns the twist-axis value of the left stick.double
getLeftStickTwist
(boolean doExp) This method returns the twist-axis value of the left stick.double
getLeftStickTwist
(double cubicCoefficient) This method returns the twist-axis value of the left stick using the cubic polynomial curve.double
This method returns the x-axis value of the left stick.double
getLeftStickX
(boolean doExp) This method returns the x-axis value of the left stick.double
getLeftStickX
(double cubicCoefficient) This method returns the x-axis value of the left stick using the cubic polynomial curve.double
This method returns the y-axis value of the left stick.double
getLeftStickY
(boolean doExp) This method returns the y-axis value of the left stick.double
getLeftStickY
(double cubicCoefficient) This method returns the y-axis value of the left stick using the cubic polynomial curve.double
This method returns the z-axis value of the left stick.double
getLeftStickZ
(boolean doExp) This method returns the z-axis value of the left stick.double
getLeftStickZ
(double cubicCoefficient) This method returns the z-axis value of the left stick using the cubic polynomial curve.double
This method returns the throttle value of the left joystick.double
getLeftThrottle
(boolean doExp) This method returns the throttle value of the left joystick.double
getLeftThrottle
(double cubicCoefficient) This method returns the throttle value of the left joystick using the cubic polynomial curve.double
This method returns the twist-axis value of the right stick.double
getRightStickTwist
(boolean doExp) This method returns the twist-axis value of the right stick.double
getRightStickTwist
(double cubicCoefficient) This method returns the twist-axis value of the right stick using the cubic polynomial curve.double
This method returns the x-axis value of the right stick.double
getRightStickX
(boolean doExp) This method returns the x-axis value of the right stick.double
getRightStickX
(double cubicCoefficient) This method returns the x-axis value of the right stick using the cubic polynomial curve.double
This method returns the y-axis value of the right stick.double
getRightStickY
(boolean doExp) This method returns the y-axis value of the right stick.double
getRightStickY
(double cubicCoefficient) This method returns the y-axis value of the right stick using the cubic polynomial curve.double
This method returns the z-axis value of the right stick.double
getRightStickZ
(boolean doExp) This method returns the z-axis value of the right stick.double
getRightStickZ
(double cubicCoefficient) This method returns the z-axis value of the right stick using the cubic polynomial curve.double
This method returns the throttle value of the right joystick.double
getRightThrottle
(boolean doExp) This method returns the throttle value of the right joystick.double
getRightThrottle
(double cubicCoefficient) This method returns the throttle value of the right joystick using the cubic polynomial curve.protected void
notifyButtonEvent
(int buttonValue, boolean pressed) This method is called when a button event is detected.void
setButtonEventHandler
(FrcDualJoystick.ButtonEventHandler buttonEventHandler) This method sets the button event handler for the joystick buttons.void
setLeftStickInverted
(boolean xInverted, boolean yInverted) This method inverts the analog axes of the left joystick.void
setLeftStickInverted
(boolean xInverted, boolean yInverted, boolean zInverted, boolean twistInverted) This method inverts the analog axes of the left joystick.void
setRightStickInverted
(boolean xInverted, boolean yInverted) This method inverts the analog axes of the right joystick.void
setRightStickInverted
(boolean xInverted, boolean yInverted, boolean zInverted, boolean twistInverted) This method inverts the analog axes of the right joystick.Methods inherited from class trclib.driverio.TrcGameController
adjustAnalogControl, adjustAnalogControl, getDirectionDegrees, getDirectionRadians, getMagnitude, init, setButtonEventEnabled, setExponent, setSamplingPeriod, toString
-
Field Details
-
leftJoystick
public final edu.wpi.first.wpilibj.Joystick leftJoystick -
rightJoystick
public final edu.wpi.first.wpilibj.Joystick rightJoystick
-
-
Constructor Details
-
FrcDualJoystick
Constructor: Create an instance of the object.- Parameters:
instanceName
- specifies the instance name.leftPort
- specifies the USB port for the left joystick.rightPort
- specifies the USB port for the left joystick.deadbandThreshold
- specifies the deadband of the analog joysticks.
-
FrcDualJoystick
Constructor: Create an instance of the object.- Parameters:
instanceName
- specifies the instance name.leftPort
- specifies the USB port for the left joystick.rightPort
- specifies the USB port for the left joystick.
-
-
Method Details
-
setButtonEventHandler
This method sets the button event handler for the joystick buttons.- Parameters:
buttonEventHandler
- specifies button event notification handler, null to disable event notification.
-
setLeftStickInverted
public void setLeftStickInverted(boolean xInverted, boolean yInverted, boolean zInverted, boolean twistInverted) This method inverts the analog axes of the left joystick.- Parameters:
xInverted
- specifies true if inverting the x-axis, false otherwise.yInverted
- specifies true if inverting the y-axis, false otherwise.zInverted
- specifies true if inverting the z-axis, false otherwise.twistInverted
- specifies true if inverting the twist-axis, false otherwise.
-
setLeftStickInverted
public void setLeftStickInverted(boolean xInverted, boolean yInverted) This method inverts the analog axes of the left joystick.- Parameters:
xInverted
- specifies true if inverting the x-axis, false otherwise.yInverted
- specifies true if inverting the y-axis, false otherwise.
-
setRightStickInverted
public void setRightStickInverted(boolean xInverted, boolean yInverted, boolean zInverted, boolean twistInverted) This method inverts the analog axes of the right joystick.- Parameters:
xInverted
- specifies true if inverting the x-axis, false otherwise.yInverted
- specifies true if inverting the y-axis, false otherwise.zInverted
- specifies true if inverting the z-axis, false otherwise.twistInverted
- specifies true if inverting the twist-axis, false otherwise.
-
setRightStickInverted
public void setRightStickInverted(boolean xInverted, boolean yInverted) This method inverts the analog axes of the right joystick.- Parameters:
xInverted
- specifies true if inverting the x-axis, false otherwise.yInverted
- specifies true if inverting the y-axis, false otherwise.
-
getLeftStickX
public double getLeftStickX(double cubicCoefficient) This method returns the x-axis value of the left stick using the cubic polynomial curve.- Parameters:
cubicCoefficient
- specifies the cubic coefficient.- Returns:
- x-axis value of the left stick.
-
getLeftStickX
public double getLeftStickX(boolean doExp) This method returns the x-axis value of the left stick.- Parameters:
doExp
- specifies true if the value should be raised exponentially, false otherwise. If the value is raised exponentially, it gives you more precise control on the low end values.- Returns:
- x-axis value of the left stick.
-
getLeftStickX
public double getLeftStickX()This method returns the x-axis value of the left stick.- Returns:
- x-axis value of the left stick.
-
getLeftStickY
public double getLeftStickY(double cubicCoefficient) This method returns the y-axis value of the left stick using the cubic polynomial curve.- Parameters:
cubicCoefficient
- specifies the cubic coefficient.- Returns:
- y-axis value of the left stick.
-
getLeftStickY
public double getLeftStickY(boolean doExp) This method returns the y-axis value of the left stick.- Parameters:
doExp
- specifies true if the value should be raised exponentially, false otherwise. If the value is raised exponentially, it gives you more precise control on the low end values.- Returns:
- y-axis value of the left stick.
-
getLeftStickY
public double getLeftStickY()This method returns the y-axis value of the left stick.- Returns:
- y-axis value of the left stick.
-
getLeftStickZ
public double getLeftStickZ(double cubicCoefficient) This method returns the z-axis value of the left stick using the cubic polynomial curve.- Parameters:
cubicCoefficient
- specifies the cubic coefficient.- Returns:
- z-axis value of the left stick.
-
getLeftStickZ
public double getLeftStickZ(boolean doExp) This method returns the z-axis value of the left stick.- Parameters:
doExp
- specifies true if the value should be raised exponentially, false otherwise. If the value is raised exponentially, it gives you more precise control on the low end values.- Returns:
- z-axis value of the left stick.
-
getLeftStickZ
public double getLeftStickZ()This method returns the z-axis value of the left stick.- Returns:
- z-axis value of the left stick.
-
getLeftStickTwist
public double getLeftStickTwist(double cubicCoefficient) This method returns the twist-axis value of the left stick using the cubic polynomial curve.- Parameters:
cubicCoefficient
- specifies the cubic coefficient.- Returns:
- twist-axis value of the left stick.
-
getLeftStickTwist
public double getLeftStickTwist(boolean doExp) This method returns the twist-axis value of the left stick.- Parameters:
doExp
- specifies true if the value should be raised exponentially, false otherwise. If the value is raised exponentially, it gives you more precise control on the low end values.- Returns:
- twist-axis value of the left stick.
-
getLeftStickTwist
public double getLeftStickTwist()This method returns the twist-axis value of the left stick.- Returns:
- twist-axis value of the left stick.
-
getRightStickX
public double getRightStickX(double cubicCoefficient) This method returns the x-axis value of the right stick using the cubic polynomial curve.- Parameters:
cubicCoefficient
- specifies the cubic coefficient.- Returns:
- x-axis value of the right stick.
-
getRightStickX
public double getRightStickX(boolean doExp) This method returns the x-axis value of the right stick.- Parameters:
doExp
- specifies true if the value should be raised exponentially, false otherwise. If the value is raised exponentially, it gives you more precise control on the low end values.- Returns:
- x-axis value of the right stick.
-
getRightStickX
public double getRightStickX()This method returns the x-axis value of the right stick.- Returns:
- x-axis value of the right stick.
-
getRightStickY
public double getRightStickY(double cubicCoefficient) This method returns the y-axis value of the right stick using the cubic polynomial curve.- Parameters:
cubicCoefficient
- specifies the cubic coefficient.- Returns:
- y-axis value of the right stick.
-
getRightStickY
public double getRightStickY(boolean doExp) This method returns the y-axis value of the right stick.- Parameters:
doExp
- specifies true if the value should be raised exponentially, false otherwise. If the value is raised exponentially, it gives you more precise control on the low end values.- Returns:
- y-axis value of the right stick.
-
getRightStickY
public double getRightStickY()This method returns the y-axis value of the right stick.- Returns:
- y-axis value of the right stick.
-
getRightStickZ
public double getRightStickZ(double cubicCoefficient) This method returns the z-axis value of the right stick using the cubic polynomial curve.- Parameters:
cubicCoefficient
- specifies the cubic coefficient.- Returns:
- z-axis value of the right stick.
-
getRightStickZ
public double getRightStickZ(boolean doExp) This method returns the z-axis value of the right stick.- Parameters:
doExp
- specifies true if the value should be raised exponentially, false otherwise. If the value is raised exponentially, it gives you more precise control on the low end values.- Returns:
- z-axis value of the right stick.
-
getRightStickZ
public double getRightStickZ()This method returns the z-axis value of the right stick.- Returns:
- z-axis value of the right stick.
-
getRightStickTwist
public double getRightStickTwist(double cubicCoefficient) This method returns the twist-axis value of the right stick using the cubic polynomial curve.- Parameters:
cubicCoefficient
- specifies the cubic coefficient.- Returns:
- twist-axis value of the right stick.
-
getRightStickTwist
public double getRightStickTwist(boolean doExp) This method returns the twist-axis value of the right stick.- Parameters:
doExp
- specifies true if the value should be raised exponentially, false otherwise. If the value is raised exponentially, it gives you more precise control on the low end values.- Returns:
- twist-axis value of the right stick.
-
getRightStickTwist
public double getRightStickTwist()This method returns the twist-axis value of the right stick.- Returns:
- twist-axis value of the right stick.
-
getLeftThrottle
public double getLeftThrottle(double cubicCoefficient) This method returns the throttle value of the left joystick using the cubic polynomial curve.- Parameters:
cubicCoefficient
- specifies the cubic coefficient.- Returns:
- throttle value of the left joystick.
-
getLeftThrottle
public double getLeftThrottle(boolean doExp) This method returns the throttle value of the left joystick.- Parameters:
doExp
- specifies true if the value should be raised exponentially, false otherwise. If the value is raised exponentially, it gives you more precise control on the low end values.- Returns:
- throttle value of the left joystick.
-
getLeftThrottle
public double getLeftThrottle()This method returns the throttle value of the left joystick.- Returns:
- throttle value of the left joystick.
-
getRightThrottle
public double getRightThrottle(double cubicCoefficient) This method returns the throttle value of the right joystick using the cubic polynomial curve.- Parameters:
cubicCoefficient
- specifies the cubic coefficient.- Returns:
- throttle value of the right joystick.
-
getRightThrottle
public double getRightThrottle(boolean doExp) This method returns the throttle value of the right joystick.- Parameters:
doExp
- specifies true if the value should be raised exponentially, false otherwise. If the value is raised exponentially, it gives you more precise control on the low end values.- Returns:
- throttle value of the right joystick.
-
getRightThrottle
public double getRightThrottle()This method returns the throttle value of the right joystick.- Returns:
- throttle value of the right joystick.
-
getDriveInputs
public double[] getDriveInputs(TrcGameController.DriveMode driveMode, boolean doExp, double drivePowerScale, double turnPowerScale) This method reads various joystick/gamepad control values and returns the drive powers for all three degrees of robot movement.- Parameters:
driveMode
- specifies the drive mode which determines the control mappings.doExp
- specifies true if the value should be raised exponentially, false otherwise. If the value is raised exponentially, it gives you more precise control on the low end values.drivePowerScale
- specifies the scaling factor for drive power.turnPowerScale
- specifies the scaling factor for turn power.- Returns:
- an array of 3 values for x, y and rotation power.
-
getDriveInputs
This method reads various joystick/gamepad control values and returns the drive powers for all three degrees of robot movement.- Parameters:
driveMode
- specifies the drive mode which determines the control mappings.doExp
- specifies true if the value should be raised exponentially, false otherwise. If the value is raised exponentially, it gives you more precise control on the low end values.- Returns:
- an array of 3 values for x, y and rotation power.
-
getButtons
public int getButtons()This method returns the button states in an integer by combining all the button states.- Specified by:
getButtons
in classTrcGameController
- Returns:
- button states.
-
notifyButtonEvent
protected void notifyButtonEvent(int buttonValue, boolean pressed) This method is called when a button event is detected. It translates the button value into button type and calls the button event handler.- Specified by:
notifyButtonEvent
in classTrcGameController
- Parameters:
buttonValue
- specifies the button value that generated the event.pressed
- specifies true if the button is pressed, false if it is released.
-