-
Notifications
You must be signed in to change notification settings - Fork 0
Quick Start
Let's get familiar with Botful by writing a simple robot program! The program will run a motor at full power while it is in teleop mode.
First, we need to start out program by calling the Robot.start
function, like this:
suspend fun main() = Robot.start {}
The first thing to note here is that Robot.start
is a suspend function. That essentially means that the function could take a while to complete. In this case, the function runs for the entire duration of our robot program.
The next thing that you may notice is that Robot.start
takes a lambda as a parameter. The lambda extends the Robot.Config
type, and should contain your entire robot program.
Well, now we have a robot program, but... it doesn't do anything. Let's change that!
Earlier, we mentioned the Robot.Config
type. Well, this type happens to have a ton of useful methods that you can use to subscribe to your robot's lifecycle events!
Let's start by adding the onTeleop
function to our Robot.start
function. The onTeleop
function takes a lambda which will run whenever your robot enters teleop mode. For now, let's print a message to the user.
suspend fun main() = Robot.start {
onTeleop {
println("I'm in teleop mode!")
}
}
Seems simple enough, right? Now our robot will print the message "I'm in teleop mode!"
whenever it enters teleop mode. Next, lets add a motor to actually move the robot!
There are several types of motors available in Botful, but for this tutorial let's use a Talon
motor controller. To create a Talon
, use the `Ta