I am not a control theorist but I have been reading some books/theses on this technique. Here is what I understand about using this method so far:
Set up chirp on any one axis to cover desired frequency range
Get output data from flight
Fit a fourth-order differential function with 2 zeroes and 4 poles to the input/output of this test
Obtain a transfer function that defines the model of your aircraft
Get optimized PID gains
Validate new PID gains with another and/or same set of maneuvers
The part I am unsure about is how one is to get the optimized PID gains and ATC_RAT_RLL_FLTx parameters from the derived transfer functions like @amilcarlucas has done here. MATLAB has toolboxes that help with this but I need to know what type of PID controller is being used here and how those filter parameters are to be calculated.
Hello amilcarlucas.Your piece of work is really great, it helps me understand very quickly how the attitude controller and height control actually work. Recently, when I used your simulation to verify the accuracy of my aircraft mathematical model, a problem occurred: the function ‘fromAxisAngle’ was missing when the sid_sim_init.m file was running. If you see my message, I look forward to your reply. Thank you so much!
Thank you very much for your reply! I accidentally deleted the question I asked just now, and I will add my question again, so that people who have similar problems can refer to it: when running the sid_sim_init.m script, the ‘dcmFromEuler’ and ‘fromAxisAngle’ functions are missing. Indeed, as you said, this problem has been fixed on the master branch, and I saw the newly added functions: ‘dcmFromEuler’, ‘fromAxisAngle’, ‘quatMult’. Thanks again for your reply.
You’re right, I should have checked the new branch or the main branch first. Currently, I’m using the Simulink from the main branch, and the problem with the missing function has been resolved. However, when I run “sid_sim_init.m”, I encounter an error message saying “Unrecognized field name ‘ThrAvMx’” on line 371 of sid_sim_init.m. The line of code causing the error is “simIn.signals.MOTB.ThrAvMx = single(sid.MOTB.ThrAvMx(iVec)); % Throttle average max”. Could you please help me locate the issue? Thank you very much for your help.
My LOG_BITMASK value is 661503, isn’t it supposed to be 135923? (The README.md says: A dataflash log of a test flight with the following LOG_BITMASK: 135923)
Given the more detailed diagram you’ve displayed - is this document in the wiki still correct?
As you might have seen in my other post on the subject, I was glad to see how _FLTT, _FLTE and _FLTD fit into the system - and I’d like to understand if and how they may need optimization.
There are two settings (FAST ATTITUDE and MEDIUM ATTITUDE) in the LOG_BITMASK that are used to define the logging rate of the RATE, PID, ATT, and SIDD data. The wiki on SYSID mode explains what the sample rates are for the various combinations.
It depends on what you are trying to model using the data. If you are modelling the bare aircraft dynamics then the input would be the outputs to the motors class (RATE.Rout, RATE.Pout, RATE.Yout, and RATE.Aout) which are the Roll, Pitch, Yaw and throttle requests to the motors library before the thrust linearization and distribution of outputs to the motors based on the mixing for the frame type. The output for the bare airframe dynamics would be the gyro outputs which are captured in the SIDD message.
If you were going to model down at the motor output level, that becomes more involved and you would probably need to change the code to be able to log data of the RCOU data at a faster rate because it is only logged at 10 hz currently. That is really not how the system ID mode was designed to be used. Not saying that it couldn’t be used that way but like I said, you would have to modify sample rates for the RCOU message.
You would only need RATE.Rout. It is the input to the motors class and contains the chirp.