Issue with Limelight 2+ in autonomous

I’m sure the issue is between chair and keyboard, but I’m having an issue in autonomous and getting the LL2+ to do what I want (LOL).

Sorry, can’t post code at the moment, but we’re using the LL2+ to get target tx and ty to home in on target. In teleop, the code works great - it’s a button-press (and a huge leap for our team, so thanks to LL team for the great product!) :slight_smile:

I know, not ideal to ask for help with programming and not post the code, but for an idea of how I approached it: I’m using a timed frame sequence for everything and everything, except for data to/from the LL2+ in the code works (backing up, spinning up shooter, feeding power cells, etc).

We are using networktables to send commands to LL2+ to invoke vision processor mode, then read tx and ty to feed PID controls to steer the robot. From the driver station I can tell the camera never switches to vision from driver camera, however once it goes to teleop, the button-press targeting works just fine.

I could be that I accidentally have a NT read instead of NT write somewhere, so I guess I’m just asking for pointers to help me troubleshoot when I get a chance. I though that it might be an issue with using Networktables in autonomous and perhaps that I need to turn them into global variables instead, but I’m just spitballing. Any pointers would be greatly appreciated.

Thanks in advance :slight_smile:

By placing the targetting code in periodic tasks, you can use that exact same code in both teleop and auto. That’s how we handle it.

1 Like

I’ll see if I can do it that way. Right now, I’m reading /limelight/tx and /ty and using those, along with the reading gyro as inputs to the PID loops, while using calibrated crosshairs (setpoints 0 for both PID loops) feeding arcade drive in teleop on button press.

So if I understand it correctly, just take everything: NT read gyro, limelight tx and ty, the PID loops, and assign the outputs of the PID to a global variable like “LLX” and “LLY” and use those for the inputs to arcade drive in both teleop and autonomous, and just ensure the LL2+ starts off in vision processing mode. Does that sound like that should work?

Yup. That’s very similar to what we do.

Keep in mind that you’ll want to zero out any variables in disabled. That way when you transition from auto to teleop nothing will carry over.

1 Like

I’ll give it a go! Thanks for the assist!

If the “timed sequence” in auto is this:
I’m suspecting that you shouldn’t use it. If this is like the “timed loop” VI, it uses a different execution system and thread model that doesn’t play well with the rest of the robot code.
Suggest using something like this instead. (THIS IS ONLY FOR AUTONOMOUS!)

Within your robot program use Global Variables to communicate between different
sections of the code (auto, periodic tasks, teleop). Between computers use Network Tables.

1 Like

Yep, this is what i used. The global variables seemed to do the trick mostly. I just need to figure out how to clear the variables in I think.