for a project at university I want to introduce a flutter signal into the control surfaces of a plane and then analyze the behavior. I aim for frequencies with at least 10Hz, so I’m running my script at 100Hz. The problem is that logging doesn’t keep up.
Here you can see a part of a log from a simulation I ran:
The blue line is my calculated cosine function, logged from inside my lua script. In orange you can see the value mapped onto a servo, so logged from ArduPilot directly.
At first it seemed to me, that the script couldn’t keep up, but then I just used gcs:sendtext and printed all the values to MissionPlanner, resulting in this graph:
Both graphs come from the same simulation run. So I conclude that the script is able to keep up, but the logging is the bottleneck.
How can I increase the rate? Especially the one coming out from Lua would be interesting, because then I could just log the required servo channels and don’t have to increase the logging rate of the whole RC-Out package, which is probably hard coded somewhere… Or should I just use the workaround of sending everything to the ground station and converting it to a csv manually?
Some more information: I’m using SITL Plane on dev through MissionPlanner on Windows and I set SERVO_RATE to 200Hz, LOG_FILE_BUFSIZE to 400.
I’d like to second this – I’m also trying to increase the logging rate of the RCOU values.**
Currently, they are logged at only 10 Hz, but I’d like to capture the PWM values (e.g. RCOU.C1) at 100 Hz for analysis.
Does anyone know how to achieve this? Any help would be greatly appreciated!
I’m skeptical of the above claim that writing text to the GCS at 100Hz was even effective. I’d be very curious what the X-scale’s time source was during that event. 100Hz is close to the upper limit for anything scripted, and I’d venture a guess that the first graph produced was more representative of script capability.
Depending on the type of ESC telemetry in use, ESC logging could be a bit faster and may be a better source for analysis than RCOUT.
If you want true 100Hz logging, you probably need to write a custom firmware patch. For faster RCOUT logging in the Copter branch, you’d move this line into the fast loop.
I can confirm that, in my servo testing rig I use H7 Ardupilot as control board and I observed some stutters in tested servos though I write to SD card file too so it might have been responsible for stutters.
I am not sure you will be able to induce flutter with ailerons as they act behind neutral plane.
If I remember correctly the problem in the end was just that the logging backend of sitl couldn’t keep up, once I moved to actual hardware I had no problems sampling at higher rates. But on my hardware I was able to run with more than 100Hz, I have to look for my data again, but I settled for an interval of 4ms in the end…
Edit here is the data: I scheduled the script with an intervall of 1 ms and logged the time between consecutive executions: