Putting "TeleOp.vi" into "Autonomous.vi"

We placed a copy of our “TeleOp.vi” into our “Autonomous.vi” inside of a while loop, and it seems to be running exactly as expected, but I just want to make sure that there isn’t something horribly wrong going on behind the scenes. From my understanding of how LabView works, I think this should be perfectly fine, but I’d like to get a second opinion.

Just FYI, the reason we are doing this is because we are going to have our robot driven manually, with a ton of autonomous functions that aid in things like placing hatch panels.

That should be fine.

You can also just call Teleop.vi from Autonomous.vi in a 20ms loop.
There’s a benefit to having only one version of Teleop.vi. Any changes automatically work both places.

Thanks, we are calling TeleIop.vi inside Autonomous.vi, I misspoke when I said we copied it. The benefit of making one change that affects both TeleOp and Autonomous is the initial reason we wanted to organize our code this way. What would be the difference between running the loop with at 20ms, vs not specifying a loop speed?

Unconstrained loops in LabVIEW suck all the air out of the CPU.
The driver control changes only occur every 20ms, and the regular Teleop gets called on a 20ms loop.

1 Like

Are you planning to have the autonomous running other tasks while teleop is also running within the autonomous VI?

Possibly, but probably not. Our goal is to make our controls such that there is little to no difference between driving during Sandstorm, and driving during TeleOp (other than the fact that you can only see using an on board camera during Sandstorm). So putting anything inside our Autonomous.vi other than the TeleOp.vi would be pretty much unnecessary as we could just add it to our TeleOp.vi instead, and have it be added to both.

If that’s the case, I’d consider modifying Robot Main instead. Right-click on the Autonomous Independent reference you see on the Block Diagram. Choose “Browse for Path” and select your Teleop VI. That will make the autonomous case call the teleop VI instead of autonomous.

Either should work. The way I mention will prevent your autonomous VI from ever running. Anything added to it would be ignored by the robot (just a caveat to be aware of)

If that is all you do, TeleOp would run just once at the beginning of the sandstorm. Putting TeleOp in Autonomous should work fine.
@hamac2003 if you’re wanting to have small automodes controlled by TeleOp you may want to consider the Command and Control architecture although it is kind of late in the season for that probably. Maybe look at it during the off season.

Thanks, I figured as much about jeffb’s suggestion. As for command control (like you said, it’s o late in the season to change), what exactly is it? I’ve heard people refer to it when talking about Java and C++, and I always assumed that it wasn’t something that can be used with Labview.

I put auto tasks in the Periodic Tasks.vi

When you create a roboRIO project, you can select the Command Control template. Basically you do all the Set Drive, Set Motor, Set Solenoid etc. in Period Tasks but you send messages to Period Tasks from either TeleOp or Autonomous using “Notifiers”. Notifiers are like globals but better because if you don’t write to the notifier the recieving code of the notifier can just wait and not run or timeout if you want it to and run specific code.