2017 FRC Control SystemFRC Java Programming FRC Java BasicsJava conventions for objects, methods and variables

Java conventions for objects, methods and variables

Creating objects that are connected to the roboRIO in Java

Gyro headingGyro = new AnalogGyro(1);
double heading = headingGyro.getAngle();

Generally all the objects in WPILib that connect to one of the roboRIO breakout boards have one argument in the constructor when created where you specify the channel or port number it is connected to. The above example illustrate the conventions used in WPILib for Java.

  1. Creates an AnalogGyro object connected to analog channel 1 and stores its address in "headingGyro".
  2. Gets the current heading from the AnalogGyro in degrees and stores it in the variable "heading".

Creating operator interface objects in Java

Creating operator interface objects in Java

Generally objects connected to the Driver station PC via USB take a single argument indicating the USB port they are connected to. A single Joystick class is provided which should provide the functionality needed to interface with any joystick or gamepad which works with the FRC Driver Station.

  1. Creates a Joystick object connected to USB port 1 on the DS (listed first in the Setup tab of the DS).
  2. Gets the current X axis value of the joystick and stores it in the variable "speed".

Class, method and variable naming

Class, method and variable naming

MXP IO Numbering

MXP IO Numbering

In C++ and Java the numbering for the MXP IO is a continuation of the numbering from the headers, meaning MXP DIO 0 is DIO 10, MXP DIO 1 is DIO 11 and so on. This applies to DIO, PWM and Analog Input on the MXP. The I2C and SPI buses have enumerations used to indicate which port you are using.

0 Report Errors

Use this form to report any errors with the documentation. For help with WPILib, please use the FIRST Forums at http://forums.usfirst.org For reporting WPILib bugs, please submit an issue on GitHub at https://github.com/wpilibsuite/allwpilib/issues/new

Ignore