System Identification
Posted: Fri Nov 21, 2014 10:28 pm
Good day everyone!!
Let me tell you a bit about my project, before I start asking questions and suggestions
As the subject implies, I doing systems identification of multicopters being flown by me via a multiwii board. Why do I want to do this? I want to do very precise navigation algorithms using a motion capture system.
Systems identification is a statistical method to build mathematical models of the multicopters, to have excellent control we require a perfect mathematical model. In order to do a good sysid we require data, lots of data, data coming from the board as well as the pilot and the position in the space (motion capture), so, I require raw imu (accelerometers and gyroscopes), pilot commands (rc channels) and position (x,y,z).
So far, I have a position controller working with the multiwii board being flow by simulink using data from the motion capture system and just sending rc channels via a 3DR robotics radio (roll, pitch, yaw, throttle), you can see a video about that here:
[vimeo]https://vimeo.com/105761692[/vimeo]
I works nice... but I want it to work even nicer and better!!! so, we need all the mathematical models and parameters to be as precise as possible, ergo, systems id.
I knew that the 3dr radio was not good enough to send data in a fast way to the ground station... So, I put onboard a raspberry pie, this computer ask data to the multwii and also to the motion capture system, and saves it... thats it.
My code is written in python and everyone can have access to it: https://github.com/alduxvm/rpi-mw/
Its working nice... but its still not good enough, allow me to explain why.
The fastest I can go asking and then getting data is ~ 0.02 seconds, aprox 50hz, which is the PERFECT sample rate to do sysid... buttttttt I need MSP_RAW_IMU as well as MSP_RC, when doing that, I got a delay between each reading of ~ 0.06 which is 16hz... and NOT GOOD ENOUGH for sysid.
This is a sample of the data:
What I do in order to save data is as follows:
- Ask mw for raw-imu
- wait for the response
- save response
- Ask for rc channels
- wait for response
- save response
- repeat
The waiting response is fixed and its at the moment 0.02... if I do less I got garbage/corrupted data... So, first question, is there a way to improve this???
Of course a main issue is that I need to ask for raw and rc in a separate way, this makes more delay, so, I wanted to create a new message, one combining raw and rc... and looking at "Protocol.cpp" tells me the next:
//to multiwii developpers/committers : do not add new MSP messages without a proper argumentation/agreement on the forum
hehehe, of course, that do not stop me to test, so, I tried that, I modify this part:
and just a s_struct without headSerialReply... for the while
The problem with this is that I have a response with blank spaces... so, Im not sure if this is the good way to implement what I want, I´m getting something like:
Of course, I havent decoded the message yet, so, its in its pure form
... also, by any chance, has anyone use the module struct on python to decode this binary data?
Ok... So, added to this, I have very noisy accel data... almost useless for systid... Do the LPF on the MPU6050 that is configurable affects the accel as well? because it states that is for gyro.
So, I have 3 main issues:
- Improve the RAW_IMU and RC readings to be at least 50hz
- Make new msp message with RC and RAW to improve, without errors
- Filter accel readings (I´m testing next week a mechanical vibration dampening similar to the ones I use for APM)
Thanks a lot!!
So sorry for the long post.
Cheers!
Let me tell you a bit about my project, before I start asking questions and suggestions

As the subject implies, I doing systems identification of multicopters being flown by me via a multiwii board. Why do I want to do this? I want to do very precise navigation algorithms using a motion capture system.
Systems identification is a statistical method to build mathematical models of the multicopters, to have excellent control we require a perfect mathematical model. In order to do a good sysid we require data, lots of data, data coming from the board as well as the pilot and the position in the space (motion capture), so, I require raw imu (accelerometers and gyroscopes), pilot commands (rc channels) and position (x,y,z).
So far, I have a position controller working with the multiwii board being flow by simulink using data from the motion capture system and just sending rc channels via a 3DR robotics radio (roll, pitch, yaw, throttle), you can see a video about that here:
[vimeo]https://vimeo.com/105761692[/vimeo]
I works nice... but I want it to work even nicer and better!!! so, we need all the mathematical models and parameters to be as precise as possible, ergo, systems id.
I knew that the 3dr radio was not good enough to send data in a fast way to the ground station... So, I put onboard a raspberry pie, this computer ask data to the multwii and also to the motion capture system, and saves it... thats it.
My code is written in python and everyone can have access to it: https://github.com/alduxvm/rpi-mw/
Its working nice... but its still not good enough, allow me to explain why.
The fastest I can go asking and then getting data is ~ 0.02 seconds, aprox 50hz, which is the PERFECT sample rate to do sysid... buttttttt I need MSP_RAW_IMU as well as MSP_RC, when doing that, I got a delay between each reading of ~ 0.06 which is 16hz... and NOT GOOD ENOUGH for sysid.
This is a sample of the data:
What I do in order to save data is as follows:
- Ask mw for raw-imu
- wait for the response
- save response
- Ask for rc channels
- wait for response
- save response
- repeat
The waiting response is fixed and its at the moment 0.02... if I do less I got garbage/corrupted data... So, first question, is there a way to improve this???
Of course a main issue is that I need to ask for raw and rc in a separate way, this makes more delay, so, I wanted to create a new message, one combining raw and rc... and looking at "Protocol.cpp" tells me the next:
//to multiwii developpers/committers : do not add new MSP messages without a proper argumentation/agreement on the forum
hehehe, of course, that do not stop me to test, so, I tried that, I modify this part:
Code: Select all
case MSP_RC:
headSerialReply(RC_CHANS*2+18);
s_struct_s((uint8_t*)&rcData,RC_CHANS*2);
s_struct_s((uint8_t*)&imu,18);
break;
and just a s_struct without headSerialReply... for the while

The problem with this is that I have a response with blank spaces... so, Im not sure if this is the good way to implement what I want, I´m getting something like:
Code: Select all
40 $M>"i????????????]??l?????
40 $M>"i??????????????u??x?p?
40 $M>"i????????w???|$?x?p?
40 $M>"i????????]#_?'?x?p?
40 $M>"i????????>(4??y???)???j
40 $M>"i????????4=*?U??)???o
40 $M>"i????????
+?????)???^
40 $M>"i??????????????J?4???8??p
40 $M>"i????????????????0???8???
40 $M>"i??????????T???????8???
40 $M>"i????????P??Rg?????R?
40 $M>"i????????;d????m????R0
40 $M>"i????????ul?????????R?
Of course, I havent decoded the message yet, so, its in its pure form

Ok... So, added to this, I have very noisy accel data... almost useless for systid... Do the LPF on the MPU6050 that is configurable affects the accel as well? because it states that is for gyro.
So, I have 3 main issues:
- Improve the RAW_IMU and RC readings to be at least 50hz
- Make new msp message with RC and RAW to improve, without errors
- Filter accel readings (I´m testing next week a mechanical vibration dampening similar to the ones I use for APM)
Thanks a lot!!
So sorry for the long post.
Cheers!