3D Robotics

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.]
E-mail me when people leave their comments –

You need to be a member of diydrones to add comments!

Join diydrones

Comments

  • Hi,

    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-
    http://dl.dropbox.com/u/5284957/JSBSimGUI_SFunction_042810.zip

    Feel free to download it and make any changes.
  • Developer
    I'm a graduate student at Purdue University in Aeronautics and Astronautics and work in the Hybrid Systems Lab. http://www.purduehsl.dynalias.com/ 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:
    http://forge.scilab.org/index.php/p/aerospace-toolbox/
    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:
    http://sourceforge.net/projects/oooark/
    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 (http://hsl.dynalias.com/debian).
  • 100KM
    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
  • 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...
  • 3D Robotics
    IR sensors are AN 0-2
    Pressure is AN 5
    Voltage is AN 3

    Others are free, I think

    Wiki coming as soon as Ning's wiki app sucks less. They tell me that's soon.
  • 3D Robotics
    1) Yes, Also ADC0-5 are free
    2) Not sure. Probably around 50Hz, which is the servo refresh rate
    3) Entirely (for now)
    4) I'd go for Horizon first, for simplicity and similarity to current ArduPilot
    5) No. Not sure how to do that
    6) Not sure of the point of that. You can already buy USB cables that you can plug into your RC Tx trainer port to do that.
  • Funny that Mr. Anderson made this post yesterday... I have been stalking :) these forums for awhile now, since I finally decided that I was going to act on this UAV idea I've had for a long time. I actually signed up to bounce some ideas off the MatrixNav guys about maintaining a quaternion vs a DCM for orientation, but enough about that. Anyway, my strategy is to simulate "everything" prior to building one piece of hardware. One of the things I have started work on is an interface to FlightGear that takes aircraft dynamics data and translates that into raw sensor (roll, pitch, yaw, XYZ accel, GPS, mag, etc.) data including modeling the sensor performance (noise, limits, digitization errors, etc.). I was then going to model my IMU algorithms and run all of this through them to see how they hold up with the "truth" output from FlightGear. I guess the next logical step would be to implement my nav equations and feed the control data back into FlightGear and see what happens. It seemed to me that this is a big chunk of what Mr. Anderson was talking about, except my plan is to model my HW in SW. Now that I think about it, my next logical step would be to do some HITL (HW in the loop) work.

    A couple things about FlightGear for the person that metioned it. Fisrt, FGs output is not based on a set sample rate (it updates with frame rate and a time delta between samples, and sometimes frames are skipped) so some interpolation is needed to make it usable, but that’s easy right? Second, FG outputs data in earth reference frame, to feed an IMU we need to translate that into body reference frame, still not rocket science. Last, there are no flight models for RC airplanes (that I could find) for FG, this could make things tough for a not-so-aerodynamic-smart guy like me. That leads me to my next topic JBSim…

    JBSim is an open source flight dynamics model that is used (among others) by FG. I have started to model my Hobbico SuperStar EP in JBSim but I have not gotten far enough to know if it is going to work. There is a model in JBSim of a Cessna 172 which has to have similar (to scale of course) flying characteristics. Or maybe it doesn’t, but that is what I am starting with. I may also attempt to mod the JBSim code to support body frame output data, but that is pretty far down the road. My day job brings me pretty close to avionics work for *real* airplanes (and UAVS), so I have some pretty smart people to bounce questions off of, unfortunately I have yet to ask a question that I understood the answer to.

    To the PICPilot guy (Mr. Wolfe I believe): I plan on doing the hardware with a PIC (I was going to attempt 16-bit) b/c that is what I have used for years. Your board is pretty bad@$$ by the way. I have not the skills to put something like that together; I was going to use thru-hole ICs and breakout boards when I couldn’t find a thru-hole part, adding little dabbles of magic from my $30 RadioShack soldering iron.:) I am interested to see what you come up with for stats on all that gear.

    I am pretty sure that this is going to be the path I am going down for the next few weeks (months? years?) if anybody has any suggestions I would love to hear them. I also have no problem sharing my trials and tribulations with everyone. I will probably set up a blog on this site eventually. Nice to meet everyone, sorry for the rambling first post; and if I high jacked the thread taking it off track I am sorry.
  • Looks like something the Parallax Propeller could take in its stride :-)

    I'd love to take-up the challenge, but I have no X-Plane nor ArduPilot :-(
  • 3D Robotics
    I think that the sim should cost less than $100 and ideally less than $50. If it could come with a desktop app that, like Brian suggests, does some of the processing on the PC and thus can simplify/cheapify the board (just one USB connection, for example), all the better.
  • 100KM
    true but lets define "expensive " i don't think $200 would be expensive and you could do it for under that . but $200 to sim a $25 AP? so i guess a good question to Chris would be : What expected price range would you give?
This reply was deleted.