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.
  • James,

    This looks great! I'll definitely check it out

    - Roy
  • 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).
  • 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.
  • 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.
  • Aren't the current sensors such as the X-Y horizon sensor on ADC0-5?

    PPM is just like if you AND all of the PWM servo signals together. The only real requirement is that the servo signals on PB0 PB1 PB2 are sequentially time shifted then I can merge them together with diodes and its way easier to convert the servo signals back into digital values.

    3689302388?profile=original


    Aside from the PPM thing if everything else looks good specifications wise I'll order parts and start building it.

    After trying to dig through the documentation today I am starting to think that this site needs a wiki to organize the information available.
  • 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.
  • Ok, here is the initial specifications I have come up with for a hardware in the loop development tool.
    I have a few questions that hopefully someone can answer before I can order parts. The design might be simplified in the future with only one USB connection or perhaps a cheaper microcontroller, but this looks like a good start.

    SimPilot HITL Development Tool

    Specifications
    ATMega168 Microcontroller
    MAX5590B Buffered Fast-Settling Octal 12-Bit Voltage-Output DAC
    AT90USB162 USB Joystick Interface
    FT232R USB Serial Interface

    Computer Connections
    USB Joystick
    USB Simulator Telemetry Feed

    Daughterboard Connections
    NEMA GPS Serial Emulation
    8 Channel 12-Bit DAC Sensor Emulation
    Ch0 X Horizon Sensor
    Ch1 Y Horizon Sensor
    Ch2 Z Horizon Sensor
    Ch3 Airspeed Sensor
    Ch4 Configurable Sensor
    Ch5 Battery / Fuel Sensor
    Ch6 Configurable Sensor (Disconnected)
    Ch7 Configurable Sensor (Disconnected)
    3 Channel Digital I/O [D6 D7] (Planned for Software Version 2)
    Stall Sensor
    Landing Gear Control
    SPI Bus Sensor Emulation [D8 D11 D12 D13] (Planned for Software Version 2)
    SCP1000 Barimetric Pressure Sensor
    ADIS16405 High Precision Tri-Axis Gyroscope, Accelerometer, Magnetometer
    4 Channel 10 Bit PPM Servo Capture Port

    Questions

    1) Are ACD6 and ADC7 disconnected on the ArduPilot? The v15 schematics seem to indicate that they are.

    2) What is the current sampling frequency for the X-Y Sensor and the Pressure Sensor?

    3) Is the altitude is primarily calculated from the GPS?

    4) Can we have a poll for IMU vs Horizon Sensor? ie. Which one should I get working first.

    5) Does the ArduPilot output the servo control signals in a way that is compatible with PPM Signaling? Can it?

    6) Perhaps this is more useful as 2 boards, Having one board as a servo signal to USB joystick converter which could be useful for learning how to fly a model airplane manually, and the other board would be the telemetry emulator. Any thoughts?
This reply was deleted.