Go to Post And that's why we all need to consider reserving a "No! Bad robot!" button for the robocoach. :yikes: - vhcook [more]
Home
Go Back   Chief Delphi > Technical > Programming > C/C++
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 29-04-2012, 20:07
xraymypanda's Avatar
xraymypanda xraymypanda is offline
Cowboy programmer
AKA: Chris M
FRC #0599 (RoboDox)
Team Role: Programmer
 
Join Date: Dec 2011
Rookie Year: 2011
Location: Granada Hills,CA
Posts: 82
xraymypanda has a spectacular aura aboutxraymypanda has a spectacular aura about
Robodox Guide to velocity control using PID

Hello,
Many many many teams utilized a shooter wheel design this year and could have benefitted greatly from a guide on how to utilize the WPILibrary PIDController function for velocity control. That is exactly the purpose of this guide, however late in the season it is, it can still help teams in the future and those of use ( like myself) who just couldn't go without getting it done anyways. Happy to answer any questions or address any concerns.
Enjoy.
Attached Files
File Type: pdf Implementing PID for Velocity Control.pdf (295.1 KB, 294 views)
__________________

2011: Head Scout
2012: (figure)Head Programmer
2013: Head Programmer, Chief Strategist, Outreach Executive, and Driver
Reply With Quote
  #2   Spotlight this post!  
Unread 30-04-2012, 00:23
Tanaythan's Avatar
Tanaythan Tanaythan is offline
Programmer
AKA: Tanay Nathan
FRC #3256 (Warriorborgs)
Team Role: Programmer
 
Join Date: Feb 2011
Rookie Year: 2010
Location: San Jose
Posts: 27
Tanaythan is an unknown quantity at this point
Re: Robodox Guide to velocity control using PID

I've been thinking of a different way to control the velocity of a spinner using PWM and the basic GetRate() function of an encoder. It starts of with a while loop and the shooter motor.
Code:
while(encoder->GetRate() <= setpoint) {jag->Set(i); i+= .001}
This way, it ramps up, but the only fear I have of this method is that I am unfamiliar with the way GetRate() works. If it gets back data per second, then we have a problem with this formula. If it works like the CANJaguar feature, there should be no problems with this method.

Note: We used CANJaguars this year and plugged the encoder into the Jaguar itself to use the Speed PID feature.
__________________
Tanay Nathan
Programmer
Team #3256 Warriorborgs
Reply With Quote
  #3   Spotlight this post!  
Unread 30-04-2012, 17:21
xraymypanda's Avatar
xraymypanda xraymypanda is offline
Cowboy programmer
AKA: Chris M
FRC #0599 (RoboDox)
Team Role: Programmer
 
Join Date: Dec 2011
Rookie Year: 2011
Location: Granada Hills,CA
Posts: 82
xraymypanda has a spectacular aura aboutxraymypanda has a spectacular aura about
Re: Robodox Guide to velocity control using PID

Quote:
Originally Posted by rawrxp View Post
Code:
while(encoder->GetRate() <= setpoint) {jag->Set(i); i+= .001}
This way, it ramps up, but the only fear I have of this method is that I am unfamiliar with the way GetRate() works. If it gets back data per second, then we have a problem with this formula.
As far as I know and recall, GetRate() returns data per second.
__________________

2011: Head Scout
2012: (figure)Head Programmer
2013: Head Programmer, Chief Strategist, Outreach Executive, and Driver
Reply With Quote
  #4   Spotlight this post!  
Unread 30-04-2012, 19:25
Tanaythan's Avatar
Tanaythan Tanaythan is offline
Programmer
AKA: Tanay Nathan
FRC #3256 (Warriorborgs)
Team Role: Programmer
 
Join Date: Feb 2011
Rookie Year: 2010
Location: San Jose
Posts: 27
Tanaythan is an unknown quantity at this point
Re: Robodox Guide to velocity control using PID

I'll modify my formula and see if I can use it with the CANJaguar PWM feature and using the GetSpeed() function. I'll do it as soon as I possibly can. We can always use Ether's method of the "bang bang" control style.
__________________
Tanay Nathan
Programmer
Team #3256 Warriorborgs
Reply With Quote
  #5   Spotlight this post!  
Unread 25-10-2012, 11:20
JamesTerm's Avatar
JamesTerm JamesTerm is offline
Terminator
AKA: James Killian
FRC #3481 (Bronc Botz)
Team Role: Engineer
 
Join Date: May 2011
Rookie Year: 2010
Location: San Antonio, Texas
Posts: 298
JamesTerm is a splendid one to beholdJamesTerm is a splendid one to beholdJamesTerm is a splendid one to beholdJamesTerm is a splendid one to beholdJamesTerm is a splendid one to beholdJamesTerm is a splendid one to beholdJamesTerm is a splendid one to behold
Re: Robodox Guide to velocity control using PID

Quote:
Originally Posted by xraymypanda View Post
As far as I know and recall, GetRate() returns data per second.
GetRate() works great for velocity control... in fact in my tests it works better for noise control than using raw/time way.

In our code we work with radians per second as the preferred unit of measurment, and we do not need to normalize to use PID... I did however rewrite the PID class from 2011 to something more direct that does not use any threading. Instead the main loop is timed and each time change call uses a delta time parameter (double in units of seconds). And this gets factored in for the error computation. This will take care of uneven time-slices which is why the threading was used. Finally on the averaging... don't use a smooth blend type of average because this will introduce extra latency on your actual time. Instead use either a priority queue or a fixed number averager (or both) also use the kalman filter... I use all three of these... to combat the worst case encoder noisy-ness... like when the shaking of the motor caused the encoder to bust out of its casing and lose values per revolution.

The re-written PID controller source is here:
http://www.termstech.com/files/Archi...Controller.zip

The averagers are also in here in the Misc.h file
Reply With Quote
  #6   Spotlight this post!  
Unread 25-10-2012, 14:02
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,098
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: Robodox Guide to velocity control using PID

Quote:
Originally Posted by JamesTerm View Post
... in my tests ...
I'd be interested in seeing your test plan, test setup, and test results, if you would be willing to share them.


Reply With Quote
  #7   Spotlight this post!  
Unread 25-10-2012, 15:15
JamesTerm's Avatar
JamesTerm JamesTerm is offline
Terminator
AKA: James Killian
FRC #3481 (Bronc Botz)
Team Role: Engineer
 
Join Date: May 2011
Rookie Year: 2010
Location: San Antonio, Texas
Posts: 298
JamesTerm is a splendid one to beholdJamesTerm is a splendid one to beholdJamesTerm is a splendid one to beholdJamesTerm is a splendid one to beholdJamesTerm is a splendid one to beholdJamesTerm is a splendid one to beholdJamesTerm is a splendid one to behold
Re: Robodox Guide to velocity control using PID

Quote:
Originally Posted by Ether View Post
I'd be interested in seeing your test plan, test setup, and test results, if you would be willing to share them.


I have all my work on this here:
http://www.termstech.com/articles/PID_Kalman.html

This is due for an update on the latest and greatest achievements that show how to beat latency with some tested velocity graphs. I'll get to that eventually, but what is there now is still worth a read.

Going here:
http://www.termstech.com/articles/

Has a list of all the articles I've written... check out "getting encoders to work", "Gettting arm to work", and "Weight Mass? what's the difference?"

On a side note not yet written there is a new technique I call "use the force" this gets me the 0ms latency, and I've got this working for speed control, but eventually wish to get this for fixed point... I'll explain this one in these articles at some point.

Here's a sneak peak of it:
http://www.termstech.com/files/RateG...kForceTest.gif
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 03:03.

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