I am new to all of this, and am trying to make sense of the code.
What I can’t understand is, what is the main code that runs? All the cpp files have function declarations only. There must be a main function that calls all the functions right? If yes, where is that? If no, can someone give me an overview of how the codes are linked to each other? As in when I go from GUIDED mode to say RTL, how does the transition in code take place?
ArduCopter is a multithread code, in ArduCopter.cpp you have the setup and the declaration of the Scheduler, and there you can see all the threads available, their frecuency, and their máximum time.
To answer your question, when you change the flight mode from GUIDED to RTL, the “flight_update” thread is the one in charge of doing all of that. (You can see what it does in “flight_mode.cpp”