3D Robotics

T3--Round 6: The Simulation Round!

For the last T3 round before the weather improves (in the Northern Hemisphere), we're going to do something indoors! It's a simulation round, which I previewed here.


I'll repeat the basics:


There are two kinds of simulations: "open loop" and "closed loop".


Open loop means that you connect the output of the simulator to the input of the autopilot. The simulation drives the autopilot with synthetic GPS coordinates and sometimes synthetic attitude data, essentially replacing the autopilot's sensors. This basically fools the autopilot into thinking that it is flying, and you can watch how it responds. This is typically done by having the simulator output data via the serial port and feed that into the autopilot.


Closed loop means that you also connect the output of the autopilot to the input of the simulator, so that the autopilot is "flying" the aircraft on screen. This usually requires a relatively complicated bit of hardware that converts the PWM servo output of the autopilot into what amount to joystick commands via USB or serial that steer the plane in the simulator. It can also be done entirely in software on the host PC, as in the case of Matlab simulations being driven by a flight simulator.


Here are some blog posts that show examples:


--Curt Olson's FlightGear demo

--Faisal Shah closes the loop, Part 1

--Faisal Shah closes the loop, Part 2


Here's the contest structure:


Two sets of winners:


Both must write "DIY" (in cursive) over a place of their choosing. Example above from brakar, who, like Jesse & Jared, have jumped the gun a bit and already submitted successful entries for this round.


--Group One: Open loop (video showing you mirroring the airplanes control surfaces with the arrow keys): First six to complete this win a $25 gift certificate to the DIY Drones store.


--Group Two: Closed loop (aircraft controls the flight simulator): First three to complete this win a $50 gift certificate.


A special top prize will go to the person who best documents how they went about it and creates a useful tutorial for others to use afterward (judge: Gary Mortimer). The prize for that will be the notorious Raven UAV clone (unless the winner requests something else, in which case I may grant mercy and come up with something of equal or greater value).


Also, as suggested by Brian Wolfe, anyone who completes either of these rounds will get points added to their grand total: One point for open loop and four points for closed loop. Here are the current cumulative rankings after five T3 rounds:


Brian Wolfe 31
Vassilis 24
Brakar 23
Mark Griffin 18
Krzysztof Bosak 17
Andrus Kangro 12
Jesse Jared 8
IOS 6
Bill Premerlani 6
MarcS 6
Joe 6
Steve Joyce 5
Steve Westerfield 3
Chris Anderson 3
Icebear 1


Entries must include a video and KML track and a description of your simulation setup (flight sim, autopilot, other hardware). Submit your entry in the comments below by 12:00 midnight PST on Sunday, May 2nd.


E-mail me when people leave their comments –

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

Join diydrones

Comments

  • Apologies for the delay. Vimeo has been chewing on my video for 22 hours now so I have uploaded to YouTube. Quality is not the best.

  • The HUD shows actual values of roll/pitch/etc from the property tree. Maybe it is an effect of outside view.
  • T3
    Of course I know what HUD is.
    In the video during turns the AHI shows anything but the actual roll and pitch.
    I wonder what is the origin of displayed values.
  • T3
    What is the HUD showing in FlightGear?
  • My first shot - an ArduPilot/FlightGear based closed loop simulation. I have no prior experience of tuning gains for ArduPilot so there is still some work to do here. Video to follow shortly and later a write up with software and associated configuration files.
    T3_6.kml

    diyT3_6.jpg


    Hardware and Software used:
    Ardupilot 2.6 with very minor modifications running on an Arduino Mega board.
    FlightGear 1.9.1 with EasyStar model.
    Custom software for translating between FlightGear and ArduPilot + basic Ground Station functionality.

    The system works in a similar manner previous simulation solutions. Custom software takes position/velocity data from flightgear via UDP, formats it for ardupilot and shoves it out the serial port. ArduPilot data output is modified to include servo position data as suggested by Jason Short. This servo data is parsed from the returning serial data packets, translated to values flightgear expects and sent to flightgear via UDP.

    Position/velocity data from flightgear is formatted into ArduIMU serial packets by the custom software. This allows use with virtually stock AP 2.6 code. The only AP code modification required is a small (6 lines) hack to get servo position data into return packets.

    As there is no simple way to share serial data with the AP GroundStation software (very) basic GS functionality is included in the custom software.
    https://storage.ning.com/topology/rest/1.0/file/get/3692033103?profile=original
  • 3D Robotics
    Nice one, Brian! Do you do this all with the normal hardware (ie, tweaking your code so the PWM output goes to FlightGear via serial instead)?
  • Brian,
    I experienced this problem with FG2.0 and rolled back to FG1.9.1. FG2.0 doesn't wait for new values, it just hangs if you don't send enough data. So I use FG 1.9.1 because its UDP queue lag is known and avoidable.
  • Brian,
    I fought with latency in the begining of FG use. And I found that rising FG input frequency doesn't solve the problem completely. So I decided to add a variable to FG property tree and use it as a packet number.

    FGWrapper does the following:
    1. Gets a packet from FG with values of attitude, position, etc and "FG_packet_number"
    2. Converts and sends values to the autopilot
    3. Reads and converts response from autopilot
    4. Checks the difference between "FG_packet_number" from step 1 and "internal_packet_number". If this difference is more than threshold (I use "3" as value) then skip step 5 (synchronization case)
    5. Increases "internal_packet_number" and sends it back to FG with other values (normal case)

    In other words FGWrapper periodicaly stops sending packets to prevent FG queue flooding.

    I use the same gain in the simulation and real life.
  • It is not an open source project. On autopilot board there are 5 serial ports (for sensors, modem and servos), FRAM (config etc), SD card slot (log). Used software: FreeRTOS, Chan FatFS (for SD).

    FG really helps much in debuging/tuning!
This reply was deleted.