|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools | Rate Thread | Display Modes |
|
#1
|
||||
|
||||
|
Drivetrain PID tuning
Today, I was encouraging my rookie programmers to utilize the NavX to experiment with PID Control in order to make our robot drive straight. Given that we've never done this in a season, one of the things that crossed my mind is how we should deal with the differences in CoFs between our lab's carpet and that of a true to life field. What have other teams done to account for this? Have you guys just purchased carpet, and just calibrated it on that? What would you use to re-tune your loop at competition?
Thanks so much! |
|
#2
|
|||||
|
|||||
|
Re: Drivetrain PID tuning
Sensitivity to carpet variation is somewhat dependent on your drivetrain geometry and dynamics. A 6 wheel drive, dropped-center robot with a roughly central CoM and hard wheels is going to turn pretty similarly on a wide variety of floor surfaces. Meanwhile, a 4 wheel drive robot with a long wheelbase and pneumatic wheels may scrub quite differently depending on carpet.
Ideally your PID algorithm can be tuned to compensate for various types of floor conditions (after all, well-worn vs. brand new field carpet can be quite different in its own right!). If you are able to control your robot on a couple different types of surfaces at home (including whatever you have that is most similar to the field surface), you ought to be good when you get to competition. |
|
#3
|
|||
|
|||
|
Re: Drivetrain PID tuning
We're able to get pretty good straight driving using only the P term with the navX, so that may be worth trying. As for carpet, a local store gave us a 5x12 foot square of the official carpet (different color though).
|
|
#4
|
|||||
|
|||||
|
Re: Drivetrain PID tuning
Quote:
As far as color, if you insist on the right color, you'd need a new piece (or two) of carpet each year. |
|
#5
|
|||
|
|||
|
Re: Drivetrain PID tuning
Things to watch out for when doing this, based on personal experience:
1) It is very hard for a loop to keep you driving straight at max speed, because if your motors are saturated you can only slow down one side to adjust, rather than both slow down one side and speed up the other. If you give yourself some headroom, it will work much better. 2) Unless you are using cascading control (i.e. feeding the output of your heading loop to a wheel velocity loop), it is likely that you won't be able to make the p gain high enough on the heading loop to make steady state error acceptably small without introducing instability. A quick and dirty fix for this is to simply add or subtract some minimum output to/from the calculated heading loop output whenever it is outside of some tolerance around 0. |
|
#6
|
||||
|
||||
|
Re: Drivetrain PID tuning
Quote:
1.We do a quick system id on the yaw axis a. Apply a moderate amplitude yaw step (usually 1/2 max input on whatever yaw command input you have) b. Model the angular rate output with the equation rate = input*k*(1 - exp(-t/tau)) 2. design a controller using the following architecture; error = (yaw_cmd - yaw_rate) motor_cmd = PID(error, Kp, Ki, Kd) where: Kp = gain/K*tau Ki = gain/K Kd = 0 gain = 5 to 10 (arbitrary, desired bandwith in rad/sec); 3. Vary gain to get the command response you want. We start at 10, and if it's too sluggish bump it up, if it oscillates or limit cycles (bounces back and forth due to backlash) we back it off. Sorry for the terse explanation, but that's pretty much it. We do all our own code, so the PI controller is just written into the yaw service function. Sorry I don't have the code right now, but I can find it. Cheers, Steve. |
|
#7
|
||||
|
||||
|
Re: Drivetrain PID tuning
Can anyone explain to me why so many teams use gyros for driving straight instead of encoders?
|
|
#8
|
||||
|
||||
|
Re: Drivetrain PID tuning
Quote:
*aka "math" Last edited by Ty Tremblay : 28-12-2016 at 10:48. |
|
#9
|
|||||
|
|||||
|
Re: Drivetrain PID tuning
Quote:
Once the wheels have slipped against the carpet/floor/obstacle and you don't know how much, you can't reliably use the encoders (by themselves) to determine orientation. Gyros have more drift, but are not subject to this sudden loss of calibration. |
|
#10
|
||||
|
||||
|
Re: Drivetrain PID tuning
Quote:
David |
|
#11
|
||||
|
||||
|
Re: Drivetrain PID tuning
Quote:
Last edited by SamcFuchs : 28-12-2016 at 11:13. |
|
#12
|
||||
|
||||
|
Re: Drivetrain PID tuning
Sure you get a number that represents your angle, but if you're trying to go a predetermined distance, encoders make corrections much easier.
|
|
#13
|
||||
|
||||
|
Re: Drivetrain PID tuning
How do you accomplish this? Do you just set your setpoint proportional to the position of the stick?
|
|
#14
|
||||
|
||||
|
Re: Drivetrain PID tuning
Quote:
Code:
Robot.drivetrain.arcadeDrive(DriveForwardSpeed, (Robot.drivetrain.getGyroAngle().getAngle())); Code:
Robot.drivetrain.arcadeDrive(-DriveForwardSpeed, (-(Robot.drivetrain.getGyroAngle().getAngle()) * Kp+.1)); |
|
#15
|
|||||
|
|||||
|
Re: Drivetrain PID tuning
You can definitely do motion profiling with a gyro.
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|