OpModes - addonovan/ftc-ext GitHub Wiki
Setting up an OpMode
A major difference between the standard way and this library is that the ftcext OpModes are completely separate from Qualcomm's. What does this mean? Well, for starters, this means that instead of extending com.qualcomm.robotcore.eventloop.opmode.OpMode
or com.qualcomm.robotcore.eventloop.opmode.LinearOpMode
, you must extend either com.addonovan.ftcext.control.OpMode
or com.addonovan.ftcext.control.LinearOpMode
. These classes perform the exact same way that their Qualcomm counterparts do, in that OpMode is loop and update-based, while LinearOpMode runs sequentially.
Another caveat is the Register
annotation that must be on an OpMode. In order for the OpModeRegistrar
to find your OpModes, it must have @Register( name )
annotation on the class. name
is a String
that serves as the name that the OpMode is registered as, this is what shows up on the Driver Station device during OpMode selection. This can be almost any string; however, there are a few exceptions:
name
is "Stop Robot" - This name is dedicated to a specific OpMode on the Robot Controller that cannot be modified, and so the Robot Controller app will pitch a fit if you try to use it, so don'tname
is "" (an empty string) - The Robot Controller app will also pitch a fit if you try to use this, so don'tname
contains "=" - I thought equals signs were stupid. Literally no other reason.
And finally, the class must be instantiable, meaning:
- It's not
abstract
- It is
public
(Kotlin: no visibility modifier is necessary,public
is the default)
Note: Since these are phones we're dealing with, emojis are acceptable and do work, feel free to look up the unicode character chains for whatever emoji your heart desires and use the "\uXXXX" escape sequence to insert them into a string.
This is a working OpMode that would automatically get registered by ftcext (granted, it doesn't do anything):
Java
import com.addonovan.ftcext.control.OpMode;
import com.addonovan.ftcext.control.Register;
@Register( "Testing!" )
public class TestingOpMode extends OpMode
{
@Override
public void loop() {}
@Override
public void init() {}
}
Kotlin
import com.addonovan.ftcext.control.OpMode
import com.addonovan.ftcext.control.Regsiter
@Register( "Testing!" )
class TestingOpMode : OpMode()
{
override fun loop() {}
override fun init() {}
}