Go to Post (Just remember to pack extra warm--when they say the state motto is Live, Freeze, or Die, they're not joking.) - Billfred [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

 
Reply
Thread Tools Rate Thread Display Modes
  #16   Spotlight this post!  
Unread 09-28-2016, 12:16 AM
AustinSchuh AustinSchuh is offline
Registered User
FRC #0971 (Spartan Robotics) #254 (The Cheesy Poofs)
Team Role: Engineer
 
Join Date: Feb 2005
Rookie Year: 1999
Location: Los Altos, CA
Posts: 800
AustinSchuh has a reputation beyond reputeAustinSchuh has a reputation beyond reputeAustinSchuh has a reputation beyond reputeAustinSchuh has a reputation beyond reputeAustinSchuh has a reputation beyond reputeAustinSchuh has a reputation beyond reputeAustinSchuh has a reputation beyond reputeAustinSchuh has a reputation beyond reputeAustinSchuh has a reputation beyond reputeAustinSchuh has a reputation beyond reputeAustinSchuh has a reputation beyond repute
Re: Tuning PID Constants Over a Range

Quote:
Originally Posted by Paul Copioli View Post
We have found that motion profile + feedforward gain + PID work for all of our telemetry navigation needs, whether it be for driving or moving a ridiculously complicated arm.

Austin and his crew use state space, but I am too simplistic for all that awesomeness so I stick with profile + FF + PID.
Agreed! profiles + Feed Forward + PID is good enough for FRC. Everything in FRC can be worked down to a second order system, which means that PID is a good control strategy.

I love playing with control systems, and like pushing the limits. That being said, I don't recommend using the controllers we use unless you have a strong math background and time to learn what is going on.

The Talon SRXs have good support for all of this as well.
Reply With Quote
  #17   Spotlight this post!  
Unread 09-28-2016, 12:33 AM
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: Tuning PID Constants Over a Range

Wesley did a great job of summarizing our process for tuning, but I'd like to add a few things, especially with respect to the trapezoidal motion component:
Quote:
Originally Posted by wesleyac View Post
I would agree that motion profiling + feed forward will help a lot. 254 and 971 did a great video on this at champs in 2015 (https://www.youtube.com/watch?v=8319J1BEHwM).

The process that we used for tuning our turning went something like this:

1.) Write and test motion profile code (graph it to make sure that it is actually doing what it is supposed to).
2.) Find motion profile parameters. We used trapezoidal motion.
2a.) You can find the maximum velocity by sending 12v to both motors and looking at the maximum slope of the line.
2b.) From the same plot of the velocity, you can run a regression to get the acceleration.
2c.) You should set you FF parameters to something slightly lower than the actual values - as the season wears on, your robot will get less efficient, and you don't want to ask your robot to follow a profile that it's incapable of following.

3.) Find FF parameters
3a.) You can use the dynamics of the system to calculate what these should be, but we found that for turning, they ended up being fairly inaccurate (probably wheel scrub + static friction were a lot of that. pneumatic wheels can be a pain ) We started with calculated values, and tuned them by hand until they largely matched the motion profile. Again, having plots of angle over time as well as target angle over time on the same axes helps hugely here. If you don't have some system to graph variables over time, make one! it will save time in the long run. Test every change with multiple values.
4.) Start tuning PID. There are many different strategies for this. The one that you are using looks fine. Test every change for a range of values (90deg, 25deg, 10deg, 5deg, 2deg, etc. This also applies to tuning the FF values.) Again, graph everything. You can very easily see the effects of changing PID parameters from the graphs.

Another thing to consider it when you want to terminate the loop. If you don't need to be very accurate (for example, in an initial turn before starting vision), then don't have strict termination conditions. Also, if you have problems with the robot continuing to turn after the profile is over, consider adding a minimum derivative as a termination condition.

If you have any questions, feel free to ask.
(emphasis mine)

2b) The regression that Wesley is referring to is an exponential regression against the solution to the second-order differential equation that the drivetrain (theoretically) should follow: x'' = ax' + bu where x is distance (or angle - we controlled angle and distance with two separate controllers) and u is voltage, assumed to be constant at 12V. You basically just collect a bunch of data and then do a regression on that to find the constants a and b. You can also not bother with this part for acceleration and just try to manually tune constants, which can work just as well or better in some cases but can require more time.

2c) You definitely need to set the motion profile's acceleration and velocity parameters to lower than the maximum, but not only because of wear/tear/battery voltage/other pesky things that happen in the real world. If you set the velocity to the maximum the robot can possibly go, you will not be able to actually control it when it is going that speed - to properly control a system, you should not be saturating its inputs or the system and controller will respond in a pretty strange manner (nonlinearities are unlikely to play well with PID controllers), being "less responsive" when moving at full speed than when accelerating or decelerating. In addition, the end of the acceleration period will get cut off and will not act nicely (the middle plot is velocity and the bottom plot is voltage):
Click image for larger version

