FIRST Robotics Competition Discussions

cancel
Showing results for 
Search instead for 
Did you mean: 

Parallel Execution with Wait?

Hi,

I'm a mentor helping the students with their Lab View software.  We are encountering an issue where using wait pauses execution of the entire robot.

Our robot uses a piston to move the kick mecahnism.  We would like to be able to retract our kick mechanism while we are driving.  Our lab view code for retracting the kick mechanism is in a seperate VI and uses a 'wait' to wait for the piston to become fully retracted.  From the lab view documentation, we thought the wait would allow other parallel sub VIs to execute.

However, when we encounter the wait the entire program waits, so we can't drive or do anything else while the kick mechanism is retracting. The drive and other VIs do not have any inputs from the retract piston VI, so there shouldn't be any dependancies.

Is there a way to wait withought pausing execution of the entire robot?

Any help is much appreciated, thanks!

Mike

0 Kudos
Message 1 of 4
(3,949 Views)

You're partially correct about parallel sub-vis. A loop runs each sub-vi once per loop. Thus, if you have a very slow VI in the same loop as a very fast VI, the fast VI will only run as fast as the slow VI. However, if you have the fast VI and the slow VI in different loops, they would each run at their own rate.

Things in your telop.vi should always be fast to avoid messing up communication, as you've noticed.

The way we make this work is to implement slow things in state machines. Make each iteration fast, and move on to the next state when the desired time has elapsed (using the tick count vi).

0 Kudos
Message 2 of 4
(2,824 Views)

Worked perfectly. We moved the slow executing code to a state machine and it's working now. Thanks!

One thing that still has me perplexed is one of our other failed attempts. We tried running our slow retract piston code in a while loop at the top level of robot main. We then had a global variable to enable/disable the code in the top level retract piston code. Since this while loop is in parallel with the while loop containing teleop, I wouldn't expect the delay to affect teleop, but it did.

It's not holding us up anymore, just curious as I'm new to Lab View. Thanks for the help!

Mike

0 Kudos
Message 3 of 4
(2,824 Views)

Hi Mike,

Was the piston code outside of the Case Structure that contains the TeleOp VI but inside the main While Loop? If so, this might be why you still saw that pause.

If it was outside the main While loop, was there anything from the slow subVI that the top level piston code was waiting on before it finished running?

~Olivia

NI FIRST Support

0 Kudos
Message 4 of 4
(2,824 Views)