AutonomousBunyipsOpMode

BunyipsOpMode variant for Autonomous operation. Uses the Task system for a queued action OpMode.

Author

Lucas Bubner, 2023

Lachlan Paul, 2023

Since

1.0.0-pre

See also

Constructors

Link copied to clipboard
constructor()

Types

Link copied to clipboard
Priority representation for building tasks.

Inherited properties

Link copied to clipboard
Link copied to clipboard

BunyipsLib Gamepad 1: Driver

Link copied to clipboard

BunyipsLib Gamepad 2: Operator

Link copied to clipboard
open var hardwareMap: HardwareMap
Link copied to clipboard
open val isStarted: Boolean
Link copied to clipboard

Set how fast the OpMode is able to loop in the activeLoop or onInitLoop methods in Loops per Time Unit. This will dynamically adjust to be the target speed of how fast loops should be executed. Measures of less than or equal to zero will be ignored, and the OpMode will run as fast as possible.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open var t: DualTelemetry

Shorthand field alias for the telemetry (DualTelemetry) field. Sometimes, this field is required to be used as the Kotlin compiler might have trouble distinguishing between the overridden field and the base field. This method is a direct alias to the DualTelemetry field.

Link copied to clipboard

BunyipsLib Driver Station & FtcDashboard Telemetry

Link copied to clipboard
open var time: Double
Link copied to clipboard

The moving average timer for the OpMode, which is used to calculate time between hardware cycles. This is useful for debugging, performance monitoring, and calculating various time-based values (deltaTime, loopCount, elapsedTime, etc.)

Functions

Link copied to clipboard
protected fun activeLoop()
Code to run continuously after the START button is pressed on the Driver Station.
Link copied to clipboard
fun <T : Task?> add(@NonNull newTask: T): T
Call to add Task instances that will be executed sequentially during the active loop.
fun <T : Task?> add(@NonNull runQueuePriority: AutonomousBunyipsOpMode.TaskPriority, @NonNull newTask: T): T
Add a task to the run queue at a specified run queue priority.
Link copied to clipboard
fun <T : Task?> addAtIndex(index: Int, @NonNull newTask: T): T
Insert a task at a specific index in the queue.
fun addAtIndex(index: Int, @NonNull runnable: Runnable): RunTask
fun addAtIndex(index: Int, @NonNull name: String, @NonNull runnable: Runnable): RunTask
Insert an implicit RunTask at a specific index in the queue.
Link copied to clipboard
fun <T : Task?> addFirst(@NonNull newTask: T): T
Add a task to the very start of the queue.
Link copied to clipboard
fun <T : Task?> addLast(@NonNull newTask: T): T
Add a task to the run queue, but after onReady has processed tasks.
Link copied to clipboard
fun <T : Task?> defer(@NonNull newDynamicTask: Supplier<T>): T
Call to add Task instances that will be executed sequentially during the active loop.
fun <T : Task?> defer(@NonNull runQueuePriority: AutonomousBunyipsOpMode.TaskPriority, @NonNull newDynamicTask: Supplier<T>): T
Add a task to the run queue at a specified run queue priority.
Link copied to clipboard
fun <T : Task?> deferAtIndex(index: Int, @NonNull newDynamicTask: Supplier<T>): T
Insert a task at a specific index in the queue.
Link copied to clipboard
fun <T : Task?> deferFirst(@NonNull newDynamicTask: Supplier<T>): T
Add a task to the very start of the queue.
Link copied to clipboard
fun <T : Task?> deferLast(@NonNull newDynamicTask: Supplier<T>): T
Add a task to the run queue, but after onReady has processed tasks.
Link copied to clipboard
Call to disable the automatic stopping of the hardware when the OpMode finishes after no tasks are left.
Link copied to clipboard
protected fun onInit()
Runs upon the pressing of the INIT button on the Driver Station.
Link copied to clipboard
protected abstract fun onInitialise()
Runs upon the pressing of the INIT button on the Driver Station.
Link copied to clipboard
protected fun onInitLoop(): Boolean
Use an init task if you wish to run looping code during the initialisation phase of the OpMode.
Link copied to clipboard
protected abstract fun onReady(@Nullable selectedOpMode: Reference<out Any>, @NonNull selectedButton: Controls)
Called when the OpMode is ready to process tasks.
Link copied to clipboard
protected open fun onStart()
Perform one time operations after start is pressed.
Link copied to clipboard
protected open fun periodic()
Override to this method to add extra code to the activeLoop, which will be run before the task queue is processed.
Link copied to clipboard
fun remove(@NonNull task: Task)
Remove a task from the queue.
Link copied to clipboard
fun removeAtIndex(taskIndex: Int)
Removes whatever task is at the given queue position.
Link copied to clipboard
Removes the first task in the task queue.
Link copied to clipboard
Removes the last task in the task queue.
Link copied to clipboard
fun run(@NonNull runnable: Runnable): RunTask
fun run(@NonNull name: String, @NonNull runnable: Runnable): RunTask
Implicitly constructs a new RunTask to add to the run queue.
Link copied to clipboard
protected fun setOpModes(@Nullable selectableOpModes: Array<Any>)
protected fun setOpModes(@Nullable selectableOpModes: List<Any>)
Call to define your OpModeSelections, if you list any, then the user will be prompted to select an OpMode before the OpMode begins.
Link copied to clipboard
fun use(@NonNull subsystems: Array<BunyipsSubsystem>)
Call to manually add the subsystems that should be managed by AutonomousBunyipsOpMode.
Link copied to clipboard
fun wait(duration: Double, @NonNull unit: Time): WaitTask
Implicitly constructs a new WaitTask to add to the run queue.

Inherited functions

