The Setup
We’re running 2 Limelight 2.0s, one for aiming and one for intake, and reading their outputs in periodic tasks. We then use the basic rotate code from the LabView example here and send the output to Teleop through a global variable. Currently only aiming is being sent.
The Issue
When the output from the rotate code is put into the rotate input in the mecanum cartesian drive block, all 4 outputs, x and y offset from both limelights start lagging about 20 seconds or so in periodic tasks. But only when put into the drive block. If the global variable output is put into an indicator there is no lag. I have also tried moving the drive code into periodic tasks as well with the same results. When the output, which is no longer sent through the global variable, is not put into the drive block there is no lag. But when the output is sent into the drive block the lag returns. The lag is independent of having the second limelight hooked up physically or coded, but when I swap from using the shooter limelight to the intake limelight I get the same issues.
If anyone can offer any help it would be greatly appreciated. Our code setup is extremely similar to last year and there was no issue then, so we are confused as to what changed or what’s causing the issue.
When you are doing things in periodic tasks it is best to use separate loops for separate things. You have 1 while loop doing: limelight stuff, dio stuff, shooter, etc. Lets give each one of these a separate loop so that we can start trying to identify where your problems are.
Secondly when you have a loop in periodic tasks it need some delay so it doesn’t consume all or nearly all of your resources. Maybe I missed it but I didn’t see a delay in that loop.
I also generally recommend (if not using command) to do all of the sets in periodic tasks so that you can use that code for both auto and teleop.
We had the same problem. Went into limelight and set stream rate to low. You will find that option in the setting menu on the tab below the general options.