FRC LabVIEW Tutorials - Auto Selecting

Adding options to the defualt autonomous

The default dashboard uses a variable that is set in the Begin VI to decide what options to display, so we’ll start by adding options to the default there.

The auto list on the dashboard is set in

If you deploy this code and open connect the dashboard, you can click the drop down to see the updated options list.

It is also possible to type the desired option - but when doing this (with the default dashboard) you have to click out of the box to apply the value

Adding options to auto code

Right click on the case structure in Autonomous

Right click the case structure

You see all of the cases that are currently there. You also have the option to delete the case that is shown when you right click.

Delete all cases you don’t plan to use (keep anything you are planning to copy and paste later)

Add a case for every value that you would like to select (I encourage you to keep the blank, default case) and edit the code.
You can change the label by double clicking and editing between the quote marks.

Editing case values by double clicking header and changing string

While this does allow for as many options as you desire, you have to type out the names for them multiple times (in auto and either in the Begin so they show in the list, or when you use them).

Creating an Enum

We first change the Dashboard Read to reading a number

Change dashboard read to number

We then create an enum (from the numerics palette) and make it a Type Def

Make an enum and create a Tpe Def from it

Once opened, we can edit the items and add all the options we desire.

Once that is finished, we Apply Changes (under File) and Save it (save it somewhere easily accessible - like the desktop)

Back in Autonomous, use a Type Cast vi (use quick search - hit ctrl + space - or find it under the Numeric -> Data Manipulation pallette) to convert the number that is read to the enum

Make an enum and create a Tpe Def from it

You can right click and select “Add case for every value” to populate the entire list

Right click and select add case for every value

Customizing dashboard

To use this value (or rather - have it sent . . .), we need to create a custom dashboard (more details on setting this up under our gyro tutorial).

We replace the default combo box with our enum by selecting “choose a control” and navigating to where we saved it.

Replace the combobox with our enum

This will break the dashboard because the are several vi’s on the block diagram expecting a string, so we will go update those now.

First, we replace the Write String with a NT Write Number

Replace the write string with Write Number

We also remove the code that updated the options (since we now know these from the enum)

Remove the code to update the options

And change the “Select Auto”; Value Change case to writing a number (this is the case that sends the update whenever you change it)

Update the set value to set a number

Now all you need to do to add or remove (or rename) auto modes is open the type def and change it’s items, then rebuild both the dashboard and the robot project.

Some things to consider for improvement

  1. Build the dashboard and copy it over the default one so (in Program Files) so when Driver station opens it will use your updated version (otherwise you need to have your updated version running first)

  2. Extending the array of movements (provided in the default auto) to include manipulator movements

  3. Use encoders and/or a gyro for more accurate movements (than time will consistently produce).

If this tutorial inadvertently leaves some details out, please tell us about it and we will update it.

Google Form to request details


Table of Contents