public abstract class LinearOpMode extends OpMode
This class derives from OpMode, but you should not override the methods from OpMode.
Modifier and Type | Class and Description |
---|---|
protected class |
LinearOpMode.LinearOpModeHelper |
gamepad1, gamepad2, hardwareMap, internalOpModeServices, msStuckDetectInit, msStuckDetectInitLoop, msStuckDetectLoop, msStuckDetectStart, msStuckDetectStop, telemetry, time
Constructor and Description |
---|
LinearOpMode() |
Modifier and Type | Method and Description |
---|---|
protected void |
handleLoop() |
void |
idle()
Puts the current thread to sleep for a bit as it has nothing better to do.
|
void |
init_loop()
From the non-linear OpMode; do not override
|
void |
init()
From the non-linear OpMode; do not override
|
void |
internalPostInitLoop()
automatically update telemetry in a non-linear opmode
|
void |
internalPostLoop()
automatically update telemetry in a non-linear opmode
|
boolean |
isStarted()
Has the opMode been started?
|
boolean |
isStopRequested()
Has the the stopping of the opMode been requested?
|
void |
loop()
From the non-linear OpMode; do not override
|
boolean |
opModeIsActive()
Answer as to whether this opMode is active and the robot should continue onwards.
|
abstract void |
runOpMode()
Override this method and place your code here.
|
void |
sleep(long milliseconds)
Sleeps for the given amount of milliseconds, or until the thread is interrupted.
|
void |
start()
From the non-linear OpMode; do not override
|
void |
stop()
From the non-linear OpMode; do not override
|
void |
waitForNextHardwareCycle()
Deprecated.
The need for user code to synchronize with the loop() thread has been
obviated by improvements in the modern motor and servo controller implementations.
Remaining uses of this API are likely unncessarily wasting cycles. If a simple non-zero
delay is required, the
sleep() method is a better choice.
If one simply wants to allow other threads to run, idle() is a good choice. |
void |
waitForStart()
Pauses the Linear Op Mode until start has been pressed or until the current thread
is interrupted.
|
void |
waitOneFullHardwareCycle()
Deprecated.
The need for user code to synchronize with the loop() thread has been
obviated by improvements in the modern motor and servo controller implementations.
Remaining uses of this API are likely unncessarily wasting cycles. If a simple non-zero
delay is required, the
sleep() method is a better choice.
If one simply wants to allow other threads to run, idle() is a good choice. |
getRuntime, internalPreInit, internalUpdateTelemetryNow, requestOpModeStop, resetStartTime, updateTelemetry
public abstract void runOpMode() throws java.lang.InterruptedException
Please do not swallow the InterruptedException, as it is used in cases where the op mode needs to be terminated early.
java.lang.InterruptedException
public void waitForStart()
@Deprecated public void waitOneFullHardwareCycle() throws java.lang.InterruptedException
sleep()
method is a better choice.
If one simply wants to allow other threads to run, idle()
is a good choice.Each cycle of the hardware your commands are sent out to the hardware; and the latest data is read back in.
This method has a strong guarantee to wait for at least one full hardware hardware cycle.
java.lang.InterruptedException
Thread.sleep(long)
,
idle()
,
waitForNextHardwareCycle()
@Deprecated public void waitForNextHardwareCycle() throws java.lang.InterruptedException
sleep()
method is a better choice.
If one simply wants to allow other threads to run, idle()
is a good choice.Each cycle of the hardware your commands are sent out to the hardware; and the latest data is read back in.
This method will wait for the current hardware cycle to finish, which is also the start of the next hardware cycle.
java.lang.InterruptedException
Thread.sleep(long)
,
idle()
,
waitOneFullHardwareCycle()
public final void idle()
One can use this method when you have nothing better to do in your code as you await state managed by other threads to change. Calling idle() is entirely optional: it just helps make the system a little more responsive and a little more efficient.
idle()
is conceptually related to waitOneFullHardwareCycle(), but makes no
guarantees as to completing any particular number of hardware cycles, if any.
opModeIsActive()
,
waitOneFullHardwareCycle()
public final void sleep(long milliseconds)
sleep()
method.milliseconds
- amount of time to sleep, in millisecondsThread.sleep(long)
public final boolean opModeIsActive()
Note that internally this method calls idle()
runOpMode()
method and return to its caller.runOpMode()
,
isStarted()
,
isStopRequested()
public final boolean isStarted()
opModeIsActive()
,
isStopRequested()
public final boolean isStopRequested()
opModeIsActive()
,
isStarted()
public final void init()
public final void init_loop()
public final void start()
public final void loop()
public final void stop()
protected void handleLoop()
public void internalPostInitLoop()
OpMode
internalPostInitLoop
in class OpMode
public void internalPostLoop()
OpMode
internalPostLoop
in class OpMode