OCCRA
Go to Post A problematic dynamic and culture becomes apparent when failure persists for such a duration and reoccurs so frequently that students begin to accept it as the norm, and never learn the proper way to do things. - sanddrag [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 10-02-2017, 11:15 PM
Jared Russell's Avatar
Jared Russell Jared Russell is offline
in hibernation
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,302
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 a PIDF follower on a robot with high gearing

Quote:
Originally Posted by Oblarg View Post
Assuming that you're tracking your profiles well enough that actual speed is sufficiently close to desired speed at any given point in time, then wouldn't a feedforward structure of "intercept + Kv*velocity setpoint + Ka*acceleration setpoint" properly account for this?
Yeah it should, though the nuisance factors I mentioned above still apply (I edited my post while you were responding)
Reply With Quote
  #17   Spotlight this post!  
Unread 10-02-2017, 11:19 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,606
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 a PIDF follower on a robot with high gearing

Quote:
Originally Posted by Jared Russell View Post
Yeah it should, though the nuisance factors I mentioned above still apply (I edited my post while you were responding)
We're hoping that the Talon SRX's setNominalClosedLoopVoltage() can account for battery voltage sag, though we haven't at all considered inductance.
__________________
"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

Last edited by Oblarg : 10-02-2017 at 11:21 PM.
Reply With Quote
  #18   Spotlight this post!  
Unread 10-02-2017, 11:37 PM
Jared Russell's Avatar
Jared Russell Jared Russell is offline
in hibernation
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,302
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 a PIDF follower on a robot with high gearing

BTW I recently came across a procedure for tuning acceleration gain that I thought I would share. Haven't tried this myself yet, but it is pretty intuitive and the math checks out.

1) Tune velocity feedforward gain using standard methods (e.g. measure actual speed and divide by applied voltage).

2) Using (slowing ramping) triangular or trapezoidal motion profiles, tune the velocity integral gain (Ki) to achieve zero steady state error tracking during the ramp up and down. Leave all other feedback gains set to zero. It doesn't have to be perfect, you just want to achieve a ~zero error steady state without a ton of oscillation. You will probably lag behind the velocity profile at first, then integral will kick in and you'll converge with the velocity ramp, then you'll overshoot the end of the ramp up.

3) Plot the effect of integral gain (integrator * Ki) during the ramp up. Measure the peak control contribution of the integrator term during the ramp up, divide by the acceleration of the ramp, and you have your acceleration feedforward gain (Ka).

4) You can now remove the integral gain if you want (and you should try to if you can...integrators suck)
Reply With Quote
  #19   Spotlight this post!  
Unread 10-02-2017, 11:41 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,606
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 a PIDF follower on a robot with high gearing

That is really, really clever. We'll have to try it.

I'm still hoping that, now that we've got a better handle on how to account for frictional losses, there's a chance that the "theoretical" value of Ka (i.e. calculated from motor stall torque, max voltage, gearing, robot mass, and wheel size) will work.
__________________
"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

Last edited by Oblarg : 10-02-2017 at 11:43 PM.
Reply With Quote
  #20   Spotlight this post!  
Unread 10-02-2017, 11:45 PM
Jared Russell's Avatar
Jared Russell Jared Russell is offline
in hibernation
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,302
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 a PIDF follower on a robot with high gearing