Name:	cutoff_tmp.png
Views:	77
Size:	38.7 KB
ID:	21083

3a) I don't have anything to add on this point, but I just wanted to emphasize how important it is to have some way to visualize everything that's happening on your robot. Not only for tuning purposes, but for debugging as well - log everything you can in some way; it will serve you well when you are tearing your hair out over some strange bug.
__________________

Reply With Quote
  #18   Spotlight this post!  
Unread 09-28-2016, 01:01 PM
Brian Selle's Avatar
Brian Selle Brian Selle is offline
Mentor
FRC #3310 (Black Hawk Robotics)
Team Role: Engineer
 
Join Date: Jan 2012
Rookie Year: 2012
Location: Texas
Posts: 162
Brian Selle has a spectacular aura aboutBrian Selle has a spectacular aura aboutBrian Selle has a spectacular aura about
Re: Tuning PID Constants Over a Range

One more idea is to use PID alone for small movements (like < 5 deg) and motion profile (w/ PID position control) for larger turns. If you tune your controller for using motion profile the gains will be relatively high and should work well for small angle corrections.
__________________
2015 Newton Semi-Finalist (3130, 2468, 3310, 537)
2015 Lubbock Regional Winner (2468, 3310, 4799)
2014 Galileo Quarter-Finalist (2052, 70, 3310, 3360)
2014 Colorado Regional Winner (1138, 3310, 2543)
2013 Texas Robot Roundup Winner (3310, 624, 2848)
2013 Archimedes Semi-Finalist (126, 3310, 1756)
2013 Dallas Regional Winner (148, 3310, 4610)
2012 Dallas West Regional Winner (935, 3310, 4206)
Reply With Quote
  #19   Spotlight this post!  
Unread 09-28-2016, 02:32 PM
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,069
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: Tuning PID Constants Over a Range

I agree that a motion profile + feedforward to overcome static friction can solve this problem adequately for FRC purposes. However, the Talon SRX makes precise 1KHz velocity control stupidly easy to achieve; hiding the stiction nonlinearity behind a Talon and using plain old position PID is just as workable a solution these days. (But is still improved by using a motion profile of course)
Reply With Quote
  #20   Spotlight this post!  
Unread 09-28-2016, 02:45 PM
Andrew Schreiber Andrew Schreiber is offline
Data Nerd
FRC #0079
 
Join Date: Jan 2005
Rookie Year: 2000
Location: Misplaced Michigander
Posts: 4,055
Andrew Schreiber has a reputation beyond reputeAndrew Schreiber has a reputation beyond reputeAndrew Schreiber has a reputation beyond reputeAndrew Schreiber has a reputation beyond reputeAndrew Schreiber has a reputation beyond reputeAndrew Schreiber has a reputation beyond reputeAndrew Schreiber has a reputation beyond reputeAndrew Schreiber has a reputation beyond reputeAndrew Schreiber has a reputation beyond reputeAndrew Schreiber has a reputation beyond reputeAndrew Schreiber has a reputation beyond repute
Re: Tuning PID Constants Over a Range

Quote:
Originally Posted by Jared Russell View Post
I agree that a motion profile + feedforward to overcome static friction can solve this problem adequately for FRC purposes. However, the Talon SRX makes precise 1KHz velocity control stupidly easy to achieve; hiding the stiction nonlinearity behind a Talon and using plain old position PID is just as workable a solution these days. (But is still improved by using a motion profile of course)
Are you saying for heading changes, let's assume turn in place, you'd suggest figuring out how far the wheels need to turn and then just position PID them (with or without motion profile) ?
__________________




.
Reply With Quote
  #21   Spotlight this post!  
Unread 09-29-2016, 01:57 AM
AustinSchuh AustinSchuh is offline
Registered User
FRC #0971 (Spartan Robotics) #254 (The Cheesy Poofs)
Team Role: Engineer
 
Join Date: Feb 2005
Rookie Year: 1999
Location: Los Altos, CA
Posts: 800
AustinSchuh has a reputation beyond reputeAustinSchuh has a reputation beyond reputeAustinSchuh has a reputation beyond reputeAustinSchuh has a reputation beyond reputeAustinSchuh has a reputation beyond reputeAustinSchuh has a reputation beyond reputeAustinSchuh has a reputation beyond reputeAustinSchuh has a reputation beyond reputeAustinSchuh has a reputation beyond reputeAustinSchuh has a reputation beyond reputeAustinSchuh has a reputation beyond repute
Re: Tuning PID Constants Over a Range

