Skip to content

Creating your first Manual Mode

A ManualMode is a VoltOpMode that allows you to perform actions using gamepads.

First, create a new class that inherits ManualMode.

ManualMode takes a type parameter for your Robot class. It uses that type for the abstract robot property.

ManualMode also has an optional parameter for ManualParams, which allows you to configure things like default dead zones.

Override the robot property with an instance of your Robot class. You can use properties defined in VoltOpMode like hardwareMap to create your Robot instance.

import dev.kingssack.volt.opmode.manual.ManualMode
class ExampleTeleOp : ManualMode<MyRobot>() {
override val robot = MyRobot(hardwareMap)
}

By default ManualModess support seven Events:

  • Tap(button: Button)
  • Release(button: Button)
  • Hold(button: Button, durationMs: Double)
  • DoubleTap(button: Button)
  • Change(analogInput: AnalogInput)
  • Threshold(analogInput: AnalogInput, min: Float)
  • Combo(buttons: Set<Button>)

Let’s make releasing the “A” button on gamepad one score, releasing the “A” button on gamepad two open the claw, and releasing the “B” button on gamepad two close the claw.

import dev.kingssack.volt.opmode.manual.ManualMode
import dev.kingssack.volt.util.Event.ManualEvent.*
import dev.kingssack.volt.util.Button
class ExampleTeleOp : ManualMode<MyRobot>() {
override val robot = MyRobot(hardwareMap)
init {
Release(Button.A1) then { +robot.score() }
Release(Button.A2) then { +robot.claw.open() }
Release(Button.B2) then { +robot.claw.close() }
}
}

Add the @VoltOpModeMeta annotation to the class definition. Without this annotation, the OpMode will not be registered and will not appear on the Driver Station.

import dev.kingssack.volt.opmode.VoltOpModeMeta
import dev.kingssack.volt.opmode.manual.ManualMode
import dev.kingssack.volt.util.Event.ManualEvent.*
import dev.kingssack.volt.util.Button
@VoltOpModeMeta("Example TeleOp", "Examples")
class ExampleTeleOp : ManualMode<MyRobot>() {
override val robot = MyRobot(hardwareMap)
init {
Release(Button.A1) then { +robot.score() }
Release(Button.A2) then { +robot.claw.open() }
Release(Button.B2) then { +robot.claw.close() }
}
}
package org.firstinspires.ftc.teamcode.opmodes.manual
import dev.kingssack.volt.opmode.VoltOpModeMeta
import dev.kingssack.volt.opmode.manual.ManualMode
import dev.kingssack.volt.util.Event.ManualEvent.*
import dev.kingssack.volt.util.Button
@TeleOp("Example TeleOp", "Examples")
class ExampleTeleOp : ManualMode<MyRobot>() {
override val robot = MyRobot(hardwareMap)
init {
Release(Button.A1) then { +robot.score() }
Release(Button.A2) then { +robot.claw.open() }
Release(Button.B2) then { +robot.claw.close() }
}
}