|
Re: Various Labview Questions
In general, local variables are not desirable in your code. They were added to LV in LV3.0 or 3.1 in order to make UI programming easier, and they are useful for other initialization and communication situations, but in a parallel environment, they don't provide any form of sequencing or notification, and are therefore a bit dangerous compared to a wire.
Loops that run in teleop are not a problem provided they terminate quickly. The teleop callback is supposed to complete in ~20ms so that the framework can call the appropriate callback again -- often the teleop with the latest joystick info. When you have a sequencing operation that will take longer than 20ms, you have two choices -- build a state machine inside of teleop, or make a parallel Timed task that controls the sequencing operation.
State machine:
This involves remembering state data in a feedback node or local/global variable so that the sequencing operation can be monitored and advanced when appropriate. The operation is essentially sliced up so that it can advance in small 20ms slices. This approach is fine if everyone understands the concepts. It is a common approach in a single-threaded system.
Parallel task:
This involves making a parallel loop (thread if not using LV) that monitors and advanced the sequencing operation. It does this outside of teleop, so that teleop can return quickly and keep other mechanisms going. Teleop can communicate set points and monitor the state of the operation through global variables, notifiers, queues, or RT FIFOs. This approach keeps the code decoupled, making it easier to modify and develop independent of the rest of the robot. Be sure that something throttles the loop so that it runs only when needed and not one million times per second.
Either approach will work, though I'd encourage you to try the second, as it keeps the code separated and can be developed in an independent project with a simple panel as a test harness.
Please ask more detailed questions if any of this didn't make sense.
Greg McKaskle
|