Quote:
Originally Posted by Andrew Schreiber View Post
Are you saying for heading changes, let's assume turn in place, you'd suggest figuring out how far the wheels need to turn and then just position PID them (with or without motion profile) ?
Yes, but he's proposing that the output of the position PID and (maybe) profile would be a velocity to feed to the velocity PID running on the talon.
Reply With Quote
  #22   Spotlight this post!  
Unread 09-29-2016, 09:52 AM
Andrew Schreiber Andrew Schreiber is offline
Data Nerd
FRC #0079
 
Join Date: Jan 2005
Rookie Year: 2000
Location: Misplaced Michigander
Posts: 4,055
Andrew Schreiber has a reputation beyond reputeAndrew Schreiber has a reputation beyond reputeAndrew Schreiber has a reputation beyond reputeAndrew Schreiber has a reputation beyond reputeAndrew Schreiber has a reputation beyond reputeAndrew Schreiber has a reputation beyond reputeAndrew Schreiber has a reputation beyond reputeAndrew Schreiber has a reputation beyond reputeAndrew Schreiber has a reputation beyond reputeAndrew Schreiber has a reputation beyond reputeAndrew Schreiber has a reputation beyond repute
Re: Tuning PID Constants Over a Range

Quote:
Originally Posted by AustinSchuh View Post
Yes, but he's proposing that the output of the position PID and (maybe) profile would be a velocity to feed to the velocity PID running on the talon.
So run a traditional PID control loop with the Gyro as the input and a fake output that sends a target velocity to the velocity PID on the talons?
__________________




.
Reply With Quote
  #23   Spotlight this post!  
Unread 09-29-2016, 11:51 AM
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,069
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: Tuning PID Constants Over a Range

Quote:
Originally Posted by Andrew Schreiber View Post
So run a traditional PID control loop with the Gyro as the input and a fake output that sends a target velocity to the velocity PID on the talons?
Yeah, use one controller with gyro angle as the process variable to track a desired heading profile. The output of this loop is a desired angular velocity. You can then use an inverse kinematics equation* to map angular velocity to drive motor velocities, and use these as velocity setpoints for the Talon SRX.