Link copied to clipboard
fun detachActiveLoopRunnables(attachedRunnables: Array<Runnable>)

Removes a Runnable that was added to the active loop via onActiveLoop. Calling this method will no-op on runnables that can't be found on the currently attached runnables, and will stop executing runnables on the active loop that could be found.

Link copied to clipboard

Dangerous method: call to IMMEDIATELY terminate the OpMode. No further code will run, and this should only be used in emergencies.

Link copied to clipboard
fun exit()

Dangerous method: call to shut down the OpMode as soon as possible. This will run any BunyipsOpMode cleanup code, much as if the user pressed the STOP button.

Link copied to clipboard
fun finish(safeHaltHardwareOnStop: Boolean)

Call to manually finish the OpMode.

Link copied to clipboard

BunyipsLib Gamepad 1: Driver

Link copied to clipboard

BunyipsLib Gamepad 2: Operator

Link copied to clipboard

Get the currently respected init-task that will run during dynamic_init.

Link copied to clipboard

The instance of the current BunyipsOpMode. This is set automatically by the BunyipsOpMode lifecycle. This can be used instead of dependency injection to access the current OpMode, as it is a singleton.

Link copied to clipboard
fun getRobotControllers(): List<LynxModule>

A list of all LynxModules (Control + Expansion Hub) modules on the robot.

Link copied to clipboard
open fun getRuntime(): Double
Link copied to clipboard

Shorthand field alias for the telemetry (DualTelemetry) field. Sometimes, this field is required to be used as the Kotlin compiler might have trouble distinguishing between the overridden field and the base field. This method is a direct alias to the DualTelemetry field.

Link copied to clipboard

BunyipsLib Driver Station & FtcDashboard Telemetry

Link copied to clipboard

The moving average timer for the OpMode, which is used to calculate time between hardware cycles. This is useful for debugging, performance monitoring, and calculating various time-based values (deltaTime, loopCount, elapsedTime, etc.)

Link copied to clipboard
fun halt()

Call to temporarily halt all activeLoop-related updates from running. Note this will pause the entire activeLoop, but continue to update timers and telemetry. These events must be handled manually if needed, which include any conditional calls to resume.

Link copied to clipboard
fun idle()
Link copied to clipboard
fun ifRunning(opModeConsumer: Consumer<BunyipsOpMode>)

Run the supplied callback if a BunyipsOpMode is currently running. This chains an internal call to BunyipsOpMode with a lambda supplied with the non-null instance of BunyipsOpMode.

Link copied to clipboard
fun init()
Link copied to clipboard
fun init_loop()
Link copied to clipboard
Link copied to clipboard
open fun internalPostLoop()
Link copied to clipboard
open fun internalPreInit()
Link copied to clipboard
fun internalUpdateTelemetryNow(telemetry: TelemetryMessage)
Link copied to clipboard

Whether a BunyipsOpMode is currently running. This is useful for checking if the OpMode singleton can be accessed without raising an exception due to the field being null.

Link copied to clipboard
Link copied to clipboard
fun loop()
Link copied to clipboard
fun onActiveLoop(runnables: Array<Runnable>)

Add a Runnable to the list of runnables to be executed just before the activeLoop. This is useful for running code that needs to be executed on the main thread, but is not a subsystem or task.

Link copied to clipboard
protected open fun onFinish()

Perform one time clean-up operations after the activeLoop finishes all intentions gracefully.

Link copied to clipboard
protected open fun onInitDone()

Allow code to execute once after all initialisation has finished.

Link copied to clipboard
protected open fun onStop()

Perform one time clean-up operations as the OpMode is stopping.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open fun resetRuntime()
Link copied to clipboard
fun resume()

Call to resume the activeLoop after a halt call.

Link copied to clipboard
protected abstract fun runBunyipsOpMode()
Main BunyipsOpMode executor method.
protected fun runBunyipsOpMode()

This method is the entry point for the BunyipsLib framework, and is called by the FTC SDK.

Link copied to clipboard
open fun runOpMode()
Main OpMode thread method.
abstract fun runOpMode()
Link copied to clipboard

Dangerous method: Call to command all motors and servos on the robot to shut down. This is a method called by the SDK continuously when no OpMode is running. It is also automatically called via finish.

Link copied to clipboard
fun setGamepad1(<set-?>: Controller)

BunyipsLib Gamepad 1: Driver

Link copied to clipboard
fun setGamepad2(<set-?>: Controller)

BunyipsLib Gamepad 2: Operator

Link copied to clipboard

Set a task that will run as an init-task. This will run after your onInit has completed, allowing you to initialise hardware first. This is an optional method, and runs alongside onInitLoop.

Link copied to clipboard
fun setT(<set-?>: DualTelemetry)

Shorthand field alias for the telemetry (DualTelemetry) field. Sometimes, this field is required to be used as the Kotlin compiler might have trouble distinguishing between the overridden field and the base field. This method is a direct alias to the DualTelemetry field.

Link copied to clipboard

BunyipsLib Driver Station & FtcDashboard Telemetry

Link copied to clipboard

The moving average timer for the OpMode, which is used to calculate time between hardware cycles. This is useful for debugging, performance monitoring, and calculating various time-based values (deltaTime, loopCount, elapsedTime, etc.)

Link copied to clipboard
fun sleep(milliseconds: Long)
Link copied to clipboard
fun start()
Link copied to clipboard
fun stop()
Link copied to clipboard

Call to command all moving motors/CRServos to stop by method of setting their powers to zero. This does not impact normal servos.

Link copied to clipboard
Link copied to clipboard
open fun updateTelemetry(telemetry: Telemetry)
Link copied to clipboard
open fun waitForStart()