Creating your Benchtop Test Program
The simplest way to create a robot program, is to start from one of the three supplied templates (Sample, Iterative or Command). Sample is best used for very small sample programs or advanced programs that require total control over program flow. Iterative Robot is a template which provides better structure for robot programs while maintaining a minimal learning curve. Command-Based robot is a template that provides a modular, extensible structure with a moderate learning curve.
The templates will get you the basis of a robot program, organizing a larger project can often be a complex task. RobotBuilder is recommended for creating and organizing your robot programs. You can learn more about RobotBuilder here. To create a command-based robot program that takes advantage of all the newer tools look at Creating a Robot Project in the Command Based Programming Chapter.
Creating a project
To create a project click "File" then "New" then click "Project...".
Selecting the project type (Robot Java Project)
Choose "Example Robot Java Project" as the project type.
Selecting the Example
If necessary, click the arrow to expand the Getting Started with Java section, then click to select the Getting Started example. Then click Next.
Entering the team number
Enter your team number, then click Next. This is used when the Eclipse tools download programs onto your RoboRIO. As described in the dialog this is a global setting that can also be accessed from Window->Preferences->WPILib Preferences (if you need to change what team number you are targeting).
This dialog will only be shown if there is no team number currently set in Eclipse global settings.
The project is created in the Projects window in Eclipse
The project is created in the current workspace with the package name:
where your team number is substituted for 191 in this example. The project name is name of the sample robot project that was selected.
Notice that the project is now created (MyRobotProject) with a "src" folder that contains a Robot.java file that subclasses the appropriate base class for your template choice (note that the Command Based project will look a little different). You can double-click on the source file "Robot.java" to see the default code.
Defining the variables for our sample robot
The sample robot in our examples will have a joystick on USB port 1 for arcade drive and two motors on PWM ports 0 and 1. Here we create objects of type RobotDrive (myRobot), Joystick (stick), and Timer (timer).
Simple autonomous sample
Easy arcade drive for teleoperation
Test Mode is used for testing robot functionality. The test mode of our sample program runs LiveWindow. LiveWindow is a part of the SmartDashboard that allows you to see inputs and control outputs on the robot from the dashboard when the robot is in Test Mode. You can read more about LiveWindow in the SmartDashboard section of the Driver Station Manual.