Skip to content

Creating your first Manual Mode

Rapidly develop and test new Tele-Operated programs for your robot with the Volt library.

What is a ManualMode?

A ManualMode allows you to control the robot with gamepads.

Creating a ManualMode

Create a new Kotlin class in the TeamCode/src/main/kotlin/org/firstinspires/ftc/teamcode/opmodes/manual package that inherits the ManualMode class.

The ManualMode class contains:

  1. A robot
  2. A list of actions
  3. A function called tick() that is called every tick

The ManualMode class also contains methods for:

  1. isButtonPressed(button: String): Returns true if the button is pressed
  2. isButtonTapped(button: String): Returns true if the button was released
  3. isButtonDoubleTapped(button: String): Returns true if the button was double tapped
  4. isButtonHeld(button: String, milliseconds: Double): Returns true if the button was held for the specified time
  5. getAnalogValue(name: String): Returns the value of an analog input
class ExampleManual : ManualMode() {
override val robot = SimpleRobotWithMecanumDrive(hardwareMap, Pose2d(
Vector2d(0.0, 0.0),
Math.toRadians(0.0) // Make sure to use radians!
))
init {
// Initialize
}
}

Add functionality

Create an interaction

An Interaction takes a condition and an action.

class ExampleManual : ManualMode() {
override val robot = SimpleRobotWithMecanumDrive(hardwareMap, Pose2d(
Vector2d(0.0, 0.0),
Math.toRadians(0.0)
))
private val doSomething = Interaction({ isButtonTapped("a1") }, { robot.turnTo(90.0) })
init {
interactions.add(doSomething)
}
}

Make it an OpMode

Add the @TeleOp annotation to the class definition.

@TeleOp(name = "Example", group = "Examples")
class ExampleManual : ManualMode() {
override val robot = SimpleRobotWithMecanumDrive(hardwareMap, Pose2d(
Vector2d(0.0, 0.0),
Math.toRadians(0.0)
))
private val doSomething = Interaction({ isButtonTapped("a1") }, { robot.turnTo(90.0) })
init {
interactions.add(doSomething)
}
}

Result

package org.firstinspires.ftc.teamcode.opmodes.manual
import com.qualcomm.robotcore.eventloop.opmode.TeleOp
import dev.kingssack.volt.autonomous.ManualMode
import dev.kingssack.volt.robot.SimpleRobotWithMecanumDrive
@TeleOp(name = "Example", group = "Examples")
class ExampleManual : ManualMode() {
override val robot = SimpleRobotWithMecanumDrive(hardwareMap, Pose2d(
Vector2d(0.0, 0.0),
Math.toRadians(0.0)
))
private val doSomething = Interaction({ isButtonTapped("a1") }, { robot.turnTo(90.0) })
init {
interactions.add(doSomething)
}
}