Where is Arducopter entry point

Hi everyone,

In version 3.2 when the source code still uses Arduino, the entry point could be found in loop(), which then calls init() and the fast_loop() functions. Then the source code moved to C++, but no main function was found, so I cant find the way how the init() and fast_loop() functions are called. I searched in the forum, but cannot find. It is so strange that such a popular topic like this was not discussed. I highly appreciate if anybody can explain me where is the entry point of the Arducopter.

1 Like

chase this define up:


Hi Peter,
Thank you very much for the help. I’m now reading the document, but it seems that things are clear now.

Hi Peter,
I saw how setup() and loop() are defined and called, but I still haven’t seen how fast_loop() is called.

fast_loop is a terrible idea and should die :slight_smile:

I still don’t understand. Line 249 checks if _fastloop_fn variable is true then calls _fastloop_fn() function. So my question is that _fastloop_fn is variable or function?

_fn is typical of symbols that you might not expect to be a function
pointer actually being a function :slight_smile:

So yes, it’s a function. It’s passed in in the Scheduler constructor. In
Copter’s case, here:

Note that adding stuff to the fastloop function is almost certainly not
what you need to do.

Perhaps if you outline what you’re intending someone might suggest how to
get your code being called.

Thank you for your help and time. Actually I don’t have any concrete intention. I only want to understand the way Arducopter is programmed so that I can learn how to do if later I meet a similar case. But when I try to access the link you provided, I met with 404 error. Can you provide me with another link? Thank you in advance

Hi Peter,
I have a look at copter.h and may be this is what you have talked about

// main loop scheduler
AP_Scheduler scheduler{FUNCTOR_BIND_MEMBER(&Copter::fast_loop, void)};

Am I right?

My bad, sorry. Fixed link:

in libraries/AP_HAL/AP_HAL_Main.h

the macro expend to:

int main(int argc, char* const argv[]); 

Why this is main? where is the entry function setup() and loop() defined?