Go to Post We're still not ready for 2012.... - AdamHeard [more]
Home
Go Back   Chief Delphi > Technical > Programming > Java
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 10-16-2013, 09:22 PM
adlasa's Avatar
adlasa adlasa is offline
President and Lead Programmer
AKA: Sasha
FRC #1458 (Red Ties)
Team Role: Leadership
 
Join Date: Dec 2012
Rookie Year: 2011
Location: Bay Area
Posts: 35
adlasa has a spectacular aura aboutadlasa has a spectacular aura aboutadlasa has a spectacular aura about
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.
__________________
Computers run on smoke. When the smoke escapes the computers stop working.
Reply With Quote
  #2   Spotlight this post!  
Unread 10-16-2013, 09:46 PM
z_beeblebrox's Avatar
z_beeblebrox z_beeblebrox is offline
Custom User Title
AKA: Cal
FRC #4183 (Bit Buckets)
Team Role: Alumni
 
Join Date: Jan 2012
Rookie Year: 2012
Location: Cambridge MA
Posts: 811
z_beeblebrox has a reputation beyond reputez_beeblebrox has a reputation beyond reputez_beeblebrox has a reputation beyond reputez_beeblebrox has a reputation beyond reputez_beeblebrox has a reputation beyond reputez_beeblebrox has a reputation beyond reputez_beeblebrox has a reputation beyond reputez_beeblebrox has a reputation beyond reputez_beeblebrox has a reputation beyond reputez_beeblebrox has a reputation beyond reputez_beeblebrox has a reputation beyond repute
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.
__________________
2012 Utah Regional Rookie All-Star
2013 Phoenix Regional Judge's Award for "design process and prototyping"
2014 Hub City Regional Quality Award, Arizona Regional Excellence in Engineering Award
2015 Arizona East Regional Creativity Award, Winner
2016 Arizona North Regional Finalist, Arizona West Excellence in Engineering Award, Finalist
Reply With Quote
  #3   Spotlight this post!  
Unread 10-16-2013, 10:39 PM
adlasa's Avatar
adlasa adlasa is offline
President and Lead Programmer
AKA: Sasha
FRC #1458 (Red Ties)
Team Role: Leadership
 
Join Date: Dec 2012
Rookie Year: 2011
Location: Bay Area
Posts: 35
adlasa has a spectacular aura aboutadlasa has a spectacular aura aboutadlasa has a spectacular aura about
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.
__________________
Computers run on smoke. When the smoke escapes the computers stop working.
Reply With Quote
  #4   Spotlight this post!  
Unread 10-16-2013, 10:55 PM
Joe Ross's Avatar Unsung FIRST Hero
Joe Ross Joe Ross is offline
Registered User
FRC #0330 (Beachbots)
Team Role: Engineer
 
Join Date: Jun 2001
Rookie Year: 1997
Location: Los Angeles, CA
Posts: 8,547
Joe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond repute
Re: Why is there .01 second delay in teleop on the tutorials?

Quote:
Originally Posted by adlasa View Post
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.
The CPU also has to process incoming communication data. You will see increased latency if there isn't free CPU time.

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.
Reply With Quote
  #5   Spotlight this post!  
Unread 10-17-2013, 12:23 AM
adlasa's Avatar
adlasa adlasa is offline
President and Lead Programmer
AKA: Sasha
FRC #1458 (Red Ties)
Team Role: Leadership
 
Join Date: Dec 2012
Rookie Year: 2011
Location: Bay Area
Posts: 35
adlasa has a spectacular aura aboutadlasa has a spectacular aura aboutadlasa has a spectacular aura about
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!
__________________
Computers run on smoke. When the smoke escapes the computers stop working.
Reply With Quote
  #6   Spotlight this post!  
Unread 10-17-2013, 01:30 PM
ekapalka's Avatar
ekapalka ekapalka is offline
Registered User
FRC #3216
 
Join Date: Dec 2012
Location: Bermuda
Posts: 277
ekapalka has a spectacular aura aboutekapalka has a spectacular aura about
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?
Reply With Quote
  #7   Spotlight this post!  
Unread 10-17-2013, 01:44 PM
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 7,999
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: Why is there .01 second delay in teleop on the tutorials?

Quote:
Originally Posted by ekapalka View Post
...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?
It depends on how you implement the thread. If you create a thread which runs continuously in an infinite loop within the thread, then you need to slow down the frequency of that loop by yielding the processor for a period of time every pass through the loop.

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 : 10-17-2013 at 01:47 PM.
Reply With Quote
  #8   Spotlight this post!  
Unread 10-17-2013, 02:14 PM
Joe Ross's Avatar Unsung FIRST Hero
Joe Ross Joe Ross is offline
Registered User
FRC #0330 (Beachbots)
Team Role: Engineer
 
Join Date: Jun 2001
Rookie Year: 1997
Location: Los Angeles, CA
Posts: 8,547
Joe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond repute
Re: Why is there .01 second delay in teleop on the tutorials?

Quote:
Originally Posted by ekapalka View Post
...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?
If you are event based, then your idle loop should have a wait in it.
Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 09:04 AM.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi