Now that I have system identification data, what do I do?

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:

  1. Set up chirp on any one axis to cover desired frequency range
  2. Get output data from flight
  3. Fit a fourth-order differential function with 2 zeroes and 4 poles to the input/output of this test
  4. Obtain a transfer function that defines the model of your aircraft
  5. Get optimized PID gains
  6. 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.

We have a simulink model that lets us see how the PIC controller looks like.

But yes, optimizing the controller is the part where a lot of creativity and coding skills are required.

BTW we plan to PR the simulink model in the next few days.

What repo will this be in? Can you please update us here when you do?

Ardupilot code repository. We will do a PR against the Copter-4.1 branch

Copter: Simulink model and init scripts by fbredeme · Pull Request #21747 · ArduPilot/ardupilot · GitHub here is the promised attitude and altitude controllers

3 Likes

What do you mean by different controller? @khancyr

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!

AFAIK this has already been fixed in ArduPilot master branch.

What branch are you using?

I am using the Copter-4.1 branch, so the problem just now will appear.

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.

I think this has been fixed in the Copter-4.3, Copter-4.4 and master branches

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)

The function is always a chirp and can not be charged, apart from frequency and amplitude

2 Likes

I’ve been studying this document: General ArduCopter Attitude Controller Description — Copter documentation

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.

The document I posted in the Wiki PR is AFAIK the most uptodate version. Other versions are outdated.

Can someone please share their thoughts? Will be so helpful… specially for my second question

Thank you in advance

No, not the rcouts. The outputs of the gyro sensors.

Thank you again for your support. Honestly, now I am more confused are you pointing at the PID’s output?

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.

1 Like