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

  • Brian, I've got a GPS emulator that I'm going to be releasing next week that does just that. It captures the output from the ArduPilot and changes the GPS stream accordingly. Granted, it's not as fancy as what's proposed here, but it will show the basics of the flight path.
  • 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.
  • T3
    Why go to the trouble of decoding the PWM servo signals. It seems that you could just define a Hardware in the Loop Telemetry packet that send the servo commands straight to the PC. For teh return data you could use the GPS input to receive simulated GPS data and sensor data. No extra hardware required other than possible a level translator for the PC to GPS input leg.
    I don't use the ardupilot so I may have a missconception on some things here. Just an idea. This is the general approach I have planed for the PicPilot but I do have the luxery of a USB port on the board.

    Brian
  • 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?
  • 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.
  • 100KM
    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.
  • 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
  • Don't forget Michal B's approach for X Plane using only the FTDI cable, the Ardupilot (running modified code) and his program.
    http://www.diydrones.com/profiles/blog/show?id=705844%3ABlogPost%3A...
This reply was deleted.