Creating your first Manual Mode
A ManualMode is a VoltOpMode that allows you to perform actions using gamepads.
1. Create Your ManualMode Class
Section titled “1. Create Your ManualMode Class”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)}import dev.kingssack.volt.opmode.manual.ManualMode;
public class ExampleTeleOp extends ManualMode<MyRobot> { @NotNull MyRobot robot = new MyRobot(getHardwareMap());
@Override protected @NotNull MyRobot getRobot() { return robot; }
public ExampleTeleOp() { super(new ManualParams()); }}2. Define Events
Section titled “2. Define Events”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.ManualModeimport 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() } }}import dev.kingssack.volt.opmode.manual.ManualMode;import dev.kingssack.volt.util.Event.ManualEvent.*;import dev.kingssack.volt.util.Button;import kotlin.Unit;
public class ExampleTeleOp extends ManualMode<MyRobot> { @NotNull MyRobot robot = new MyRobot(getHardwareMap());
@Override protected @NotNull MyRobot getRobot() { return robot; }
public ExampleTeleOp() { super(new ManualParams());
then(new Release(Button.A1), builder -> { builder.unaryPlus(robot.score()); return Unit.INSTANCE; }); then(new Release(Button.A2), builder -> { builder.unaryPlus(robot.getClaw().open()); return Unit.INSTANCE; }); then(new Release(Button.B2), builder -> { builder.unaryPlus(robot.getClaw().close()); return Unit.INSTANCE; }); }}3. Add Metadata
Section titled “3. Add Metadata”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.VoltOpModeMetaimport dev.kingssack.volt.opmode.manual.ManualModeimport 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() } }}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;import kotlin.Unit;
@VoltOpModeMeta("Example TeleOp", "Examples")public class ExampleTeleOp extends ManualMode<MyRobot> { @NotNull MyRobot robot = new MyRobot(getHardwareMap());
@Override protected @NotNull MyRobot getRobot() { return robot; }
public ExampleTeleOp() { super(new ManualParams());
then(new Release(Button.A1), builder -> { builder.unaryPlus(robot.score()); return Unit.INSTANCE; }); then(new Release(Button.A2), builder -> { builder.unaryPlus(robot.getClaw().open()); return Unit.INSTANCE; }); then(new Release(Button.B2), builder -> { builder.unaryPlus(robot.getClaw().close()); return Unit.INSTANCE; }); }}Result
Section titled “Result”package org.firstinspires.ftc.teamcode.opmodes.manual
import dev.kingssack.volt.opmode.VoltOpModeMetaimport dev.kingssack.volt.opmode.manual.ManualModeimport 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() } }}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;import kotlin.Unit;
@VoltOpModeMeta("Example TeleOp", "Examples")public class ExampleTeleOp extends ManualMode<MyRobot> { @NotNull MyRobot robot = new MyRobot(getHardwareMap());
@Override protected @NotNull MyRobot getRobot() { return robot; }
public ExampleTeleOp() { super(new ManualParams());
then(new Release(Button.A1), builder -> { builder.unaryPlus(robot.score()); return Unit.INSTANCE; }); then(new Release(Button.A2), builder -> { builder.unaryPlus(robot.getClaw().open()); return Unit.INSTANCE; }); then(new Release(Button.B2), builder -> { builder.unaryPlus(robot.getClaw().close()); return Unit.INSTANCE; }); }}