LinearOpMode vs OpMode¶
There are two OpMode classes within the FTC® SDK: OpMode and LinearOpMode. The one you use affects how you write the program. For examples of how to use OpMode and LinearOpMode, refer to the example OpModes in the SDK .
LinearOpMode Methods¶
runOpMode(): Code inside this method will run exactly once after you press the INIT button. This is where you should put all code for the OpMode.waitForStart(): This method pauses the Op-Mode until you press the START button on the driver station.isStarted(): returnstrueif the START button has been pressed, otherwise it returnsfalse.isStopRequested(): returnstrueif the STOP button has been pressed, otherwise it returnsfalse.idle(): callsThread.yield, allowing other threads at the same priority level to run.opModeIsActive(): returnsisStarted() && !isStopRequested()and callsidle().opModeInInit(): returns!isStarted() && !isStopRequested()and does not callidle().
OpMode Methods¶
init(): Code inside this method will run exactly once after you press the INIT button on the driver station.init_loop(): Once the code ininit()has been run, code inside this method will run continuously until the START button is pressed on the driver station.start(): Code inside this method will run exactly once after you press the START button on the driver station.loop(): Once the code instart()has been run, code inside this method will run continuously until the STOP button is pressed on the driver station.stop(): Code inside this method will run exactly once after you press the STOP button on the driver station.
Note
As of SDK version 8.1, when executing OpModes there is a negligible delay of one millisecond between calls of loop(). Previously, it had unpredictable delays, however since 8.1 it is similarly performant to LinearOpMode.
Conclusion¶
Overall, the use of LinearOpMode or OpMode is up to preference. Game Manual 0 uses LinearOpMode everywhere for consistency.