FIRST Robotics Competition Blog

Community Browser
cancel
Showing results for 
Search instead for 
Did you mean: 

Conditional Auto-Indexing Snippet

Whit-E_Wall-E
NI Employee (retired)

When writing code for autonomous operation, or even for portions of manual control, it's often necessary for the code to be able to react to an array of commands that will later be applied and interpreted for robot movement. However, it's also necessary to be able to filter that array of commands based on the scenario at hand. The ability to programmatically build arrays based on a condition/trigger is handled through the conditional auto-indexing tunnel. To enable the conditional terminal, right-click on the tunnel and select Tunnel Mode >> Conditional. In the example above, random data is being created, but only values over 0.5 are being placed into the array.This same technique could be applied to creating arrays of actions for the robot to take or filtering certain signals. This Boolean value can also be treated as a trigger, where we're only adding elements to the array when the trigger is high. The conditional auto-indexing tunnel can be used with both a for loop and a while loop, as shown above.

For more information on LabVIEW programming in general check out our free online resources here.

Conditional Auto-Indexing.png

Here is a white paper on how to use a snippet in your program.

Regards,

M. Whitaker
ni.com/support