dronecrew / px4tools

PX4 flight analysis tools.
BSD 3-Clause "New" or "Revised" License
84 stars 48 forks source link

System Identification using the log data #19

Open SiddharthPatel45 opened 7 years ago

SiddharthPatel45 commented 7 years ago

As pointed out by @mhkabir I followed this thread to collect the data from the px4log file to perform System Identification of the tricopter. But, I am running into some difficulties and I think the sampling of the inputs I'm giving has something to do with it. I'm using my own MATLAB code following the Output Error Method to perform the system identification. Earlier, I was collecting the data directly from MAVROS and it didn't work out, probably because of the sampling time. In your python script "logsysid.py" I noticed that you resample and then interpolate the data before sysid. Why do you do so? If you could help me, would be a great help!

Thanks Sid

jgoppert commented 7 years ago

I would recommend you stay away from the matlab sysid toolbox. Sysid isn't baked to the point you can just send in data and it spits out a model. Plot your signals, you will see the inner loop after debiasing is just a pure delay and gain. Hope that helps.

SiddharthPatel45 commented 7 years ago

Thank you for your comments @jgoppert , yes that is helpful. But I would be grateful if you could answer a few specifics of my problem. First, I am not using the matlab sysid toolbox. I have written my own code for System Identification following the Output Error Method in which I give Inputs to the model I already derived for my system and I get a few Estimated Parameters as output. That's all. The problem where I'm stuck is my code produces output for simulated data but not for this real data which I collect from the pixhawk. As I said I was using MAVROS to store data earlier but it didn't work and I suspect that data sampling has to do something with it. So, I am now thinking to use the data I get from the px4log and perform sysid with it through my code. That is still feasible right? Can you help me on two things, if you can, please!

  1. Why and How do you do the interpolation of the data & time in your logsysid file? Do I need to do same before I use it?
  2. Is there a way to get data from MAVROS at a constant frequency. Currently it varies in the range of 48/49 Hz but I need more. Even with the px4log data I get is ~133 Hz but not constant. This means the time step is changing at every instant. Can we make it constant. See, I don't mind using data from any where. All I need is the 3 attitude angles, 3 angular rates and the Input PWMs. But I need to be sure that they are sampled at a known frequency so that I can use them for system Identification

Thank you again for all of your help and comments. I've been stuck for a long time and it would be great if you could help me on any of this. @mhkabir would appreciate a word a two for help from you as well. Adios!

jgoppert commented 7 years ago

Resampling is beneficial to estimate what the values were at the same timestamp, you can never get uinform sampling without post processing. You need at least 100 hz for data to get a decent fit. Why not try coding your method in python and comparing go mine. If it does better I would be happy to take a PR. I also do automatic pid gain tuning bases on the model for you in px4tools.

SiddharthPatel45 commented 7 years ago

That's great! But as much as I would like to do that, my project has a deadline to be honoured. And yes, I noticed you also evaluate PID gains, pretty useful. Thank you for all your comments though. I noticed later that the data is not recorded at a constant frequency so I need to make it at uniform timestamp, as you suggested. Maybe once my reports are done, I can share my results (If I'm able to get something, finally) with you and compare. Thanks again for all your help and will let you know if I'm able to solve my problem! Cheers!

SiddharthPatel45 commented 7 years ago

@jgoppert I've another question for you if you may. I did what you do but all in MATLAB code and not in the toolbox. Collected the data from logs, resampled them before using, but my system didn't behave correctly. I was later pointed out that there is a time_delay which also plays a role and I saw that your code also calculates the time delay and the PID gains. So, my question is

_What does this time_delay represent? Is it between the commanded input and the response time it takes for the UAV (or more accurately, motors) to follow? Because, then I was not taking any delay time into consideration in my code and maybe that's why it didn't work. You think this timedelay has that major of a role? And, even you collect the PWM signals and convert them in order to get the inputs, right? as there is no way to measure the actual inputs.

I would be really grateful if you could clear my query!

Thanks

jgoppert commented 7 years ago

Yes, the time delay has a major role. I'm not 100% sure what the cause is, gain and delay are the primary components of the signal. No, I don't use the PWM, I use the actuator controls topic, it is the pre-mixed input signal, it is easier that way, but should yield the same results.

SiddharthPatel45 commented 7 years ago

ok on everything, but I don't get how you use actuator control topic. And you get this data from the px4log? How exactly do you measure the input motor RPM? and thanks again