SITL X-plane - mapping servos to datarefs?

I’m currently having a hack at the SITL code to see if I can map the servos to various control surfaces within X-plane via using dataref UDP packets to drive individual features as if they were actual servos rather than the current send data method.

I’ve managed to get some data into X-plane to configure the overrides I need but I’m struggling to get my head around how the servo mapping works and how I can know what each mapped servo PWM value might be.

Is there a variable I can peek at to do this? I’m seeing the input.servos[x] parameter as it’s used in the Xplane::send_data routine but this code beginner numpty can’t figure out how that traces back to where it is defined.

Any clues here?

OK, so I think I’ve leaped that hurdle. Now pumping data from an improperly configured servo array into X-plane, so that’s a success! I just need to figure out how to map the servos correctly. Despite being configured in the .parm file and re-loaded, SITL is adamant that channels 0-3 are aileron, elev, throttle and rudder…

Well, that last bit was caused by SITL overwriting my .parm file. Traps for the unwary there! Now I have “mapped” all my SITL psuedo-servos to wiggle the appropriate control surfaces within X-plane! Very happy bunny tonight. Just have to climb Mount Quadplane Configuration tomorrow…

Hi @Andrew_Rabbitt, I have the same issue as you. Can you explain, how you connected the servos correctly via the datarefs?

All the secrets are hidden in SITL_XPlane.cpp
under the
void XPlane::send_data(const struct sitl_input &input)

There are two methods I use - either a data frame (can’t remember the official X-Plane terminology right now) which stacks groups of similar variables together or as a data ref which is one parameter at a time.

Look in

…\X-Plane 11\Instructions\X-Plane SPECS from Austin\Exchanging Data with X-Plane.rtfd

for information on how the data frames and data refs are structured.

Then, I calculated the appropriate variable from Ardupilot and scaled it suitably for X-Plane’s consumption and beamed it back to X-Plane via a data frame or a data ref such as:

d.code = FlightCon;[0] = elevator;[1] = aileron;[2] = rudder;[4] = rudder;
socket_out.send(&d, sizeof(d));

or using the send dref subroutine:

send_dref(“sim/flightmodel/controls/flaprqst”, flap);

Let me know if this makes sense or if you have any more questions. I’ll try to help you on your way.

Kind regards,


1 Like

Sounds very helpful. Unfortunately i am not able to reproduce your explaination. So it would be nice, if you can support me. Therefore I will explain you my problem at first:

I want to simulate a autonomous flight with XPlane and MissionPlanner as GCS. For this I have created a hybrid drone (quadplane) with PlaneMaker. I can fly my drone with missionplanner and can control the altitude, speed, direction… But the problem is that MissionPlanner is only controlling my hub rotors and is not carrying out any transition. So MP can not trigger my pusher rotor (picture below, my pusher is throttle_5).
Therefore I want to map my servos to datarefs in XPlane like you did it. Maybe you can tell me how to change SITL_XPlane.cpp so I can control four hub rotors and a pusher in Xplane. And how do I include SITL_XPlane.cpp in Arduplane again? Unfortunately I don’t have any programming experience, so an explanation at primary school level would be great.

Thank you in forward and best regards,



@Lars_Wagner, I suspect you’ve not set up a throttle channel for conventional wing-borne flight which is why there’s no forward thrust. I haven’t played about with a separate-lift-thrust (SLT) VTOL so I am not so familiar with this configuration. You should consider setting it up as a conventional fixed-wing aircraft first and then add the quadplane features. I don’t think adjusting the SITL code is necessary for you at this stage.

Edit to add: some further digging suggests you need your thrust motor servo output to be configured as ID 70 rather than the (presumably) 37 you may have it set to. Quad motors should be 33 thru 36, I’m guessing.