Package frclib.driverio
Class FrcJoystick
java.lang.Object
trclib.driverio.TrcGameController
frclib.driverio.FrcJoystick
- Direct Known Subclasses:
FrcSideWinderJoystick
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 interfaceThis interface, if provided, will allow this class to do a notification callback when there are button activities.static enumNested classes/interfaces inherited from class trclib.driverio.TrcGameController
TrcGameController.DriveMode -
Field Summary
FieldsFields inherited from class trclib.driverio.TrcGameController
instanceName, tracer -
Constructor Summary
ConstructorsConstructorDescriptionFrcJoystick(String instanceName, int port) Constructor: Create an instance of the object.FrcJoystick(String instanceName, int port, double deadbandThreshold) Constructor: Create an instance of the object. -
Method Summary
Modifier and TypeMethodDescriptionintThis 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.doubleThis method returns the throttle value of the stick.doublegetThrottle(boolean doExp) This method returns the throttle value of the stick.doublegetThrottle(double cubicCoefficient) This method returns the throttle value of the stick using the cubic polynomial curve.doublegetTwist()This method returns the twist-axis value of the stick.doublegetTwist(boolean doExp) This method returns the twist-axis value of the stick.doublegetTwist(double cubicCoefficient) This method returns the twist-axis value of the stick using the cubic polynomial curve.doublegetX()This method returns the x-axis value of the stick.doublegetX(boolean doExp) This method returns the x-axis value of the stick.doublegetX(double cubicCoefficient) This method returns the x-axis value of the stick using the cubic polynomial curve.doublegetY()This method returns the y-axis value of the stick.doublegetY(boolean doExp) This method returns the y-axis value of the stick.doublegetY(double cubicCoefficient) This method returns the y-axis value of the stick using the cubic polynomial curve.doublegetZ()This method returns the z-axis value of the stick.doublegetZ(boolean doExp) This method returns the z-axis value of the stick.doublegetZ(double cubicCoefficient) This method returns the z-axis value of the stick using the cubic polynomial curve.protected voidnotifyButtonEvent(int buttonValue, boolean pressed) This method is called when a button event is detected.voidsetButtonEventHandler(FrcJoystick.ButtonEventHandler buttonEventHandler) This method sets the button event handler.voidsetInverted(boolean xInverted, boolean yInverted) This method inverts the analog axes.voidsetInverted(boolean xInverted, boolean yInverted, boolean zInverted, boolean twistInverted) This method inverts the analog axes.Methods inherited from class trclib.driverio.TrcGameController
adjustAnalogControl, adjustAnalogControl, getDirectionDegrees, getDirectionRadians, getMagnitude, init, setButtonEventEnabled, setExponent, setSamplingPeriod, toString
-
Field Details
-
joystick
public final edu.wpi.first.wpilibj.Joystick joystick
-
-
Constructor Details
-
FrcJoystick
Constructor: Create an instance of the object.- Parameters:
instanceName- specifies the instance name.port- specifies the USB port the joystick is plugged into.deadbandThreshold- specifies the deadband of the analog joystick.
-
FrcJoystick
Constructor: Create an instance of the object.- Parameters:
instanceName- specifies the instance name.port- specifies the USB port the joystick is plugged into.
-
-
Method Details
-
setButtonEventHandler
This method sets the button event handler.- Parameters:
buttonEventHandler- specifies button event notification handler, null to disable event notification.
-
setInverted
public void setInverted(boolean xInverted, boolean yInverted, boolean zInverted, boolean twistInverted) This method inverts the analog axes.- 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.
-
setInverted
public void setInverted(boolean xInverted, boolean yInverted) This method inverts the analog axes.- Parameters:
xInverted- specifies true if inverting the x-axis, false otherwise.yInverted- specifies true if inverting the y-axis, false otherwise.
-
getX
public double getX(double cubicCoefficient) This method returns the x-axis value of the stick using the cubic polynomial curve.- Parameters:
cubicCoefficient- specifies the cubic coefficient.- Returns:
- x-axis value of the stick.
-
getX
public double getX(boolean doExp) This method returns the x-axis value of the 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 stick.
-
getX
public double getX()This method returns the x-axis value of the stick.- Returns:
- x-axis value of the stick.
-
getY
public double getY(double cubicCoefficient) This method returns the y-axis value of the stick using the cubic polynomial curve.- Parameters:
cubicCoefficient- specifies the cubic coefficient.- Returns:
- y-axis value of the stick.
-
getY
public double getY(boolean doExp) This method returns the y-axis value of the 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 stick.
-
getY
public double getY()This method returns the y-axis value of the stick.- Returns:
- y-axis value of the stick.
-
getZ
public double getZ(double cubicCoefficient) This method returns the z-axis value of the stick using the cubic polynomial curve.- Parameters:
cubicCoefficient- specifies the cubic coefficient.- Returns:
- z-axis value of the stick.
-
getZ
public double getZ(boolean doExp) This method returns the z-axis value of the 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 stick.
-
getZ
public double getZ()This method returns the z-axis value of the stick.- Returns:
- z-axis value of the stick.
-
getTwist
public double getTwist(double cubicCoefficient) This method returns the twist-axis value of the stick using the cubic polynomial curve.- Parameters:
cubicCoefficient- specifies the cubic coefficient.- Returns:
- twist-axis value of the stick.
-
getTwist
public double getTwist(boolean doExp) This method returns the twist-axis value of the 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 stick.
-
getTwist
public double getTwist()This method returns the twist-axis value of the stick.- Returns:
- twist-axis value of the stick.
-
getThrottle
public double getThrottle(double cubicCoefficient) This method returns the throttle value of the stick using the cubic polynomial curve.- Parameters:
cubicCoefficient- specifies the cubic coefficient.- Returns:
- throttle value of the stick.
-
getThrottle
public double getThrottle(boolean doExp) This method returns the throttle value of the 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:
- throttle value of the stick.
-
getThrottle
public double getThrottle()This method returns the throttle value of the stick.- Returns:
- throttle value of the stick.
-
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:
getButtonsin 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:
notifyButtonEventin classTrcGameController- Parameters:
buttonValue- specifies the button value that generated the event.pressed- specifies true if the button is pressed, false if it is released.
-