Quote:
Originally Posted by Oblarg View Post
We're hoping that the Talon SRX's setNominalClosedLoopVoltage() can account for battery voltage sag, though we haven't at all considered inductance.
Inductance only really matters for very low inertia applications (it had a small but measurable effect on our 2015 can grabbers, but in a drivetrain or arm or something, you don't notice it). Battery sag and nonlinear forms of friction are far bigger culprits most of the time.

setNominalClosedLoopVoltage() does work wonders for battery voltage sag, though it still can't help you when you saturate.
Reply With Quote
  #21   Spotlight this post!  
Unread 10-02-2017, 11:50 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,606
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 a PIDF follower on a robot with high gearing

Quote:
Originally Posted by Jared Russell View Post
setNominalClosedLoopVoltage() does work wonders for battery voltage sag, though it still can't help you when you saturate.
None of our motion profiles come anywhere close to saturating, thankfully, and we hope to keep it that way.

I'll report back next Monday on how the value of Ka we settle on compares to the theoretical value, now that we've fully ironed out intercept and Kv.
__________________
"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
  #22   Spotlight this post!  
Unread 10-03-2017, 12:12 AM
Jared Russell's Avatar
Jared Russell Jared Russell is offline
in hibernation
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,302
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 a PIDF follower on a robot with high gearing

Quote:
Originally Posted by Oblarg View Post
That is really, really clever. We'll have to try it.

I'm still hoping that, now that we've got a better handle on how to account for frictional losses, there's a chance that the "theoretical" value of Ka (i.e. calculated from motor stall torque, max voltage, gearing, robot mass, and wheel size) will work.
It's definitely worth going through the exercise of doing it, if you have the time and know-how! If nothing else, you'll learn a lot about where your model is good, and where it can be improved. Sometimes it will shine lights on other problem areas (Austin now knows more about the RoboRIO PWM implementation than is probably healthy). Once you have a good model, you can go nuts in simulation without fear of putting holes in the wall, and have access to all sorts of cool tools that can pull off tricks that PID cannot. Once you get good at modeling, you can write control algorithms before your mechanism even exists yet.

I'm a big fan of doing things empirically, since it's often the shortest path to a solution that gets the job done, and I am a very busy (and *very* lazy) man. Not sure if your motor matches it's spec sheet? Don't have a clue how efficient your geartrain is or how much inertia it has? Not sure how to make the right tradeoffs when doing pole placement or LQR? Stuck using Java?
Who cares (*), throw a Talon at it!

Both approaches have their time and place

*: A rudimentary model to validate that the mechanism is reasonably close to a first-order LTI system and to bootstrap PIDF gains into the right ballpark is still helpful.

Last edited by Jared Russell : 10-03-2017 at 12:14 AM.
Reply With Quote
  #23   Spotlight this post!  
Unread 10-03-2017, 02:21 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: 872
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 a PIDF follower on a robot with high gearing

Quote:
Originally Posted by Jared Russell View Post
It's definitely worth going through the exercise of doing it, if you have the time and know-how! If nothing else, you'll learn a lot about where your model is good, and where it can be improved. Sometimes it will shine lights on other problem areas (Austin now knows more about the RoboRIO PWM implementation than is probably healthy). Once you have a good model, you can go nuts in simulation without fear of putting holes in the wall, and have access to all sorts of cool tools that can pull off tricks that PID cannot. Once you get good at modeling, you can write control algorithms before your mechanism even exists yet.

I'm a big fan of doing things empirically, since it's often the shortest path to a solution that gets the job done, and I am a very busy (and *very* lazy) man. Not sure if your motor matches it's spec sheet? Don't have a clue how efficient your geartrain is or how much inertia it has? Not sure how to make the right tradeoffs when doing pole placement or LQR? Stuck using Java?
Who cares (*), throw a Talon at it!

Both approaches have their time and place

*: A rudimentary model to validate that the mechanism is reasonably close to a first-order LTI system and to bootstrap PIDF gains into the right ballpark is still helpful.
Jared and I tend to take very different approaches. Both of them have their places. On 971, the software team doesn't get any working hardware until the last possible moment. That pushes us to be model driven, whereas 254's iterative designs tend to push them to be experimental. There should be a video somewhere online of me giving a talk about how to do test driven development with simulations.

One of my other recent finds has been comparing modeled acceleration to measured acceleration in our drivetrain. I'm finding that the difference is even higher than I originally expected. I've got a disturbance force term in the drivetrain kalman filter which serves a similar purpose to Jared's integral solution before. That term should be 0 in an ideal model. So, you can correlate that signal with what's going on to try to determine where your model mismatch is. I'm not sure where this exploration will lead, but it might lead to discovering gearbox inefficiencies, wiring problems, etc.

Our model based feed-forwards is essentially just numerically inverting the model. I've now also got feed-forwards on all our subsystems because the math is already solved.

Model based controls tend to push the work more upfront, whereas empirical controls might save you time, or might push you to react to each problem.

Building off (*), I'd say that having a good understanding of the models for a couple mechanisms can really help you cut corners. If I'm doing a position loop with an arm, I know intuitively how all the dynamics work, what the different constants mean, etc. If I were given a brand new configuration that I hadn't seen before, I might have much more trouble writing a loop for it without understanding the physics.
Reply With Quote
  #24   Spotlight this post!  
Unread 10-09-2017, 09:34 AM
noah.gleason's Avatar
noah.gleason noah.gleason is offline
Registered User
FRC #0449 (The Blair Robot Project)
Team Role: Programmer
 
Join Date: Mar 2017
Rookie Year: 2016
Location: Bethesda, MD
Posts: 72
noah.gleason has a reputation beyond reputenoah.gleason has a reputation beyond reputenoah.gleason has a reputation beyond reputenoah.gleason has a reputation beyond reputenoah.gleason has a reputation beyond reputenoah.gleason has a reputation beyond reputenoah.gleason has a reputation beyond reputenoah.gleason has a reputation beyond reputenoah.gleason has a reputation beyond reputenoah.gleason has a reputation beyond reputenoah.gleason has a reputation beyond repute
Re: Tuning a PIDF follower on a robot with high gearing

Quote:
Originally Posted by Oblarg View Post
None of our motion profiles come anywhere close to saturating, thankfully, and we hope to keep it that way.

I'll report back next Monday on how the value of Ka we settle on compares to the theoretical value, now that we've fully ironed out intercept and Kv.
So we tested the intercept and Kv yesterday using velocity-only motion profiles, and it worked very well except that we needed to get separate intercept and Kv for each side of the drive. The difference between sides was about 10% for us, on a robot using 3 cims per side but in opposite directions (probably some combination of motor bias and 4-year-old CIM slop). We didn't have time to go back and calculate the intercept and Kv for the other side (the data posted earlier was for the right side only), so we just tuned it until it drove straight. Once it did, we checked the distance and it went 102 inches (setpoint was 100), so I'd guess it would work great first try if you calculate each side from the vel vs voltage curve. We added in the theoretical Ka of 100 feet/(sec^2) and it reduced the error down to 101 (still without position servo, just velocity FF). We tested it with two different profiles and the error was about the same. Adding in the position servo reduced the error down to 0.25 inches. Next week we'll test this on some curved profiles and report back.
Reply With Quote
  #25   Spotlight this post!  
Unread 10-09-2017, 10:51 AM
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,606
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 a PIDF follower on a robot with high gearing

It's worth noting that with a calculated maximum acceleration of ~100 feet/sec^2, the actual voltage value of the acceleration feedforward is quite small (on the order of half a volt, maximum, with the profiles we're running). The addition of an intercept to the feedforward was by far more important in getting reasonably good open-loop following of the profiles.

