Generating Java Code for a project

After you start getting a significant part of your robot designed in RobotBuilder you can generate a Java project for use with Eclipse. The code that is generated includes project files that will let you just open the project and start adding your robot specific code. In addition, if you later make changes in RobotBuilder, you can regenerate the project again and it will not overwrite your changes. This process is described in detail below.

Prerequisite

A number of settings get configured when you create a project using the Eclipse plugins. If you have not yet created a project from within Eclipse, you should do so before proceeding (you can delete the project after). Instructions for doing this can be found in the Creating your Benchtop Test Program article.

Setting up the project properties for export

Here is the procedure for setting up the project for Java code generation (export).

  1. Select the project name in the top of the robot description to see the project properties.
  2. Set the project name to something meaningful for your teams robot.
  3. Set the directory where the project should be saved. This might be inside your Eclipse Workspace directory or some other folder.

Generate the project files

Generate the project files

Once the location of the exported project files is defined (previous step) either click on Java from the Export menu or use the "Java" item in the toolbar to generate code to the correct location. This will generate a full project the first time the button is pressed, or it will update the project with changes on subsequent exports.

Import the project into Eclipse

Import the project into Eclipse

Right-click in the Project Explorer and import your project from the location set in RobotBuilder. Ideally the project has been saved in your workspace.

Project Type

Project Type

Select Existing Projects into Workspace then click Next.

Select directory

Select directory

Click Browse.. locate the project directory created inside the workspace directory specified above, the click OK on the browse dialog and then Finish on the import window

Viewing the imported project

Viewing the imported project

You can view the project in the project explorer by double-clicking on the project name in the project explorer. Expand the src folder to view the source code. From there you can see all the project files. Your subsystems are in the Subsystems package and the commands are in the Commands package.

0 Report Errors

Use this form to report any errors with the documentation. For help with WPILib, please use the FIRST Forums at http://forums.usfirst.org For reporting WPILib bugs, please submit an issue on GitHub at https://github.com/wpilibsuite/allwpilib/issues/new

Ignore