Switching from Autonomous to Tele-op

I’d recommend opening devices in Begin.vi and nowhere else.
I think that’s your basic issue here.

What you posted has some problems, but the full answer is in all your code, not just this one piece. I’m just speculating because I’d need to see the rest of your code to positively tell you what 's wrong.

What is happening is that you are opening your drive motors in this vi, then going into an infinite loop. This vi (and only this Autonomous Independent.vi) gets killed automatically at the end of the Autonomous period. That means the Motor closes never happen by the way and they maintain the last value given them in the Autonomous loop.

I bet you try to open the motors again somewhere else (like in Begin.vi maybe?) and that leaves the motor reference in Teleop.vi invalid. You can’t Open the same motor more than once.

So Autonomous leaves your motors running forever, and Teleop can’t reference those same motors, as it normally should, to stop them.

Thanks! That did the trick! And man the code is so much neater and easier to read now :slight_smile:

Just one thing, it runs straight through once on practice mode, but autonomous doesn’t run if you try a second time without rebooting the cRIO. I was wondering if this was possible a safety feature that it will only run autonomous once in one boot.

If not, do you have any idea why it would do that?

Ethan

Are you getting errors on the second run? It may be that you are closing references in tele or somewhere so that auto will get errors when it tries to use the refnums again. First, look at the Diagnostics tab on the DS when running the second auto, and you may need to look at VIs that contain Close, to see where this is happening.

Greg McKaskle

Unfortunately I just left the shop, so I can’t test it out, but from what I remember I believe we were getting some watchdog errors. Also errors dealing with not powering the motors with enough, but that was only during tele-op because we are using the axis 3 slider on the joystick to be a multiplier of speed of the motors.

Here is the code we have in tele-op and autonomous

Thanks,
Ethan







The Closes in teleop are killers.

Yea, all the Closes you have in both those vi’s should be removed.
Put all your Closes in Finish.vi instead.

The While loop in Autonomous Independent.vi is necessary and that’s fine.
However, you don’t need the While loop in Teleop.vi. Teleop operates differently.

Ok, I’ll recode it use the final.vi. Do you just use the same referencing methods?

Also how would you code it without the while loop?

Ethan

Yes, the Closes are handled with a Refnum Get straight to a Close.
There are some already in Finish.vi to guide you.

The fundamental difference between Autonomous Independent.vi and Teleop.vi is that Auto gets called only once, so you want to stay in there until you’ve done all you want to, while Tekeop gets called ~50 times a second, so you’ll be back again and again.

In teleop if you leave everything, but just remove the While loop it’ll be fine.

Ok

I’m a little confused, when I code the closes, do I need to make references to them in the autonomous mode or tele-op mode, or do I just use the get reference and then close, and never use set reference in the tele-op or autonomous vi’s

Ethan

Opens go in Begin.vi
Closes go in Finish.vi
Sets go in Autonomous Independent.vi and Teleop.vi

I’m working from a Mac without LabVIEW, so I can’t give you a graphical example right now.
It takes a while to shutdown all the computers in the house and the PCs have already been put to bed.

The Auto that you posted is fine, just remove the Closes to keep it clean.

The Teleop you posted is also fine, just remove the Closes and the While loop (but not the contents).
The Get Refnums feed directly into the Sets in Teleop.
Think of the whole Teleop.vi as one giant While loop.

So I need to put a set reference in tele-op to the final.vi closes?
Ethan

I’m not clear on what you mean by that.

Like this
Ethan







Finish.vi looks good.

No, you do not need those Sets in Auto.
The Sets are only done once in Begin.vi.

Begin Opens and names the thing that’s been opened.
Everywhere else just uses the name.

So do I ever reference the closes in final.vi?

So should like this?
Ethan







There isn’t anything else you do in Finish.vi.

Think of Finish.vi as only running at the very end when you shut your robot down.
It doesn’t run at the end of Autonomous or at the end of Teleop if you’re running a practice match over and over for instance.

Ok. So that Tele-op code looks fine?

Just saw your attachments.

That is what I meant.

One problem remains with your compressor code.
The compressor is a funny operation.

The compressor should be Opened AND started/enabled in Begin.vi.
No code for the compressor goes in Auto or teleop.
Then the compressor gets Closed in Finish.vi (just like you have it now).

P.S.
You can get rid of the 1 ms timer in Teleop.vi. It does hurt and it doesn’t help.

Okay, where does the stop compressor block go then?

You can add that to Finish.vi between the Get refnum and the close