LabVIEW Autonomous Cases

Can anybody give me an explanation of all the cases in the LabVIEW autonomous code. Thanks!:slight_smile:

I don’t have it home with me. If you post a picture, I’ll be happy to explain it.

Greg McKaskle

This is all from memory. I just took a look inside the autonomous VI today.

Description from left to right:

Starting out, you should see a DriverStation-GetDigital VI or something of the sort. This basically fetches and returns the status of all digital inputs hooked to the driver station (switches, most likely… possibly buttons). This is then compiled into a boolean array and converted into a numeric byte.

The example provides for two switches. Essentially you are counting in binary.

Switch 1 | Switch 2 | Byte Value
OFF | OFF | 0
OFF | ON | 1
ON | OFF | 2
ON | ON | 3

This numeric byte is then used as an index selector for the enumeration array (located just above, I believe). The resulting enumeration selects one of the following cases: LEFT, STRAIGHT, or RIGHT.

LEFT will follow the left branch of the “Y” formation in the line.
STRAIGHT continues forward (used for starting positions which do not have a “Y”)
RIGHT… self explanatory.

There are three Double-Precision arrays inside the subsequent loop. These have hard-wired inputs on the front panel.

One of these controls the speed of the motors, gradually decreasing as the elapsed time of the autonomous period grows. I think this was done to avoid overshooting.

I honestly cannot remember what the other two are for.

There is another boolean to binary array structure inside this loop which fetches and returns the state of each IR sensor. Again, it counts in binary, returning either a 0, 1, 2, 4, or 7 (If I recall correctly).

This number is then attached to a case structure inside the loop which has a shift-register attached. This basically keeps track of what the previous case was, compares it to the new one, and provides the appropriate action to take in each instance.

For example, if the previous case represented the robot being completely on the line, but the new one represents the robot veering to the left of it, the code provides appropriate motor inputs to correct this.

The conditions represented by each numerical case are listed in the VI as comments.

I believe that’s the jist of it. Again, this is purely from memory, so don’t crucify me if anything is missing or incorrect.

I think he was inquiring about all the nested case structures for the “autonomous enabled” case, so I’ll explain that as best I can.

Outside the main while loop is the autonomous independent vi. This vi can be programmed to have one big sequence structure with something like having the first be drive forward, then have a timer for 2 seconds, then raise the arm, etc. The wire it outputs is a reference to it… kind of like a file extension, or a URL.

Inside the main while loop, there’s the Get Robot Competition Mode.vi. That outputs the obvious "autonomous enabled, teleop enabled, blah blah blah, but it also outputs “Call Context”. This is either “Init”, “Execute”, or “Stop.” these go into the second layer of case structures (for most of the vis like teleop, the case structure is within the vi). When the robot mode output changes (you hit the “disable” or “enable” buttons on dashboard), it first goes to the “stop” case of the last one, and then the “init” case of the new one. For the autonomous case, it has the functions Start background vi and stop background vi in the init and stop cases, and nothing in execute, and each takes in the reference from the autonomous vi.

The start vi function, well, starts the autonomous independent vi. That means that the first loop in which the autonomous enable is called, it starts the independent vi, and that starts running. In the “execute” case, it just lets that vi run it’s course. And in the “stop” case, it stops the vi the same way as if you pressed that red abort button.

I hope that makes sense, and is what you wanted :slight_smile:

Thanks! That helps a lot!

Does anyone know how to stop the robot on autonomous mode for some seconds?