Creating a full hardware-in-the-loop simulator

If you want to create a full hardware-in-the-loop simulator, where a flight simulator program on your PC simulates the ArduPilot sensors and GPS while ArduPilot flies the plane in the simulator, you've got to have a pretty sophisticated bit of gear between ArduPilot and the PC. It needs to take the serial output from the flight sim and feed it to ArduPilot as GPS and XYZ sensor data, and then take the servo commands from ArduPilot and feed that back to the PC as joystick commands.

Jordi did it with some custom (and relatively expensive) gear here (using this ARM board), but it would be cool to have a cheap dedicated board that we could sell that would make it easy for people. We don't have time to develop this ourselves right now, but if someone wants to take a crack at it, the functional diagram is above. If you can design and test it, we'll manufacture it!

[Note: you can also design simpler simulators:

1) "Half-duplex": This is just the above diagram, but without the return loop of reading the servo outputs and sending them back to the flight simulator as joystick controls. In that case, you could put a "human in the loop" and just copy the rudder/aileron movements yourself, tilting the joystick to reproduce what the autopilot is doing. Not perfect, but better than nothing.

2) Navigation only: this is the easiest form and just requires the FTDI cable you already have. Just have the flight simulator send its GPS coordinates to the serial port, and ArduPilot will read them and think that's where it is. Once again, you can move the joystick to reproduce ArduPilot's steering and see how the system responds. No sensors or stabilization, but it's a good way to test navigation algorithms.]

Views: 4482

Comment by Garry Qualls on August 15, 2009 at 4:34am
Isn't decoding the PWM signals sort of missing the point of building a HILSIM? I had planned to use linear potentiometers to measure my Easystar control surface deflections (at the control horns) and convert those deflections back to stick and rudder deflections for FlightGear.

I think this would allow you to build the Sim part of the diagram on an Arduino Mega. The Mega would (1) parse data coming out of FlightGear and write GPS to serial for the Ardupilot, (2) parse the FlightGear data to turn yaw, pitch, and roll into fake IR sensor data, and (3) read the control surface/throttle servo deflections and convert them to inputs for FlightGear. I was planning to adapt Jaron's "UAV Playground" to make my connections to FlightGear. Let me know if I am missing something obvious...

Comment by wayne garris on August 16, 2009 at 11:43am
In doing some time at the google machine i came across this article on HIL sim . as for my own projects ive used this set-up with MSflightsim
Comment by I Heart Robotics on August 16, 2009 at 12:59pm
decoding the PWM signals should be fine since servos tend not to malfunction weirdly. If you were building your own digital servos then including them in the test loop would be important.

The only issues is trimming the system so that a given PWM signal produces a specific deflection in the simulator. That way you don't need to rescale the control gains for the actual aircraft.

That HITL article is pretty good. If the current PID loop update frequency is sampling the sensors at 10Bits and 50Hz, then my target is for a minimum of 12Bit output at 200Hz on the DACs that are simulating those sensors.

I am hoping I can find a good x-plane model of the Easy Star or the FunJET or that it is fairly easy to build an accurate aerodynamic model so the simulated wind effects it properly.

Comment by James Goppert on April 26, 2010 at 6:34pm
I'm a graduate student at Purdue University in Aeronautics and Astronautics and work in the Hybrid Systems Lab. We are developing a fully open source unmanned vehicle test-bed. As part of that development we have a lot of things that could help you guys out.

Flightgear - Scilab Communication for Hardware/Software in the Loop Simulation:
I just released this, should be just what a lot of you are looking for. It allows you to send flightgear a control vector and outputs the state vector. Now that i've figured out the C++/ scilab interface I'm hoping to implement automatic trimming via JSBSim and some other very cool features that should make autopilot design a breeze.

Easy-star model:
I just got an easy star and our group is working on using datcom+ to create a JSBsim model of it.

Hardware in the Loop Simulation, Ground Station Software, Autopilot:
Our current setup uses the arduinomega board since the Arduipilotmega is still in development. We are trying to parallel the Ardupilotmega development however and have found Jordi's ppm code invaluable. For hardware in the loop simulation we use another arduinomega as an emulator board to create gps and imu serial signals to send to the arduinomega acting as the autopilot. Our imu is the Razor9Dof and we use an em406 for gps. We have developed ground station software that uses osgearth to automatically load satellite imagery.

Feel free to contribute, all of our work is GPL v3 licensed.
We do all of our development on debian lenny, here is our deb repo (
Comment by Roy Brewer on May 1, 2010 at 12:14pm

This looks great! I'll definitely check it out

- Roy
Comment by Brian Mills on May 1, 2010 at 6:39pm

I'm a Commercial Flight Simulator Support Engineer in Tokyo Japan and I am very impressed with the projects you guys are working on. In case any of you want to use Matlab/Simulink, I developed a JSBSim SFunction that would be great to use for a HIL simulation for autopilot testing. In its current state the SFunction takes a single control vector and outputs various state and output vectors. Though it's (currently) more geared for examining and testing FDMs developed for FlightGear, with some addtions to the Simulink model it could definitely be a useful tool for anyone who is wanting to use Matlab for UAV autopilot development.

The project comes with nice GUI interface to set up the initial states and controls and I have just completed a trim function that I will fold into the project soon.

Here is a link to the project-

Feel free to download it and make any changes.

Comment by James Goppert on May 17, 2010 at 8:26pm
I ended up moving to scicoslab since it was more stable for controller design. Here is the result.\

3D Robotics
Comment by Chris Anderson on May 17, 2010 at 8:47pm
Nice one! How's that EasyStar model coming?

Comment by James Goppert on May 18, 2010 at 12:15pm
Well we haven't tested it yet, but we have the initial datcom output/ jsbsim model. I'll see how far I can get on the jsbsim interface for scicos this week. Here is the paper on the easystar datcom model.

Comment by James Goppert on May 24, 2010 at 1:53pm
Working on the jsbsim model for the easystar still. Using datcom+ with jsbsim is a bit tricky. Have gotten a visual model togther in the blender though. Shouldn't be long before this is flying in flight gear.


You need to be a member of DIY Drones to add comments!

Join DIY Drones


Season Two of the Trust Time Trial (T3) Contest 
A list of all T3 contests is here. The current round, the Vertical Horizontal one, is here

© 2018   Created by Chris Anderson.   Powered by

Badges  |  Report an Issue  |  Terms of Service