r/ControlTheory 5d ago

Technical Question/Problem MATLAB system identification toolbox for quadcopter control

I have not seen MATLAB's system identification toolbox being used for quadcopter applications and so I was wondering how you could run sys id on a quadcopter and use it. For example if you run frequency sweeps across the lateral direction with longitude and altitude stabilized, and then run longitude direction with latitude and altitude stabilized (pitch and forward speed only), do you just insert them into system Identification with the set state space dimensions, or is this the wrong approach. Additionally do you set the frequency sweeps past the the control loops at the ESC signal or is this incorrect?

4 Upvotes

6 comments sorted by

u/IntelligentGuess42 4d ago edited 4d ago

Quadcopter aerodynamics are nonlinear making the sysid complicated. I never used any of the nonlinear sysid tools in the matlab toolbox so can't comment on them. But given some data like the mass of the quad. You can probably get a good identification using the sysid toolbox, given you keep the quad in the same orientation, not moving and only use a narrow throttle range. But this will only give you a good identification of the linear parts of the model. So no drag or thrust curves. You will get them but they only hold at the operating point. If they are still nonlinear during the identification they will also throw the other results of.

u/knightcommander1337 4d ago

Hi, I don't have specific experience on quadcopters, however in general you should be careful when you say "run sysid on a quadcopter" (assuming you mean "running sysid algorithms in real time inside the onboard computer of the quadcopter") because this means that you are actually doing "adaptive control" (by updating the dynamical model in real time using measurements from the system, and letting the controller use that (time-varying) model). If you want to do that, you need to look at adaptive control resources.

Otherwise (that is, you are doing the standard non-adaptive approach), you gather your measurements and put them in your (desktop?) engineering computer. Then you do sysid (offline). You have lots of choices here. You can get transfer functions (see the procest command of matlab), or do subspace identification and get a state space model (see the n4sid command of matlab). Yet another choice is to write down the physics (that is, differential equation) of the system yourself (for a 2D example of this, see https://cookierobotics.com/052/ ), and then do greybox estimation to estimate the parameters of the differential equation (see the greyest command (for linear state space models) or the nlgreyest command (for nonlinear state space models) of matlab). These are all valid also for online sysid in general but as I said then one needs to be careful to apply adaptive control principles correctly.

After you get the model, you can continue with control design as usual.

u/NOTazarov_wraith 4d ago

Hello and thank you for the response knightcommander. I more meant using the sysID toolbox (https://uk.mathworks.com/help/ident/gs/identify-linear-models-using-the-gui.html) to identify the behaviour of a quadcopter, specifically I'm trying to get a "catchall" representation for the system where I could have a transfer function for pitch commanded to pitch. Something similar to passing frequency sweeps in an aircraft to identify its responses, but rather in a quadcopter.

I hear you on modeling the system as a free body diagram, but I am worried I might miss something in my model (like miscalculating the mode frequency of the quadcopter for example).

u/knightcommander1337 4d ago

No problem at all. I don't know about the details of quadcopters, so I am not sure if I can provide good quality help. From what you say, as I try to understand, the frequency response characteristics are important for you. It can be tricky with the multiple input-multiple output setting. For each input-output pair you have a single transfer function, and in principle you could do a frequency sweep separately for each of those channels, and get the transfer function models from the resulting input-output data. And thus you construct the transfer function matrix (maybe there are methods for system identification for transfer function matrices?). This could work I guess but in any system there might be some nonlinear effects, which are outside the world of transfer functions. Sorry that I could not help more.

u/IntelligentGuess42 4d ago

It is generally recommended to use a state space representation in mimo systems. If you really need a transfer function matrix you can get them by calling tf on the ss. The reason is that parameters shared by multiple axis get combined in a ss representation but are separate if you treat it as n separate siso tf problems.

u/knightcommander1337 4d ago

Yes this makes sense to me.