![]() |
Tuning PID Constants Over a Range
Our team is trying to impliment PID for autonomous driving/turning, however we are struggling on tuning the constants. We have been using 1114's suggested method of tuning kP, kD, then kI, and we have been successful for tuning a single value.
For example we can tune gyroTurn(5) to turn 5 degrees, but those constants don't work for gyroTurn(25). Are we doing something wrong? or are we supposed to create different sets of constants for ranges of the angle? |
I am by no means an expert with PIDs, but in this I would suggest turn down the I constant. I ramps up over time, so with the greater degree of movement, it takes longer for the PID controller to get to the target value. Therefore, the I constant may get too high.
Sent from my SM-N920G using Tapatalk |
Re: Tuning PID Constants Over a Range
Could you clarify what you mean by "didn't work"?
Was the response not fast enough or did it never reach the intended goal value? |
Re: Tuning PID Constants Over a Range
Quote:
|
Re: Tuning PID Constants Over a Range
Quote:
|
Re: Tuning PID Constants Over a Range
We clip our motor power at 0.7, but this would not be slow enough for smaller angles and if we clip the power lower, the larger turns would be slower than desired.
|
Re: Tuning PID Constants Over a Range
Quote:
This year, we ended up having different turning/yaw control PID values based on if we were moving forward or not. |
Re: Tuning PID Constants Over a Range
Quote:
While we're at it, the following information would be helpful: What type of drivetrain do you have? How many/which drive motors power the drivetrain? What is the minimum throttle value which allows the robot to turn in place? What is the maximum achievable angular velocity of the robot? |
Re: Tuning PID Constants Over a Range
This is likely a static friction problem, and the easiest solution I've found to deal with it is to implement a "minimum output" parameter that roughly corresponds to the smallest motor voltage which will result in actual movement. Then, you change your PID response so that the magnitude of the output is never less than that value, e.g. you can just add the value (with the proper sign) to any output, or you can simply set any output that is too small to the minimum value (again, with the proper sign). I think the former behaves somewhat better, but both work.
You can also implement cascading control, where the output of your angle PID is fed to a velocity PID for the wheels instead of directly to the motors. Thus, the internal PID loop will account for the problem automatically (provided it is tuned correctly). You also really should not need an I or D term for a turn-to-angle loop. |
Re: Tuning PID Constants Over a Range
Something that also helps in making small turns is to move forward slightly while turning to the set degree.
|
Re: Tuning PID Constants Over a Range
Quote:
I don't think you need to go to cascading control here. That sounds more complicated than needed. We run statespace controllers, but the only real difference between a SS controller and a PID loop is the improved filtering on the velocity term. Our heading controller works very well. The first thing I tell people who ask me about tuning controllers like this is to start plotting things. With time as the X axis, plot left power, right power, right - left position, and gyro heading. You'll learn a lot from those plots. Feel free to post them as well if you want some more feedback. Backlash in your drivetrain is also important. If you have too much backlash, you will hunt around the goal. A small move will stabilize because you don't get moving fast enough to need to flip to the other side of the backlash in order to slow down. What frequency are you running your control loops at? Are you using the WPILib PID loop or your own? Too slow a loop time, or running the controller in the joystick code can cause a lot of problems. Consider also adding in a motion profile. You can do a constant velocity profile, or try a trapezoidal profile. This will give your controller a bunch of small moves in a (more) feasible path which will be a lot easier to follow. We do trapezoidal motion profiles for all of our movements. OP: From your profile, it looks like you are in the Bay Area. If the timing works out, 971 would be happy to chat in person with you guys, and take a look. |
Re: Tuning PID Constants Over a Range
Quote:
|
Re: Tuning PID Constants Over a Range
Quote:
While your statement is true, we have found that simply putting a motion profile on your input will eliminate the need for cascading control. To me, the motion profile (whichever you choose .. we use trapezoidal acceleration) is a more pure way to do it. We all know that if you give a step input to a motor it really doesn't behave that way so why not give it an input it really can perform. 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. Paul |
Re: Tuning PID Constants Over a Range
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 :P) 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. |
Re: Tuning PID Constants Over a Range
Quote:
|
| All times are GMT -5. The time now is 05:10 AM. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi