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 or subsystems. Supported for use in both BunyipsOpModes and any other normal SDK OpMode. This paradigm is known as RobotHardware.

    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();

Alternatively as of v7.0.0, you can choose to use a singleton pattern where the RobotConfig will be initialised just before any OpMode starts, via a BunyipsLib hook. See AutoInit for more details.

Author

Lucas Bubner, 2024

Since

1.0.0-pre

Constructors

Link copied to clipboard
constructor()

Types

Link copied to clipboard
@Target(allowedTargets = [AnnotationTarget.CLASS])
annotation class AutoInit

Attaching this annotation to a RobotConfig derivative class will cause the init method to be executed automatically on the initialisation of any OpMode.

Link copied to clipboard
object Companion
Link copied to clipboard
@Target(allowedTargets = [AnnotationTarget.CLASS])
annotation class InhibitAutoInit

Inhibits the effect of AutoInit on an OpMode derivative. This is useful if you don't wish to initialise hardware automatically on this OpMode.

Properties

Link copied to clipboard
protected lateinit var hardwareMap: HardwareMap

OpMode supplied hardwareMap instance.

Functions

Link copied to clipboard
protected fun <T> 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

Uses the HardwareMap to fetch HardwareDevices and assign instances from onRuntime.

Link copied to clipboard
protected abstract fun onRuntime()

This method is executed when the init method is called on this RobotConfig instance. In this method, you have access to the hardwareMap, as well as utility methods such as getHardware to retrieve and configure hardware. Devices and subsystems that you would like to expose should be listed as public fields in your config.