I am running a custom module to stabilize attitude of our STOL aircraft. The main loop function includes a printout block where I use the
PX4_WARN functions to send information about the state of the controller to my QGC Mavlink console every 2 seconds.
The attached flight log shows how at around 11:50 and 12:20 the custom module hangs for couple of seconds, stopping publishing to the actuator_controls_0, making the plane unresponsive.
Looking at the telemetry_status_0 topic, I can see that this coincides with a time when the TX rate went high for few seconds, assumingly blocking the printout block and hence the whole custom module loop.
Now besides of teaching me that the PX4_INFO and PX4_WARN are blocking, and as such probably not meant to be in the main stabilisation loop (shouldn’t there be a big warning about this in the documentation?), I would like to know what caused this sudden spike in the telemetry transmission rates. I don’t see any extra flood of messages in the log_message_0 topic that could have caused this, besides the regular PX4_WARNS every 2 seconds that I am sending.
Is there any way of telling from the logs why did that happen?
It has never happened before or after, the usual behavior is that I get a regular 0.12s hikup every 2 seconds during the prints that I never even noticed.
Also, what would be a correct way of implementing the printing function? A separate module monitoring the controller module state and doing the printouts? A non-blocking PX4_INFO implementation, such that we don’t need to wait for it to return? Or is there some timeout function to put around the PX4_INFO calls, such that if not completed within x seconds, continue?
Interestingly, if the telemetry signal is lost or disconnected, this is causing no issue to the controller.
Pixhawk 4, PX4 v 1.9