It seems that this form of feedforward (intercept + Kv*vel + Ka*acc) works reasonably well across different cruise speeds - we tested it on 100''-long profiles with peak velo/acc/jerk of 4/3/6 and 7/4.5/9 (ft/sec, ft/sec^2, ft/sec^3) and saw no major difference in error between the two.

I think we can conclude that this is likely a better solution than gain scheduling, and teams should try it first.
__________________
"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

Last edited by Oblarg : 10-10-2017 at 10:44 AM.
Reply With Quote
  #26   Spotlight this post!  
Unread 10-11-2017, 01:37 PM
Classified*'s Avatar
Classified* Classified* is offline
Drive it like you stole it
AKA: Julia Cecchetti
FRC #0291 (CIA: Creativity in Action)
Team Role: Leadership
 
Join Date: Nov 2015
Rookie Year: 2015
Location: Erie PA
Posts: 159
Classified* is a splendid one to beholdClassified* is a splendid one to beholdClassified* is a splendid one to beholdClassified* is a splendid one to beholdClassified* is a splendid one to beholdClassified* is a splendid one to beholdClassified* is a splendid one to behold
Re: Tuning a PIDF follower on a robot with high gearing

This seems to be the right thread to post this.

This is my first time trying to tune PIDF. Our robot has a (measured) max speed of 15 ft/s, and acceleration of 6.4 ft/s/s. I started with a simple 24 foot long straight path, a max speed of 8 ft/s and max acceleration of 4.5 ft/s (I plan to use these values for all paths) using 254's 2014 trajectory follower and trajectory lib code. In 254's presentation, they mentioned kv being 1/velocity and ka being 1/acceleration. I tried that first, and the robot flew away and almost killed a bush. Using excel I graphed the desired path vs the actual one taken. The path is cut short because I needed to save the poor bush:

So it seems my acceleration was off.

I took a different approach next, First tuning kv until it went the correct velocity (after accelerating and lagging behind). I ended up with kp = 0, kv = 1/12, ka = 0:


Then I added onto ka until the profiles were very similar. kp = 0, kv = 1/12, ka = 1/18:

I couldn't seem to make them any better than that, any change to ka made it worse. At most the error was ~6" in the path.

Then I raised kp until the error was a flat line kp = 2, kv = .0833, ka = .0556:


My Questions:

Is this the correct way to tune PIDF? Did I tune kv and ka well enough before adding in kp? Kp seems really high, Is that normal? Why are kv and ka not 1/ tested velocity and 1/tested acceleration? My ka was 1/18, my robot definitely does not accelerate to full speed in under a second, though it does seem faster than 6.4 ft/s/s.

Here are the imgur links to the graphs, as they seem blurry as thumbnails:
https://imgur.com/xFTN8zV
https://imgur.com/xHTJT5m
https://imgur.com/1wZ5kBR
https://imgur.com/Esi2zkY


Thanks!

-Julia
Team 291
__________________

2017 NEOFRA MVRC Winner with 2399 and 2252
2017 Steel City Showdown Winner with 2614 and 3260
2017 WOW Championship Finalist with 4145, 3138, and 3511
2016 Rachacha Ruckus Finalist with 5406 and 639
2015 Rachacha Ruckus Finalist with 1126 and 5406
2015 NEOFRA MVRC Finalist with 48 and 379
2015 Buckeye Regional Finalist with 48 and 5413
Team291.com

Last edited by Classified* : 10-11-2017 at 01:53 PM.
Reply With Quote
  #27   Spotlight this post!  
Unread 10-11-2017, 02:28 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,606
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 a PIDF follower on a robot with high gearing

Quote:
Originally Posted by Classified* View Post

My Questions:

Is this the correct way to tune PIDF? Did I tune kv and ka well enough before adding in kp? Kp seems really high, Is that normal? Why are kv and ka not 1/ tested velocity and 1/tested acceleration? My ka was 1/18, my robot definitely does not accelerate to full speed in under a second, though it does seem faster than 6.4 ft/s/s.
First, thank you for providing such a detailed post - it makes it much easier to give useful feedback!

The first thing to realize is that, while it is true that Kv should be on the order 1/max velocity, and Ka on the order of 1/max acceleration, these mean rather specific things and so may not neatly correspond to what you have measured. In order to understand why this is the case, we must look at the state equation for a brushed DC motor, which is of the following form (we shall assume, for sake of convenience, that there is neither friction nor wheel slip):

V = K*w + IR

Where V is the applied voltage, K is some constant, w is the angular velocity of the motor, I is the current, and R is the resistance.

Well, what does this tell us? We know that w is, clearly, proportional to robot velocity. We also know that I is proportional to torque, which is proportional to robot acceleration. Thus, by appropriately absorbing constants, we can re-write this state equation:

V = Kv*vel + Ka*acc

This yields the general form of our feedforward. So, how do we figure out the values of Kv and Ka? Well, note that from our two equations we can observe the following:

Kv*vel = K*w
Ka*acc = IR

Let's consider the first equation. At free speed, we know that K*w must equal the entire applied voltage, V (this is the definition of "free speed"). Thus, if we call the robot's velocity with the motor running at free speed "maxvel," we have Kv*maxvel = V => Kv = V/maxvel.

Similarly, let's consider the second equation. At stall, we similarly know that IR must equal the entire applied voltage (since w is 0). Thus, if we call the robot's acceleration with the motor outputting stall torque "maxacc," we similarly have Ka*maxacc = V => Ka = V/maxacc.

So, you'll note that the above formulas have a 'V' instead of a '1' - this is simply because we have done the math with voltage output, instead of fractional output. But, more importantly, after going through the math it should now be clear exactly which values of "velocity" and "acceleration" are required. We need the velocity of the robot with the motors running at free speed, and the acceleration of the robot with the motors at stall, both with our maximum applied voltage (actually, the math works at any arbitrary applied voltage but you'd have to change the numerator to match, and the values thus remain the same).

