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:
- A robot
- A list of actions
- A function called
tick()
that is called every tick
The ManualMode class also contains methods for:
isButtonPressed(button: String)
: Returns true if the button is pressedisButtonTapped(button: String)
: Returns true if the button was releasedisButtonDoubleTapped(button: String)
: Returns true if the button was double tappedisButtonHeld(button: String, milliseconds: Double)
: Returns true if the button was held for the specified timegetAnalogValue(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 }}
(Coming Soon)
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) }}
(Coming Soon)
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) }}
(Coming Soon)
Result
package org.firstinspires.ftc.teamcode.opmodes.manual
import com.qualcomm.robotcore.eventloop.opmode.TeleOpimport dev.kingssack.volt.autonomous.ManualModeimport 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) }}
(Coming Soon)