New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
enhancement: autopilot #310
Comments
Don't worry, I've not skipped this ticket! My time is limited and I haven't gotten round to reading and understanding your design yet. |
Sorry, but i do not know how long i will play with kRPC at this time, before my work gets me to switch off for a long period, and i can't answer anymore. So, any questions about my AP are welcome. The main idea, is to replace linear PID model with angular acceleration based PID model. Where proportional part is not a errorK but sqrt(abs(error)2/K)Ksign(error). The main problem of the classical PID, is that you trying to approximate constant acceleration moition (vt=v0+at^2/2) with linear law (vt=v0+at), that is wrong. |
Thanks for the graphs! It is possible I don't understand (I taught myself classical control theory when implementing the autopilot, and have no previous experience of the topic!) -- but I thought the kRPC autopilot does model constant acceleration using Also, the PID controller in the kRPC autopilot does not deal with acceleration. It tries to achieve a target velocity. This target velocity is calculated from the target pitch and roll (set by the user) and the moment of inertia and available torque of the vessel. The various tunable parameters then affect the target velocity that is passed as the setpoint for the PID. They control things like how aggressively you want the vessel to turn. Also with tuning, the default values should work for any vessel - in theory. They just control things like how much of the vessels available torque you want it to use to turn etc. From the graphs, it looks like the two autopilots basically work identically well, up until the point when the kRPC autopilot has been in a steady state for a while. This suggests that the dead zone (controlled by the attenuation angle parameter) needs increasing? I also wonder if this erratic behaviour could be caused by interaction between your target pitch/yaw code and the autopilot? PS. I've not had time to look through your code, so not clear how your autopilot actually works. When I have more time I'll see if I can understand it and then improve the kRPC autopilot. Also, do you have an example of a stock vessel and kRPC script that experiences the dodgy behaviour in those graphs. Would be useful if I could reproduce it. |
To properly control something, we need to represent this process as a mathematical model. Then build a control of this model. PID controls, is an approximation of underlaynig process model to a simple linear process. But this is a VERY BAD approximation of rigid body rotation process under an external torque acpplication. Command output of the controller is an angular acceleration term, so we need to deal with an angular acceleration in any way. And you doing this, but assuming somthing other instead of angular acceleration. The model of the system is (expanding partial derivatives differential equation):
This is how the vessel rotates about it's axis with respect to time. If we want to control ang_vel, we need to reverse this system with respect to it and command. That is:
and finally: But, in the original problem, we need to control not an ang_vel, but an ang_pos. We can rewrite body dynamics system for ang_pos as
THIS is an ideal control for the system, not the something you trying to approximate with linear function. And it is a background for my controller. Actually, we need to add disturbances compensation, command limit boundaries, near zero damping and normalize all gains.
I will make a stock vessel to reproduce and send a special version of my launch control with stock AP soon. |
Ahhhhhh!! It just clicked - now i understand what's wrong :) Thanks! |
Just swinging through to say @Assert1's graphs of the KRPC autopilot's behavior replicate my experience. |
+1 |
1 similar comment
+1 |
Seriously the auto-tuned autopilot doesn't work at all - I only tried it on planes so far, but it's unusable for them. |
I know, you are making an autotuned autopilot, but i can't use it, because of absence of some required features. I need a very pricies control over the vessel attitude and attitude rate in the space (or suborbital) flight to implement an optimum closed loop guidance algorithm. Even small discrepancy can produce a very large errors at the orbit attachment point. The main feature that i need, is an attitude control with an attitude rate augumentation. In other words, by attitude value and it's rate of change simultaneously to provide base trajectory, trajectory dynamics and corrections (for earth curvature as example). I need a good atmospheric control for badly controllable vehicles, and ability to make rapid and large attitude transitions without an overshot. So, a very long time ago (even before you was added inertial tensor computation) I am implemented my own model based autopilot with my own available torques and inertial matrix computation (it is replaced by yours for now). It is completly free of any autotuning, and have a few uniform and independent from the vessel gains, because it is based on the physics behind controlling process, and not on the plain PID (actually, this is PID where proportional part replaced with constant acceleration part). More over, it is not required to tune this gains for any vessel, it works very fine with default values, even with great delays (that have very bad impact on the closed loop control performance) introduced by kRPC. I am tested it alot with many ships in the atmospheric and vacuum flight phases. A small oscillations about zero point can occurs for some cases, but this is acceptable for me. The main advantage of my scheme is a very good time performance (nearly optimal) without any significant overshots even with very small available torques, and ability to provide target angular rates, that is absolutly required in my case.
So, i am uploading my sources, it uses my math library, but everything should be clear. I am also providing a simple model of the control law which i am used to investigate and tune the controller with respect to kRPC delays. It is very easy to implement my scheme. May be if you try it, you can get some ideas how to improve your autopilot, make it completly free from any tuning and add target angular rate augumentation. I've expect much better performance when it will be implemented on the server side (but it requries some retuning).
AttControl.h.txt
AttControl.cpp.txt
model.txt
Also, i have a problem with the engine cutoff. kRPC delays prevents me to accuratly stop the engines when i need this. It becomes a big problem for unthrottable engines that produces alot of thrust because even 0.1 delay can result a few kilometers orbit change. It will be very usefull to add an autothrottle system with an option to stop engines by reaching the specified speed.
The text was updated successfully, but these errors were encountered: