Building and downloading a robot project to the roboRIO
There are two ways of running programs onto the roboRIO. You can
- Attach to the roboRIO and run the program using the debugger from your development system OR
- Load it onto the roboRIO flash drive so it will run on reboot.
For tournaments you should always download the program so that it will be there when the robot is restarted and the match is played. This article will cover loading the program onto the roboRIO to run on reboot. The next article will cover the debugger.
Building a robot program
The first step to getting the program on the roboRIO is to build the code. This will compile and link the project files. If you have set the option to build automatically as recommended in the Eclipse installation article, this step is done each time you save a file in the project. If not, this step will be done when you start the deploy process.
Loading a program to run on robot startup
To have the program run automatically each time the roboRIO boots, it must be loaded in the roboRIO flash memory. For tournaments you should always download the program so that it will be there when the robot is restarted and the match is played. To do this:
- Right click on the project in the Project Explorer
- Select "Run As"
- Select "WPILib Java Deploy"
The deployment process will then begin and start outputting status information to the Console (generally located in the bottom center or bottom right of the window). After the program is downloaded it will be immediately launched, there is no need to reboot the roboRIO.
Program Download Process
After you click the WPILib Java Deploy button the deploy process will proceed through a number of steps.
The deploy process runs a "clean" each time it is run. This is needed to work around a bug in Ant that causes changes to static final constants to not always be picked up by the build.
Compile & Jar
Next the code is compiled and packed up into a jar file.
Get Target IP
In this step, the plugin determines the IP of the roboRIO. The plugin will try to reach the roboRIO via the following methods, in order:
- mDNS (roboRIO-TEAM-FRC.local where TEAM is your team number)
- DNS (roboRIO-TEAM-FRC.lan where TEAM is your team number)
- USB static IP (172.22.11.2)
- Ethernet static IP (10.TE.AM.2)
If the roboRIO is accessible via any of these methods, the deploy will proceed using that address as the target. If the roboRIO cannot be found using any of these methods, the deploy will abort. See Connection Failure in the Troubleshooting section below.
The dependencies section checks that the roboRIO contains any dependencies necessary for operation. For Java at this time, this consists of two components:
- Check of the roboRIO image version. If the validation succeeds you will get a message that the version was validated and the deploy will proceed. If the check fails, you will see a message indicating the allowed image version for this version of the plugins, see Image Check Failure under Troubleshooting below for more details.
- Check that the JRE is installed on the roboRIO. If not, it is deployed automatically by the plugins.
Copy and Start code
The remaining parts of the deploy then proceed as follows:
- Copy user program and robotCommand file. The robotCommand file tells the framework that launches the code what to launch (C++ vs. Java and Debug vs deploy).
- Start code. The plugin calls a script file which kills the existing user program, then restarts the LabVIEW RT process. This starts the code in the same way it will be launched when the roboRIO is booted.
There is no need to reboot the roboRIO to run the new code, it will begin running automatically. After the deploy completes, each time the roboRIO is rebooted it will run the deployed code until new code (from any FRC language) is downloaded.
Viewing program output
The console output from the program does not appear in the regular Eclipse console. To view the console output (System.out statements as well as WPILib output) see the next article, Using Riolog to view console output.
This section contains troubleshooting steps for commonly encountered issues.
Javac invalid target or Javac not found
A "Compile failed" error as shown above indicates a failure building the code. The lines that start with "javac" will indicate the source of the error (a missing semicolon on line 37 of Robot.java in the example above).
If the deploy process fails to connect to the roboRIO:
- First verify that the roboRIO is powered on, connected to the PC and that the roboRIO is imaged and that your team number is set properly in Eclipse (Window->Preferences->WPILib Preferences).
- The next step is to verify that your computer networking is configured in a way it can communicate with the roboRIO. Visit the roboRIO Network Troubleshooting document in the Troubleshooting section for more details.
- Check that your firewall is disabled or that an exception has been added for Eclipse. For the Windows Firewall, see Configuring Windows Firewall in the Troubleshooting section for more details.
Image Check Failure
If the Image Check fails that means that the Image version on your roboRIO did not match the image version that the plugins were built against. To check for updates to the Eclipse plugins, make sure you installed the plugins from the web repository and that you have an active internet connection, then click Help->Check For Updates. To check for updates to the NI FRC Update Suite, which may contain a new roboRIO image, visit the URL from the Installing the FRC Update Suite (All Languages) document. If an updated version is available, after installing it as described in that document, re-image your roboRIO using the instructions in the Imaging your roboRIO document.