Programming
Last updated
Was this helpful?
Last updated
Was this helpful?
To create a new program click on the + sign which you should find near the top left of your screen.
Name your file. From the Sample code select BlankLinearOpMode
and make sure to check the TeleOp
Option.
After you hit OK
Your code will look something like this:
At the bottom right of your screen click on the wrench.
Now open your DS app on your group’s phone and select the right-side dropdown menu. Now choose the program you just built.
Click “Init. You should now see a message on the bottom of the screen that says: “Status: Initialized”.Now click “Play”. You should now see the message on the bottom of the screen that says “Status: Running”.
Congratulations you just wrote your first program!
You robot doesn’t do much yet.. Just send a message to the phone to tell you it’s status. Go ahead and hit the stop button to stop your program.
Before we start programming our drive motors, let’s take a minute to look at the structure of a opMode.
This Is a comment. A comment is the code between the /*
and */
symbols. It is just there to help the person writing the code understand what it does. When the robot runs this program it will skip over this section.
Here is where we import other code that the robot needs to run. The robot should add these automatically so you do not need to worry about editing this section
This line of code tells the robot where you have to go to run your program. You have three options for this line. @Autonimous, @TeleOp, and @Disabled. The main difference between Autonomous and TeleOp is that Autonimous had a 30s timer. Disabled will hide your program from the menu and is helpful if you have a lot of programs.
Shown below is where you can find your programs.
These line are needed to run your program. Your class name MUST match your file name.
Your program must extend eighter LinearOpMode
or OpMode
. OpMode is a bit more complicated so for right now just use LinearOpMode.
telemetry is a way the robot tells you what it is thinking. When you use the code
telemetry.addData("Statius", "Initialized");
The robot will save the information you gave it until you call
telemetry.update();
which then sends it to the driver.
This is a while loop it will repeat anything in side the curly braces until the program ends.