Go to Post It's never been about the robots. But the robots make an interesting misdirection that we all use. So its ALL about the robots. :rolleyes: - Foster [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 14-09-2015, 18:53
Hsifeulbhsifder Hsifeulbhsifder is offline
Programmer
AKA: Zaeem Mohamed
FRC #5428 (Breaking Bots)
Team Role: Programmer
 
Join Date: Jan 2015
Rookie Year: 2015
Location: Markham, ON, Canada
Posts: 41
Hsifeulbhsifder is on a distinguished road
Regarding Loop frequency

Why is it that the loop in the Iterative Robot base runs at 50Hz? What would hypothetically happen if a different frequency was used? Just an educational question, purely theoretical.
  #2   Spotlight this post!  
Unread 14-09-2015, 19:51
kylestach1678's Avatar
kylestach1678 kylestach1678 is offline
Registered User
AKA: Kyle Stachowicz
FRC #1678 (Citrus Circuits)
Team Role: Programmer
 
Join Date: Dec 2014
Rookie Year: 2015
Location: Davis, CA
Posts: 21
kylestach1678 is a glorious beacon of lightkylestach1678 is a glorious beacon of lightkylestach1678 is a glorious beacon of lightkylestach1678 is a glorious beacon of lightkylestach1678 is a glorious beacon of light
Re: Regarding Loop frequency

Don't quote me on this, but I believe that it runs at 50hz because that is how often the driver station sends packets to the robot.

If you are using Java or C++, it is entirely possible to create a separate thread that updates at a higher rate, and many teams do so - this is beneficial because a higher update rate gives quicker responses, which is especially important in control loops. Another reason to do this is for more accurate estimations. If you are trying to approximate the integral of a sensor value, say, integrating angular velocity from a gyro to keep track of the robot's angle, you are going to be using a Riemann sum. Logic dictates that the smaller the value of dt (the higher the sampling rate) the more accurate the results.
__________________

  #3   Spotlight this post!  
Unread 14-09-2015, 20:39
Hsifeulbhsifder Hsifeulbhsifder is offline
Programmer
AKA: Zaeem Mohamed
FRC #5428 (Breaking Bots)
Team Role: Programmer
 
Join Date: Jan 2015
Rookie Year: 2015
Location: Markham, ON, Canada
Posts: 41
Hsifeulbhsifder is on a distinguished road
Re: Regarding Loop frequency

Thank you,
Although, what would occur if you set the main loop's frequency to something high like 200, would that affect control of the robot in anyway?
  #4   Spotlight this post!  
Unread 14-09-2015, 21:01
GeeTwo's Avatar
GeeTwo GeeTwo is offline
Technical Director
AKA: Gus Michel II
FRC #3946 (Tiger Robotics)
Team Role: Mentor
 
Join Date: Jan 2014
Rookie Year: 2013
Location: Slidell, LA
Posts: 3,614
GeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond repute
Re: Regarding Loop frequency

Quote:
Originally Posted by Hsifeulbhsifder View Post
Thank you,
Although, what would occur if you set the main loop's frequency to something high like 200, would that affect control of the robot in anyway?
The main issue would be that you could do less each iteration. With a 50Hz rep rate, you get 200ms to do what you have to do. With a 200ms rate, you only get 50ms. It's also entirely possible that the 50Hz rate is controlled by a hardware timer; I'm not familiar with the internals.

And I concur with Alexander and Jared below that 50 Hz would not be noticeable lag from the controls, though higher rates would be in order for many PIDs and other sensor-driven activities.
__________________

If you can't find time to do it right, how are you going to find time to do it over?
If you don't pass it on, it never happened.
Robots are great, but inspiration is the reason we're here.
Friends don't let friends use master links.

Last edited by GeeTwo : 14-09-2015 at 22:30. Reason: oops - slipped a decimal point, added last paragraph.
  #5   Spotlight this post!  
Unread 14-09-2015, 21:06
AlexanderTheOK AlexanderTheOK is offline
Guy
no team
 
Join Date: Jan 2014
Rookie Year: 2012
Location: Los Angeles
Posts: 146
AlexanderTheOK is just really niceAlexanderTheOK is just really niceAlexanderTheOK is just really niceAlexanderTheOK is just really nice
Re: Regarding Loop frequency

Yup. All the important stuff like PID loops in our code were all run separately at 200hz. You don't really need to be getting info from the driver station more often anyways. I can't imagine drivers would notice the increase in "framerate."
  #6   Spotlight this post!  
Unread 14-09-2015, 21:55
Jared Russell's Avatar
Jared Russell Jared Russell is offline
Taking a year (mostly) off
FRC #0254 (The Cheesy Poofs), FRC #0341 (Miss Daisy)
Team Role: Engineer
 
Join Date: Nov 2002
Rookie Year: 2001
Location: San Francisco, CA
Posts: 3,078
Jared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond repute
Re: Regarding Loop frequency

Quote:
Originally Posted by GeeTwo View Post
With a 50Hz rep rate, you get 200ms to do what you have to do. With a 200ms rate, you only get 50ms.
20ms and 5ms, respectively.

The roughly 50Hz loop in *Periodic() is called every time you receive a driver station packet. This is great for mapping gamepad inputs to speed controllers and solenoids, but not great for doing timing-sensitive things like PID control.
  #7   Spotlight this post!  
Unread 15-09-2015, 15:06
Greg McKaskle Greg McKaskle is offline
Registered User
FRC #2468 (Team NI & Appreciate)
 
Join Date: Apr 2008
Rookie Year: 2008
Location: Austin, TX
Posts: 4,751
Greg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond repute
Re: Regarding Loop frequency

It is also worth considering having slower loops. The rate of a given loop should be appropriate for what the loop is measuring and what it is controlling. 50Hz was selected because the human with the joystick and buttons is giving input, and that is a reasonable speed for updating the robot from those inputs. Some control or state machine loops would benefit from running faster, others will work fine if run slower than 50Hz.

You also need to account for the amount of time that a loop takes to execute. Even though a camera can produce an image every 33ms, that doesn't mean that you can process the image in that amount of time or need to process every frame. So it may be useful to run an image processing loop at 10Hz -- be sure to process the most current image and not an old one.

If you want the equivalent of a thread in LV, simply make a parallel loop as shown in Periodic Tasks, or consider making it a Timed Loop if you want less jitter.

Greg McKaskle
Closed Thread


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 03:00.

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