1s Delay Affecting Driver Controls (FTC)

We are experiencing a long delay (1 sec) in responding to our driver station controls. We have been reading a lot of posts about managing parallel loops to keep periodic actions (e.g. shooting) from interferring with high response actions like driving, and we have tried to implement that with a separate, parallel iteration linked using a global variable.

Even so, something is interferring with our responsiveness. If feels like all control actions are delayed by 1 sec. If we command rapid movements, they all happen in rapid succession … but don’t start until about 1 second after we command the operations.

Would having too much going on in our main driving iteration cause this?

We also have a lot of constants and motor / servo references inside our iteration. Would it help to pull all of those static references outside the loop?

I have included a .zip with our main loop, with the motor configurator files.

We had a lot better responsiveness with our FRC program and are wondering what we are missing with this FTC program.

Thanks!

Team 2408 LabView Code.zip (61.1 KB)


Team 2408 LabView Code.zip (61.1 KB)

Not many of us have the correct LabVIEW version to view your FTC files and comment on them.

I didn’t want you to think we were ignoring you…

No problem! Here is a doc with some screen shots. This is kind of ugly because in our latest attempt, we pulled all of the references out of the loop. We also nest case statements about 5 levels deep. Is that a source for excessive delay (it doesn’t seem like it should be)?

2408 program screenshots.doc (263 KB)


2408 program screenshots.doc (263 KB)

You should add a timer to each of your two parallel While loops to prevent one or the other from hogging the CPU. One loop could be starving the other loop. Add a 50ms Wait to the outer part of each While loop and that will periodically release the CPU to process other tasks.

Other than the obvious “Fire? = false” case causing a half second delay in that parallel loop, I don’t see anything unusually slow in your code. Because it’s parallel it shouldn’t slow down the first loop.

The nested Cases aren’t a problem unless something time consuming happens in one of the hidden ones. Can’t see where the first Tick Count goes off to, but I don’t imagine you’re doing anything unusual with that either.

loopdelay.jpg


loopdelay.jpg

Hmmm. I thought the timer would add more delay (i.e. wait) … but now that you mention releasing the cpu, I think you may be on to something. We will give that a try. Thanks!

The timer will run in parallel with the other tasks inside the While loop, so you don’t lose the full 50ms.
At most you’ll lose 50ms.

If that helps then you can experiment with shortening the time to 20ms or so. It really just needs to release long enough to allow the other loop to get a chance to run, so the time just has to be a little greater than how long the other code within the loop takes to execute.