WestlakeLEARN
FRC · LabVIEW

First Robotics Competition

FRC · LabVIEW

  • Autonomous State Flow

Autonomous State Flow

Make autonomous steps explicit and easy to test.

Module 3: Autonomous FlowAutonomous

In this lesson, you will:

  1. 01Represent autonomous as numbered states.
  2. 02Use timers to leave each state.
  3. 03Stop motors when the final state is reached.

State machines keep auto readable

A simple FRC autonomous can be a case structure driven by a state number. Each case performs one action and decides when to advance.

Timers are easier than guessing loop counts

A timer makes the code independent of how fast the loop happens to run. That matters when testing on different laptops or roboRIO loads.

Shift registers carry state between iterations

The loop has to remember which state it is in from one iteration to the next. A shift register stores the state number, the case structure acts on it, and the active case writes the next state back. Store the state start time too, and reset it only when the state changes — resetting a timer on every loop iteration means it never expires.

LabVIEW habit

Publish both the current state and elapsed time so you can see why a transition did or did not happen.

Easy mistake

Reset the state timer only when entering a new state. Resetting it every loop prevents the timeout from ever expiring.

LabVIEW diagram viewer

Block diagram walkthrough

Hover a VI. Press Ctrl-H for help.

Press enter or space to select a node. You can then use the arrow keys to move the node around. Press delete to remove it and escape to cancel.
Press enter or space to select an edge. You can then press delete to remove it or escape to cancel.
Block diagram walkthrough

Practice

Create three states: drive forward, stop and wait, then finish. Carry both the current state and state-start time through shift registers, and reset the start time only when advancing to a new state.

Checks

  • The current state is visible on the front panel or dashboard.
  • The state timer resets once on entry, not once per loop iteration.
  • Every non-final state has a time-based exit.
  • The final state sends zero motor output.

Lesson check

Check your understanding before moving on.

Why use an elapsed timer instead of counting loop iterations?

What selects which case runs in the autonomous case structure?

0 of 2 answered

References

WPILib LabVIEW DocsCurrent official FRC LabVIEW programming documentation.FRC LabVIEW ResourcesCurrent WPILib tutorials, examples, and troubleshooting resources.

Finished reading?

Mark this lesson complete — “Motor Safety and Recovery” is up next.

Teleop VI BasicsMotor Safety and Recovery