RobotConfig

abstract class RobotConfig

Abstract class to use as parent to the class you will define to mirror a "saved configuration" on the Robot Controller, and to define any robot related constants. Supported for use in both BunyipsOpModes and any other normal SDK OpMode.

    private final YourConfig config = new YourConfig();

In your OpMode's init method, call the init method of your config class, passing in the OpMode.

    config.init(this);

Author

Lucas Bubner, 2024

Since

1.0.0-pre

Constructors

Link copied to clipboard
constructor()

Properties

Link copied to clipboard
protected lateinit var hardwareMap: HardwareMap

OpMode supplied hardwareMap instance.

Functions

Link copied to clipboard
protected fun <T : HardwareDevice> getHardware(name: String, device: Class<T>, onSuccess: Consumer<T> = Consumer { }): T?

Convenience method for reading the device from the hardwareMap without having to check for exceptions. This method can be passed a Runnable to run if the device is successfully configured, useful for setting up directions or other configurations that will only run if the device was successfully found.

Link copied to clipboard

Implicit OpMode config initialisation for use in BunyipsOpModes. This will not work in normal SDK OpModes.

fun init(opMode: OpMode): RobotConfig

Uses the HardwareMap to fetch HardwareDevices and assign instances from onRuntime. Should be called as the first line in your init cycle. This method can only be executed once.

Link copied to clipboard
protected abstract fun onRuntime()

Here you will assign class instance variables to public HardwareDevices, and assign any runtime-related settings and variables for use. This is called from the init method.