Scope and Syntax of SITL Instructions among ArduPlane, Jsbsim, Flightgear

Could someone be kind enough to explain how ArduPlane, Jsbsim and Flightgear interact in a SITL simulation?

Is MavLink the only outbound and inbound instruction language for ArduPlane?


Here is what I think is going on, but I would like someone to confirm as it may shed light on an underlying issue that I am trying to solve.

At each instance of the simulation time loop,

  • ArduPlane sends instructions at control surface and/or servo level to JSBSim or whatever DFM there is.

(What do these intstructions look like, how can I track them down?)

  • JSBSim / DFM adjusts the vehicle control surfaces. Then it runs the aerodynamics and 6 degree of freedom body dynamics calculations and obtains a new vehicle attitude, displacement, velocity and rotation rates.

(What do these intstructions look like, how can I track them down?)

  • JSBSim / DFM sends the new state information to ArduPlane and potentially to a Flight Simulator (i.e. Flight Gear) which update the vehicle position and attitude in the global coordinate system.

REPEAT ABOVE

I use ArduPlane, Jsbsim and Flightgear for SITL and simulations run smoothly, but without any control surface movements. This used to be an esthetical concern, but now I need to visualize things for debugging purposes.

So I am trying to track down what servo or control surface instructions arrive at JSBsim or Flightgear, so that I can map them to control surface positions within FlightGear. So far, I only see the throttle values updating and the vehicle flies as expected - which confirm that instructions are arriving and the loop is healthy…

I tried to track down what the ArduPlane instructions for aileron, elevator and rudder or rc1, rc2, rc4 look like using a linked Mission Planner, but the effort has been fruitless.

There is absolutely nothing broken in the way SITL works and my pain point is the inability to see the type and syntax of the instructions that flow among the 3 software packages (4 with the mission planner). I tried to utilize and play with an old protocol Mavlink.xml that @Tridge had prepared for HIL with Flightgear, but it doesn’t seem to change anything (https://ardupilot.org/dev/docs/flightgear-hardware-in-the-loop-simulation.html). Clearly it is for HIL, not SITL…

Any insight would be greatly appreciated. I will contribute what I learnt and was able to implement with success on wiki pages.

For SITL inputs and outputs to external simulators, ArduPilot uses different protocols for each simulator. The source code over at ardupilot/libraries/SITL at master · ArduPilot/ardupilot · GitHub details this.

For the specific case of JSBSim (with default parameters):
Control surfaces ArduPilot → JSBSim is transmitted over port 5505
Vehicle location/attitude JSBSim → ArduPilot is transmitted over port 5504

For visualisation in FlightGear, port 5504 is used as well.

The data format that JSBSim sends to ArduPlane & Flightgear is defined in ardupilot/libraries/SITL/SIM_JSBSim.h at master · ArduPilot/ardupilot · GitHub

Hello Stephen,

The problem magically resolved itself when I increased the frequency of communication from the typical 10hz to 30-60hz on the following standard call options to FlightGear:

–native-fdm=socket,in,30,5503,udp ^
–fdm=external

I also added the following line in the body of the main Jsbsim xml file for the aircraft’s flight model (ie Rascal.xml)

output name=“localhost” type=“FLIGHTGEAR” port=“5503” protocol=“udp” rate=“30”/>

I think these changes should be part of the standard .bat and .py scripts in the SITL folders and Rascal’s flight model in ArduPilot.

That’s great! If you can, it’d be worth putting in a pull request for these changes.

This is a relatively old post. Anybody have a step-by-step process for running Ardupilot with FlightGear? I can get it somewhat working, but any model that I use seems to fly like a small drone (i.e. with a speed of about 20 m/s). I don’t think I have the connections right, and the documentation for this is not complete. Any help would be appreciated.

I had same feeling, some kind of delay, but I am not sure exactly what happened. It is not a long time I have been playing with FG<->SITL setup. under Windows it works, under LInux everythin seems ok, but they do not communicate, I get no errors, and fgfs by itsekf works, arducopter connects to QGroundControl, OSD is OK, map and console modules OK. may be some ip port issue, but I do not know where to start investigation from (no errors shown …), may be I try to change udp ports …I used arducopter and flightGear script sh files for installation and build. Everything was ok (LInux Ubuntu 23.10). Who knows ? …
Alfredo