FIRST Robotics Competition Documents

cancel
Showing results for 
Search instead for 
Did you mean: 

LabVIEW Tutorial 4: Developing a Robot Project

 

The FIRST Robotics Competition (FRC) projects are sets of VIs, organized in a LabVIEW project, that you can use as a template when building a robotics application. The FRC projects consist of two project template types. Use the FRC robot project templates to develop the program you want to deploy to and run on the roboRIO. Use the FRC Dashboard Project template to develop a program that allows you to view data on the host computer.

This tutorial describes how to create, modify, and deploy a robot project, also referred to as an FRC robot project, to the roboRIO. In this tutorial, you develop a program to perform arcade driving with a joystick and Talon motor controllers.

 

Creating an FRC Robot Project

 

Complete the following steps to create an FRC robot project.

 

  1. Click the FRC roboRIO Project link on the Projects tab in the Getting Started window to display the Create New FRC Robot Project dialog box, shown as follows.
  2.  
    pic1.png
     
  3. In the Project name text box, enter the name you want to use to identify the new FRC robot project.
  4. In the Project folder text box, enter the location on the host machine to which you want to save the project files and VIs.
  5. In the Team number text box, replace the xxyy with your team number. 
  6. Choose a robot project. Note that all projects include simulation.  Simulation allows you to learn how to program your robot using LabVIEW without having an actual robot.  You do not need a roboRIO controller to run simulation. Instead your code runs in the FRC Simulation Viewer, where you can drive your robot to test your code.  The same code can be built into an executable to run on your real robot. Refer to Tutorial 10 -- Robot Simulation for more information about using simulation. The four project options are:
    1. Arcade Drive: Modify the team VIs in this project described in the left hand side of the Robot Main.vi to code your robot. Arcade drive uses one joystick for teleop control.
    2. Command & Control: Modify the team VIs in this project described in the left hand side of the Robot Main.vi to code your robot. Command and control uses parallel controller loops to control individual mechanisms of the robot.
    3. Learn LabVIEW: Mecanum Maze Simulation: Control a simulated Mecanum robot through a maze.
    4. Learn LabVIEW: Ball Shooter Simulation: Simulate shooting balls from the robot’s basket through holes in the wall.
  7. Click the Finish button to close the Create New FRC Robot Project dialog box and create the new FRC robot project. 

LabVIEW displays the new FRC robot project in the Project Explorer window, shown as follows.

 

pic2.png

 

Notice that the FRC robot project contains two targets: My Computer and Target (roboRIO-1959-FRC.local). Files under My Computer are those you want to use and run on the host computer. Files under the roboRIO Target are those you want to deploy to and run on the roboRIO.

The roboRIO Target contains one top-level VI, the Robot Main VI, which is the master VI for the robot and is the top-level VI for the robotics program you run on the roboRIO. This target also contains a Team Code folder. This folder contains VIs that the Robot Main VI calls.

 

 

Note  The project that you create also contains default code to drive a robot in Teleop mode. The default code assumes the robot includes two motors and one joystick.

 

Refer to Tutorial 5—Editing Team Code VIs for more information about the subVIs the FRC Robot Project contains.

 

Deploying the FRC Robot Project to the roboRIO

 

After you develop the FRC robot project you want to run, you must deploy the program to the roboRIO. You can deploy the program in three ways: using the Run button; from the Project Explorer window; or as a stand-alone, built application.

 

 

Note  Regardless of how you deploy your robot program, you must also be running the FRC Driver Station in order for output (motors etc.) to work.  The FRC Driver Station can be launched from the Start menu or from the Desktop shortcut.

 

Deploying the Program Using the Run Button

 

When you deploy a program with the Run button, you maintain a connection between the host computer and the roboRIO. The program runs on the roboRIO, but you can manipulate the front panel objects of the program from the host computer. You therefore can deploy a program with the Run button to perform live front panel debugging.