So, why might your measured velocity and acceleration have resulted in your robot running away? Likely, because it is actually rather hard to empirically measure these two quantities.

Max velocity is the easier of the two to measure, but you will likely run into the problem of not being able to actually clock the robot's speed at 12V applied, because a) it takes a lot of space for a robot to actually reach steady state at max speed and b) the internal resistance of the battery will likely prevent you from actually applying 12V at any nontrivial current load. Still, a reasonable job can be done to account for these, for instance by measuring at a voltage other than max (as noted above), or (better) by taking the "linear regression" approach I detailed earlier in the thread. Note that a reason your Kv seems to imply a max speed lower than what you have measured is likely due to the presence of an "intercept" in the voltage/speed curve due to friction resulting in your linear approximation not fitting quite right at your target velocity, again as discussed earlier in the thread.

Max acceleration is basically impossible to directly measure because, in addition to the problems above, it is not actually attainable without slipping the wheels (unless you measure it at a fairly low applied voltage), and because it is only achieved instantaneously (and so, unless you have very high-resolution encoders and a very fast loop reading them, you likely will have trouble taking an accurate measurement). You may be better off calculating the theoretical value from the stall torque of your motors (if you followed the math above, it should be clear how to do this), or else just tuning it empirically as you already have done. Note, however, that (as you noticed) the value for "max acceleration" actually used in this calculation is likely going to seem huge - but even with no wheel slip and a perfect voltage source, it could never be attained for more than a split second before dropping as the motors begin to speed up (again, refer to the state equation to see why).

As for your other question:

