FRC LabVIEW Tutorials - TypeDef

You are actually already using these whether you realize it or not - you’ll be able to recognize them in some of the standard code once we are through.

A Type Def is a custom control that has all the instances linked so that one can change the original and immediately have the changes reflected throughout the project. (NI Documentation here)

For this example, we will be creating and modifying a Type Def for a state machine


Just a formality, but we will open several devices in



Due to the constructs of this data structure, it can be implemented in Periodic Tasks or in Teleop, because our state machine tutorial already shows a similar one in Periodic, we will implement this one in Teleop.

To start, create a enum control on the front panel, and right click on it. From the menu, select “Make Type Def.”

create the Type Def.

Right click again and select “Open Type Def”

Open the typedef

Once the Type Def is open, we can set the items of the enum. For this example the Up, Down, and Initialize, have been entered.

The initial configuration of a couple of modes

Back in, we will use a feedback node to keep track of the current state.

initial setup conditions

Here we realize that a mistake was made - we want to have a state for getting the user input.

If we right click on the constant that was made from our original control, we can reopen the typedef.

Re-opening the typedef

And we just add the get user input case to the values,

Adding another option

We also need to tell LabVIEW to apply the changes

Applying the change

Back in teleop, notice that both instances of the Type Def have updated.

it updated inside Teleo too.

And we finish out (most of this is implemented in our State Machines tutorial, so for details on that, click here)

finishing up

This tutorial is meant to be suggestive of how one might use a Type Def in the FIRST Robotics Competition. It will likely need to be modified to fit your specific application.

While this is a short example, the power of the Type Def grows exponentially. This last year our team had to add a case to a state machine that already had eleven (or so) cases, in the past, that would have meant deleting all the next case constants, modifying the case structure to take the new one, . . . Fortunately we had implemented a Type Def for our possible modes, and adding that case became as simple as the above example.

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