public final class Lightning
extends java.lang.Object
Lightning
class exposes methods for general interfacing with the hardware on
the physical robot. The static methods in the class can be used for things such as
accessing the joysticks, and getting hardware objects.Modifier and Type | Field and Description |
---|---|
private static JoystickMonitor |
monitor1
The joystick monitor for joystick 1.
|
private static JoystickMonitor |
monitor2
The joystick monitor for joystick 1.
|
private static LightningOpMode |
opmode
The op mode to get hardware and objects from.
|
private static com.qualcomm.robotcore.hardware.HardwareMap |
robotHardware
The
HardwareMap that is used as a portal to all hardware on the robot. |
private static java.util.List<com.qualcomm.robotcore.hardware.HardwareMap.DeviceMapping<?>> |
sensorMaps
A list of all the
DeviceMapping s exposed by the hardware map that could
point to sensors. |
private static TaskScheduler |
taskScheduler
The master task scheduler that is used to execute all background tasks in the SDK
and in client code of the SDK.
|
Modifier | Constructor and Description |
---|---|
private |
Lightning()
Lightning should not be instantiable. |
Modifier and Type | Method and Description |
---|---|
static Joystick |
getJoystick(int joystick)
Gets a reference to the given joystick.
|
static JoystickMonitor |
getJoystickMonitor(int joystick)
Gets a reference to the joystick monitor for the given joystick.
|
static Motor |
getMotor(java.lang.String name)
Gets a reference to the motor with the given name.
|
static <T> T |
getSensor(java.lang.String name)
Gets a reference to any sensor on the robot with the given name.
|
private static java.util.List<com.qualcomm.robotcore.hardware.HardwareMap.DeviceMapping<?>> |
getSensorMaps(com.qualcomm.robotcore.hardware.HardwareMap map)
Returns a list of
DeviceMapping s in the given HardwareMap that could
contain sensors. |
static Servo |
getServo(java.lang.String name)
Gets a reference to the servo with the given name.
|
static TaskScheduler |
getTaskScheduler()
Gets a reference to the main task scheduler.
|
static void |
initializeLightning(LightningOpMode opmode)
Initializes the static members in
Lightning from the given
LightningOpMode . |
private static LightningOpMode opmode
Lightning
is provided by this op mode.private static com.qualcomm.robotcore.hardware.HardwareMap robotHardware
HardwareMap
that is used as a portal to all hardware on the robot.HardwareMap
private static java.util.List<com.qualcomm.robotcore.hardware.HardwareMap.DeviceMapping<?>> sensorMaps
DeviceMapping
s exposed by the hardware map that could
point to sensors.robotHardware
private static TaskScheduler taskScheduler
private static JoystickMonitor monitor1
JoystickMonitor
private static JoystickMonitor monitor2
JoystickMonitor
public static void initializeLightning(LightningOpMode opmode)
Lightning
from the given
LightningOpMode
.opmode
- the op mode to get information from.opmode
public static TaskScheduler getTaskScheduler()
taskScheduler
public static Joystick getJoystick(int joystick)
joystick1
and
joystick2
are supported.joystick
- the ID of the joystick to return; can only be 1 or 2.java.lang.IllegalArgumentException
- if the given joystick ID is not 1 or 2.public static JoystickMonitor getJoystickMonitor(int joystick)
joystick1
and joystick2
are supported.public static Motor getMotor(java.lang.String name)
CRServo
object representing that servo is returned.name
- the name of the motor.CRServo
public static Servo getServo(java.lang.String name)
name
- the name of the servo.public static <T> T getSensor(java.lang.String name)
name
- the name of the sensor.java.lang.IllegalArgumentException
- if no sensors exist with the given name.private static java.util.List<com.qualcomm.robotcore.hardware.HardwareMap.DeviceMapping<?>> getSensorMaps(com.qualcomm.robotcore.hardware.HardwareMap map)
DeviceMapping
s in the given HardwareMap
that could
contain sensors.
This method essentially works by enumerating the known device mappings that could contain sensors. If more device mappings are added to FTC's built-in SDK, this method will need to be updated before any new sensors can be accessed through Lightning.
map
- the hardware map to search for sensor maps in.