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: 4840

Comment by Ryan on August 13, 2009 at 11:09pm
Nice work!
Comment by I Heart Robotics on August 14, 2009 at 12:41am
Ok, I'm sold on implementing this but it looks like a month or two of work.
I guess I'll order X-Plane and an ArduPilot tonight.

What percentage of people use an IMU vs horizon sensors?
Also, have you windtunnel tested the airspeed sensor?
Comment by Sarel P. Wagner on August 14, 2009 at 12:57am
Would it be possible to make the SIM side compatible to FlightGear, its a freeware application rather than X-Plane being commercial?
Comment by I Heart Robotics on August 14, 2009 at 1:04am
Well, personally I think that X-Plane is by far the best simulator for this type of thing. It is a really accurate simulation and API to interface to it is reasonable. Also I am planning on using it for one of my other projects.

On the other hand, I'm open to supporting FlightGear if it is not too much extra work.
Comment by Sarel P. Wagner on August 14, 2009 at 1:19am
Thank you for looking into this, soem information that may assist here:

Comment by Sarel P. Wagner on August 14, 2009 at 1:27am
Here is a link that may help explain further:
Comment by Marty on August 14, 2009 at 3:36am
Don't forget Michal B's approach for X Plane using only the FTDI cable, the Ardupilot (running modified code) and his program.
Comment by Roy Brewer on August 14, 2009 at 4:53am
I am considering creating a completely open source simulator using Scilab (a Matlab clone) to run the airframe dynamics and initial control code and Flight Gear for the graphics. Eventually, I'd move the control code to the controller board and just have Scilab simulate dynamics with the hardware in the loop. I'd also like to have Scilab & flight gear running on the same computer, if possible. This way a second laptop could be running the ground station s/w, communicating only with the controller board via zigbee. I know Scilab has been used for similar HIL applications. I just haven't seen it interfaced with FlightGear.

I know that a few ARM chips exist that should have plenty of PWM I/O for this interface board. A few even have analog out capability, but I don't think they have 6 d/a outputs to emulate a 6DOF analog IMU .

- Roy

- Roy

Comment by crystal garris on August 14, 2009 at 9:34am
Here is my suggestion to make it cheap . write a "sim" program for the aurdo pilot itself that has the same algorithm but gets "sensor data" from a single high speed connection to the PC.when you want to sim you simply re-flash .this is how cloud cap does it but the AP goes into a different mode instead of re-flashing it and they use a CAN connection.
Comment by I Heart Robotics on August 14, 2009 at 11:14am
I think trying to do it on the same hardware will cause more headaches then it is worth and make debugging a nightmare. The hardware itself should not be that expensive.


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

Join DIY Drones

© 2019   Created by Chris Anderson.   Powered by

Badges  |  Report an Issue  |  Terms of Service