Complete the following steps to run the FRC robot project and perform live front panel debugging.

  1. In the Project Explorer window, double-click the Robot Main.vi item to open the Robot Main VI. Tip: With Robot Main.vi open, it can be helpful to right-click on the lvproj file in the Project Explorer window and choose Save All (this Project). This can speed up the download time by ensuring that Robot Main.vi and all of its subVIs are saved prior to download.
  2. Click the Run button of the Robot Main VI to deploy the VI to the roboRIO. 

    LabVIEW deploys the Robot Main VI and any support files for the VI to the roboRIO. The Robot Main VI then runs on the roboRIO. If the robot has a joystick connected to port 1 of the driver station and Talon motor controllers controlling the two wheels, you can move the joysticks and observe how the robot responds.  Note that for any robot output to work you must be running the Driver Station in Teleop Enabled mode.
  3. Move the joystick and observe how the robot responds.
  4. Click the Finish button of the Robot Main VI. Notice that the VI stops.

If you click the Run button of the Robot Main VI and it runs slowly, close any subVIs of the Robot Main VI that are open on the host computer to improve performance. Do not close the Robot Main VI.

 

 

Note  If a program is running on the roboRIO and you redeploy that program with the Run button, the roboRIO stops and restarts the program you deployed. LabVIEW redeploys any VIs that changed or are no longer in memory on the roboRIO.

 

Deploying the Program from the Project Explorer Window

 

In the Project Explorer window, right-click the Robot Main VI and select Deploy from the shortcut menu to deploy the VI and any support files for the VI to the target. When you deploy a program from the Project Explorer window, the program runs only on the roboRIO to which it was deployed. Therefore, you cannot perform live front panel debugging.

 

Building and Deploying a Stand-Alone Application

 

To run a robot in competition, you must build the FRC robot project into a stand-alone application that you deploy to the roboRIO. You then can specify the application to run at startup so the application runs as soon as the roboRIO is powered on.

Complete the following steps to build the FRC robot project into a stand-alone application and run it on the roboRIO at startup.

  1. In the Project Explorer window, double-click the FRC Robot Boot-up Deployment build specification under the Build Specifications folder to display the FRC Robot Boot-up Deployment Properties dialog box.
  2. On the Information page, the Build specification name text box specifies a name for the build specification.
  3. The Target filename text box specifies a name for the application.
  4. The Local destination directory text box specifies where you want to save the stand-alone application on the host computer .
  5. The Target destination directory text box specifies where you want to save the stand-alone application on the roboRIO.
  6. Select Source Files from the Category
  7. Verify that the Robot Main VI is in the Startup VIs
  8. Click the OK button to close the FRC Robot Boot-up Deployment Properties dialog box.
  9. In the Project Explorer window, right-click the build specification and select Build from the shortcut menu to build the application.
  10. After the build finishes, right-click the build specification and select Run as startup from the shortcut menu to set the application as the startup application and deploy the application to the roboRIO. LabVIEW will restart on the RT target and your robot code will start running.
  11. The application will run each time you reboot the roboRIO.  When the roboRIO reboots, the STATUS light on it momentarily turns on and then off. If you do not see the status light turn on, you can reboot the roboRIO from the Diagnostics page of the driver station.
  12. Ensure the driver station is running and set to Teleop Enabled mode.
  13. Move the joystick and observe how the motors of the robot respond.
  14. If you no longer want the application to run on the roboRIO at startup, perform these two steps:
    1. Right-click the build specification and select Unset as startup from the shortcut menu.
    2. Right-click on Robot Main.vi and choose Deploy from the shortcut menu..

Connecting to the roboRIO

If you stop the VI or close the front panel, the VIs are no longer running on the roboRIO. However, if you only disconnect from the roboRIO, the front panel on the host computer appears to stop, but the VI continues running on the roboRIO. Right-click the Target (roboRIO-1959-FRC.local) item in the Project Explorer window and select Disconnect from the shortcut menu to disconnect from the roboRIO. If you then close the front panel and reconnect to the roboRIO, you re-access the front panels in memory on the device. The front panel of the running VI reappears and displays the current state of the VI. Right-click the Target (roboRIO-1959-FRC.local) item in the Project Explorer window and select Connect from the shortcut menu to connect to the roboRIO. You cannot access the front panels of VIs in memory on a roboRIO if a built application is running. You first must stop the running built application or cancel the Connect operation.

Claire M.
Technical Support
National Instruments
Certified LabVIEW Developer
Contributors