I have some custom code, which needs initialisation. I used the
Copter::setup() function (ArduCopter.cpp) to call my initialisation
functions, assuming that this function will be called after every power
cycle, since it is doing the basic system initialisation. But after some
digging around, I found the following: If I restart my Pixhawk (with all
the peripherals connected) by simply removing the power cord and plugging
it in again, the setup() function does not get called! I verified this by
sending a message to GCS through this function. The message reaches only
some times (e.g. when I command a reboot through GCS), but not when I
disconnect the power and reconnect.
Is my understanding wrong? Should I be using some other function to
initialise my custom code?
If you're connecting via a radio - are you removing power to the radio to?
If so, the radio modems probably aren't synced when going through the
Instead, to convince yourself you're going through the setup routine,
set a variable in setup() and send a gcs().send_text(...) in a 1Hz loop
containing the value of that variable.