What solution are you using for following the paths? Are you running the loop yourself on the RIO, or are you using the CANTAlonSRX's Motion Profiling mode? It is hard to know whether your P value is reasonable or not without this information - the scaling of P depends on your units, and thus on your implementation. If you are using the Talon's MP mode, a P of 2-ish (with 512 CPR encoders and the Talon's native units) is reasonable in my experience; again, though, this does not necessarily generalize!
__________________
"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

Last edited by Oblarg : 10-11-2017 at 06:06 PM.
Reply With Quote
  #28   Spotlight this post!  
Unread 10-11-2017, 02:53 PM
Classified*'s Avatar
Classified* Classified* is offline
Drive it like you stole it
AKA: Julia Cecchetti
FRC #0291 (CIA: Creativity in Action)
Team Role: Leadership
 
Join Date: Nov 2015
Rookie Year: 2015
Location: Erie PA
Posts: 159
Classified* is a splendid one to beholdClassified* is a splendid one to beholdClassified* is a splendid one to beholdClassified* is a splendid one to beholdClassified* is a splendid one to beholdClassified* is a splendid one to beholdClassified* is a splendid one to behold
Re: Tuning a PIDF follower on a robot with high gearing

Quote:
Originally Posted by Oblarg View Post
What solution are you using for following the paths? Are you running the loop yourself on the RIO, or are you using the CANTAlonSRX's Motion Profiling mode? It is hard to know whether your P value is reasonable or not without this information - the scaling of P depends on your units, and thus on your implementation. If you are using the Talon's MP mode, a P of 2-ish (with 512 CPR encoders and the Talon's native units) is reasonable in my experience; again, though, this does not necessarily generalize!
Thank you so much for the detailed answer!! I understand what is going on much better now.

I am reading the encoders and calculating the outputs on the RIO scaled to be in feet with the loop running at 50 per second. We do not have talons, we are using Sparks.

I measured the velocity on the ground, so not at free speed. And to get the acceleration I took the approximate slope of the (very nonlinear) velocity graph. Bad I know.

Quote:
Originally Posted by Oblarg View Post
Note that a reason your Kv seems to imply a max speed lower than what you have measured is likely due to the presence of an "intercept" in the voltage/speed curve due to friction resulting in your linear approximation not fitting quite right at your target velocity, again as discussed earlier in the thread.
I have been following this thread (and the other threads related to tuning PIDF) for a while as I have been attempting to tune it for weeks. I thought I would start simple without the intercept. I only yesterday got on an actual field carpet with enough room to reach max velocity in the path. Previously I had only around 10 feet in my driveway to work with, and in the middle of the night I could work on the road because there were no cars .
__________________

2017 NEOFRA MVRC Winner with 2399 and 2252
2017 Steel City Showdown Winner with 2614 and 3260
2017 WOW Championship Finalist with 4145, 3138, and 3511
2016 Rachacha Ruckus Finalist with 5406 and 639
2015 Rachacha Ruckus Finalist with 1126 and 5406
2015 NEOFRA MVRC Finalist with 48 and 379
2015 Buckeye Regional Finalist with 48 and 5413
Team291.com

Last edited by Classified* : 10-11-2017 at 02:58 PM.
Reply With Quote
  #29   Spotlight this post!  
Unread 10-11-2017, 03:04 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,606
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 a PIDF follower on a robot with high gearing

Quote:
Originally Posted by Classified* View Post
Thank you so much for the detailed answer!! I understand what is going on much better now.

I am reading the encoders and calculating the outputs on the RIO scaled to be in feet with the loop running at 50 per second. We do not have talons, we are using Sparks.

I measured the velocity on the ground, so not at free speed. And to get the acceleration I took the approximate slope of the (very nonlinear) velocity graph. Bad I know.
So, the practical effect of measuring on the ground in that way is to attempt to account for friction by absorbing it totally into the slope of the Kv*vel line (i.e. into the value of Kv). This is better than simply measuring it on blocks and pretending there is no friction, but it is definitely worse than adding an intercept term and performing a linear regression with multiple data points to determine both the intercept and Kv. Your resources (time, programming, and otherwise) will dictate what is the most reasonable solution for your team - note, however, that if you take the simpler single-test no-intercept option, it is almost certainly best to pick a Kv that works best for the speed at which you intend to drive for most of your profile, which means running your test at that speed.

Regarding the value of Kp, rather than thinking of the value of the gain itself (which does not generalize because it depends on units), it is better to think of some reasonably-dimensioned quantities that depend on it. For example, determine what fractional output is added if your positional error is 1 inch with your current Kp value of 2. This is a much easier quantity to make sense of.

Quote:
I have been following this thread (and the other threads related to tuning PIDF) for a while as I have been attempting to tune it for weeks. I only yesterday got on an actual field carpet with enough room to reach max velocity in the path. Previously I had only around 10 feet in my driveway to work with, and in the middle of the night I could work on the road because there were no cars .
One nice thing about the apparently high degree of linearity of the voltage/speed curve is that you may not actually need to get all the way up to max speed to determine Kv, if you take the "regression" approach (or even if you don't, as in that case you should tune around the speed you wish to actually go).
__________________
"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
  #30   Spotlight this post!  
Unread 10-11-2017, 03:18 PM
Classified*'s Avatar
Classified* Classified* is offline
Drive it like you stole it
AKA: Julia Cecchetti
FRC #0291 (CIA: Creativity in Action)
Team Role: Leadership
 
Join Date: Nov 2015
Rookie Year: 2015
Location: Erie PA
Posts: 159
Classified* is a splendid one to beholdClassified* is a splendid one to beholdClassified* is a splendid one to beholdClassified* is a splendid one to beholdClassified* is a splendid one to beholdClassified* is a splendid one to beholdClassified* is a splendid one to behold
Re: Tuning a PIDF follower on a robot with high gearing

Quote:
Originally Posted by Oblarg View Post
This is better than simply measuring it on blocks and pretending there is no friction, but it is definitely worse than adding an intercept term and performing a linear regression with multiple data points to determine both the intercept and Kv.
Question,

How did you measure the points on this graph?


Was your robot up on blocks or on the ground? It seems like you would only get an intercept if the robot is on the ground.
__________________

2017 NEOFRA MVRC Winner with 2399 and 2252
2017 Steel City Showdown Winner with 2614 and 3260
2017 WOW Championship Finalist with 4145, 3138, and 3511
2016 Rachacha Ruckus Finalist with 5406 and 639
2015 Rachacha Ruckus Finalist with 1126 and 5406
2015 NEOFRA MVRC Finalist with 48 and 379
2015 Buckeye Regional Finalist with 48 and 5413
Team291.com
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 06:52 PM.

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