I’m trying to create a process to validate that the system dynamics of the attitude controller is the same in SITL and physical hardware.
For the SITL side I am using the MATLAB/JSON interface to simulate the body rotating. I noticed some unwanted randomness on the angle reported in the GCS so I dropped the RND parameters for attitude sensors to zero. That model is available here. I’m still working on it, but this version helps illustrates the issue I am having so far.
For the physical side I have a Cube Black on its own (nothing except USB plugged in) that was calibrated against a flat table. I made a rocking block to make setting the angles easier and snappier to emulate what the SITL model does. I can hold the block flat on the table and then pivot it to the angle that want without having to read anything on the fly.
All parameters relating to the attitude controller (or as far as I can read from the code) and the scaling there of were kept the same (ARSPD_USE=0). Arming checks passed and flight modes were kept to FBWA. The curious thing is that the servo outputs are different. Tridge made a comment about the controller be rate based so to double check myself I cut the rate that the SITL model was using to reach the desired attitude by 4 and got the same result at steady state.
Here is SITL rolling to 15 deg at 200 deg/sec max rate.
Here is SITL rolling to 15 deg at 50 deg/sec max rate.
Then here are the physical tests. I did the same thing twice to check my sanity.
First physical test.
And the second physical test.
The angle that the physical test gets to isn’t the most consistent or a very clean input signal, but I am working on that. The bigger issue that I am seeing is that the STIL servo output is more than double that of the physical for nearly the same input signal.
Logs that each of these plots were created from are here.