|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
||||
|
||||
|
Why is there .01 second delay in teleop on the tutorials?
I was looking at the FRC Java tutorials and noticed there was a 0.01 second delay at the end of the main teleop while loop. Why is that? I never put one in my code.
|
|
#2
|
|||||
|
|||||
|
Re: Why is there .01 second delay in teleop on the tutorials?
It's to reduce CPU usage by preventing the software from running more frequently than necessary.
|
|
#3
|
||||
|
||||
|
Re: Why is there .01 second delay in teleop on the tutorials?
That makes sense thank you. But, is there any point in reducing CPU usage, what is the advantage? It's not like you are freeing up the CPU to do other things.
|
|
#4
|
||||||
|
||||||
|
Re: Why is there .01 second delay in teleop on the tutorials?
Quote:
Speed controllers are updated at a maximum of 0.005 seconds. Driver station data is received at a maximum of 0.02 seconds. 0.01 is a happy compromise. If you are only reading data from the driver station, 0.02 is all you need. |
|
#5
|
||||
|
||||
|
Re: Why is there .01 second delay in teleop on the tutorials?
Thank you for the replies guys, everything makes a lot of sense now!
|
|
#6
|
||||
|
||||
|
Re: Why is there .01 second delay in teleop on the tutorials?
...so is it considered good practice to add it in? If your code is entirely event based (or using threads), would you really need it?
|
|
#7
|
||||
|
||||
|
Re: Why is there .01 second delay in teleop on the tutorials?
Quote:
If the thread is created, does its thing, and then exits, you don't need the yield in the thread. You just need to make sure that the parent process that is creating that thread limits the frequency at which it creates the thread. Last edited by Ether : 17-10-2013 at 13:47. |
|
#8
|
||||||
|
||||||
|
Re: Why is there .01 second delay in teleop on the tutorials?
If you are event based, then your idle loop should have a wait in it.
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|