I have inherited of a flight dynamics simulation in C++ which represents a small drone with it's autopilot, actuator dynamics and a solid state IMU.
Hence, it is composed of a few models, some continuous (flight dynamics & actuators), integrated with a runge kutta 4 scheme, some discrete (the autopilot and IMU). I have full control over the physics timestep. The autopilot is supposed to run at 500hz, the solid state IMU at 2000Hz.
I am to find a "correct" time step value in order to minimize errors while maintaining a reasonnable conputationnal time.
I tried plotting the difference in mechanical energy between the highest frequency i ran the model at (16Khz) and the others simulations (500hz, 1000hz, 2000hz, 4000hz, 8000hz) I have selected these frequencies in order for the simulation to step precisely on the "activations" of the autopilot and IMU.
I did the same on a L2 norm composed of the flight dynamics state variables (speed, position, rotationnal speed and euler angles).
The results were very different from what i would have expected:
While the errors seem acceptable (errMax ~ 0.3% ), i do not understand why there is such an increase in error around the 2000 / 4000hz point. Also, the errors dont seem to decrease with the time step. This leaves me quite puzzled on the relevance of my approach.
Would anyone know any reason that could cause an increased error around a specific time step in a simulation that mixes continuous and discrete state models?
Also, is there any kind of relevant physical analysis that would allow one to get a norm that accurately represents a simulation state (in order to study the convergence of said simulation)