Who does what in an ArduPlane/SIL<>X-Plane simulation?

Hello. I am very unclear about the partitioning of functionality between SITL and X-Plane, in the setup: Mission Planner <> ArduPlane/SITL <> X-Plane. When I use X-Plane by itself, I know that it is responsible for computing the physics of the flight as well as the rendering and animation. I also know that my X-Plane plugin can deliberately screw up the animation of the control surfaces without affecting the physics computations. And I can understand what Mission Planner is used for, but looking at what is exchanged between SITL and X-Plane, it seems that ArduPlane/SITL already does the physics and sends the results to X-Plane. How does X-Plane know that it should not do the physics? Or, does it not matter? I have tried to look into the ArduPlane/SITL code to get an idea, but it is just too complex. Using gdb to set breakpoints and examining stack traces is excruciating and feels like I’m groping in the dark. I’ll greatly appreciate any help getting some clarification in this matter. Thanks.

Hello,

I haven’t check on xplane. But generally, the external simulator does the physic and send it to SITL ( imu,speed, gps attitude, actuator position, airspeed etc.).
STIL use those data to pass them to the autopilot and add missing sensors from its simulation engine if needed.
The autopilot calculate the motor outputs. SITL send them back to the simulator.
And loop until you crash!

If you want to look on the code look in libraries/AP_HalSITL/ mainly in sitl_state.cpp for SITL loop and in libraries/SITL/SIM_Xplane.h/.cpp to see what data are exchange with xplane !

@Khancyr It is good to know that the external simulator (in this case, X-Plane) will be expected to perform all of the force, acceleration, velocity and position calculations. I don’t quite understand what you mean by SITL sending back “missing sensors” and “motor outputs”. I can see that SITL has to send the desired throttle ratio, pitch, roll and yaw etc., to X-Plane, which will then act on them as if they were pilot inputs. So, ArduPilot has to translate the high level mission commands/messages from MP into those bite-size things for X-Plane. Am I correct in my conjectures?! By the way, thank you for the quick response.