* For differentially steered robots, this equation looks something like:
Code:
drive_wheel_linear_velocity = wheelbase_width_meters * desired_turning_rate_rads_per_second / 2
left_motor_desired_linear_velocity = -drive_wheel_linear_velocity
right_motor_desired_linear_velocity = +drive_wheel_linear_velocity
(you can also multiply the right side of the equation above by a corrective factor that you tune to account for losses due to skidding; ours was ~2 with 8 low pressure pneumatic wheels this year. You don't have to be super precise on this, as the gyro PID controller will correct for error, but better to be more accurate than not)

To tune this, start with the Talon SRX velocity loop and work backwards. Make sure you can accurately track a variety of speeds (both fast and slow) in straight line, turn in place, and arcing motions. We were able to find that one set of gains did a good job in all of these cases, but YMMV. Once you can accurately track your velocity commands, tune your kinematics by adjusting the equation's corrective factor while turning in place (ex. command each side of the drive to go +/- a couple feet per second and measure the actual turning rate with the gyro...repeat and find the best fit for your model). Finally, you can then tune the gyro PID loop (which will be really easy, likely P-only, because of the fast velocity loop underneath).

Last edited by Jared Russell : 09-29-2016 at 11:58 AM.
Reply With Quote
  #24   Spotlight this post!  
Unread 09-29-2016, 01:37 PM
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 7,997
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: Tuning PID Constants Over a Range

Quote:
Originally Posted by Jared Russell View Post
drive_wheel_linear_velocity = wheelbase_width_meters * desired_turning_rate_rads_per_second / 2
For a robot with center of mass located at center of rectangle formed by the 4 wheels, I think that should be:

S = (1+f2)(W/2)ω

S is drive wheel linear speed
W is trackwidth
ω is desired turning rate in radians per second
f the the ratio L/W, where L is wheelbase


Reply With Quote
  #25   Spotlight this post!  
Unread 09-29-2016, 01:42 PM
Andrew Schreiber Andrew Schreiber is offline
Data Nerd
FRC #0079
 
Join Date: Jan 2005
Rookie Year: 2000
Location: Misplaced Michigander
Posts: 4,055
Andrew Schreiber has a reputation beyond reputeAndrew Schreiber has a reputation beyond reputeAndrew Schreiber has a reputation beyond reputeAndrew Schreiber has a reputation beyond reputeAndrew Schreiber has a reputation beyond reputeAndrew Schreiber has a reputation beyond reputeAndrew Schreiber has a reputation beyond reputeAndrew Schreiber has a reputation beyond reputeAndrew Schreiber has a reputation beyond reputeAndrew Schreiber has a reputation beyond reputeAndrew Schreiber has a reputation beyond repute
Re: Tuning PID Constants Over a Range

Quote:
Originally Posted by Ether View Post
For a robot with center of mass located at center of rectangle formed by the 4 wheels, I think that should be:

S = (1+f2)(W/2)ω

S is drive wheel linear speed
W is trackwidth
ω is desired turning rate in radians per second
f the the ratio L/W, where L is wheelbase


And by L (wheelbase) you mean contact patch (I think that's the terminology Hibner used)? So, for most teams it would be either the distance between the inner 2 sets of wheels (4/8wd) or the distance between the sets of wheels that the CoM is between (6/10wd). I'm going to ignore the option of a moving CoM because it's going to make my head hurt.
__________________




.
Reply With Quote
  #26   Spotlight this post!  
Unread 09-29-2016, 01:58 PM
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 7,997
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: Tuning PID Constants Over a Range

...
Attached Thumbnails
Click image for larger version

Name:	wheelbase.png
Views:	53
Size:	4.2 KB
ID:	21092  Click image for larger version

Name:	trackwidth.png
Views:	58
Size:	17.3 KB
ID:	21093  
Reply With Quote
  #27   Spotlight this post!  
Unread 09-29-2016, 02:04 PM
Andrew Schreiber Andrew Schreiber is offline
Data Nerd
FRC #0079
 
Join Date: Jan 2005
Rookie Year: 2000
Location: Misplaced Michigander
Posts: 4,055
Andrew Schreiber has a reputation beyond reputeAndrew Schreiber has a reputation beyond reputeAndrew Schreiber has a reputation beyond reputeAndrew Schreiber has a reputation beyond reputeAndrew Schreiber has a reputation beyond reputeAndrew Schreiber has a reputation beyond reputeAndrew Schreiber has a reputation beyond reputeAndrew Schreiber has a reputation beyond reputeAndrew Schreiber has a reputation beyond reputeAndrew Schreiber has a reputation beyond reputeAndrew Schreiber has a reputation beyond repute
Re: Tuning PID Constants Over a Range

Quote:
Originally Posted by Ether View Post
...
Yes, I know the traditional definitions. Perhaps a better question would be, do I measure wheel base as the distance from the front wheel to the back wheel or do I measure it from the front wheel that touches to the back wheel that touches for drop center drive systems?
__________________




.
Reply With Quote
  #28   Spotlight this post!  
Unread 09-29-2016, 02:14 PM
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 7,997
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: Tuning PID Constants Over a Range


for 6WD drop-center skidsteer with most of the weight over the center wheels "f" is essentially zero so it reduces to Jared's formula.



Last edited by Ether : 09-29-2016 at 02:17 PM.
Reply With Quote
  #29   Spotlight this post!  
Unread 09-29-2016, 03:26 PM
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,069
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: Tuning PID Constants Over a Range

Quote:
Originally Posted by Ether View Post
For a robot with center of mass located at center of rectangle formed by the 4 wheels, I think that should be:

S = (1+f2)(W/2)ω

S is drive wheel linear speed
W is trackwidth
ω is desired turning rate in radians per second
f the the ratio L/W, where L is wheelbase


Yep, and this is the equation we actually used as our starting point (using the track width and wheelbase length of our inner four wheels). Our CoG was within an inch or two of the geometric center (ignoring dynamics). We found that even with this correction, we were ~50% off of the true value (a bit unsurprising since even though our outside wheels were raised, they still bore some weight because of deflection of our 15-20 PSI inner wheels).
Reply With Quote
  #30   Spotlight this post!  
Unread 09-30-2016, 03:36 PM
Oblarg Oblarg is offline
Registered User
AKA: Eli Barnett
FRC #0449 (The Blair Robot Project)
Team Role: Mentor
 
Join Date: Mar 2009
Rookie Year: 2008
Location: Philadelphia, PA
Posts: 1,047
Oblarg has a reputation beyond reputeOblarg has a reputation beyond reputeOblarg has a reputation beyond reputeOblarg has a reputation beyond reputeOblarg has a reputation beyond reputeOblarg has a reputation beyond reputeOblarg has a reputation beyond reputeOblarg has a reputation beyond reputeOblarg has a reputation beyond reputeOblarg has a reputation beyond reputeOblarg has a reputation beyond repute
Re: Tuning PID Constants Over a Range

If all you're doing is tuning a turn-to-angle loop, though, do you really need to take the extra step to figure out the proper scaling factor for turning rate? You could just "absorb" that constant (whatever it is) into the value of p.
__________________
"Mmmmm, chain grease and aluminum shavings..."
"The breakfast of champions!"

Member, FRC Team 449: 2007-2010
Drive Mechanics Lead, FRC Team 449: 2009-2010
Alumnus/Technical Mentor, FRC Team 449: 2010-Present
Lead Technical Mentor, FRC Team 4464: 2012-2015
Technical Mentor, FRC Team 5830: 2015-2016
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 05:10 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