ArduPilot successful flight simulation

A photo of successful flight as seen in Google Earth and X-plane:

Here is another ArduPilot simulation inspired by Jordi's simulation.My simulation requires minimum additional hardware, all you need is ArduPilot connected by FTDI cable to PC.Actual simulation runs in X-plane simulator. ArduPilot get simulated GPS data over serial, and it returns back proposed servo positions back over serial as part of telemetry info (servos can also move physically). ArduPilot also reports bunch of variables - lat/lot/alt, next waypoint, distance to it, etc.What you need to repeat the simulation:- Modified ArduPilot code from this blog post- X-plane 9 demo (buy full version if you wish, but demo works just perfect, it only ignores joystick input after 10 minutes, but we control it other way so it really doesn't limit us)- Google Earth- ArduSimulator (developed by me), which is simple application that does following:1) Connects to ArduPilot over serial for sending/receiving data2) Connects to X-plane on localhost (same PC)3) Reads data from X-plane (lat/lon/alt/course), sending these to ArduPilot as GPS sentences4) Simulating FMA copilot stabilization on ailerons/elevator5) Reads and displays telemetry and servo positions from ArduPilot6) Sends servo positions to X-plane to control throttle and rudder7) Records fly path and sends it to Google Earth to displayHere's how to repeat the simulation:- Start X-plane, go to Menu->Settings->Net Connections, select tab Inet 3 and enable "IP of data receiver", change IP address to and port to 49001. It looks like this:

- Select Aircraft from folder Aircraft\Radio Control\GP_PT_60 (yes, we want to fly RC plane which has ail/elv/rud/thr controll)- Select airport Innsbruck- You can open this KML path: Innsbruck.kmz in Google Earth, which was my testing fly plan configured in ArduPilot; this will show you the waypoints- upload compiled ArduPilot code to the board and leave it running; LOCK LED should keep flashing- start ArduSim.exe (simulator tool); it will connect to serial port and X-plane; if it can't connect to serial, specify correct port and baudrate and press Start button- click [Google Earth] button in ArduSim to make connection with GE- hit B in X-plane to release brakes, and try keys A/W/C to choose various viewsNow simulation should be running if everything is connected successfully, and you should see plane in X-plane to fly and visualization path & icon in Google Earth to move. Don't control plane in X-plane! ArduPilot will take-off and fly on its own.Here's video how it all looks in action:And complete flight path visualization for Google Earth: Flight.kmzYou can see original waypoints in white, and real fly path in yellow. And also final circulation over start point when all waypoints were visited...Now about problems and future tasks:- I have strong impression that controlling altitude by throttle with use of copilot stabilization doesn't work properly, this simulation showed me that plane didn't want to drop altitude from high point to lower one... see results in above flight path in GE. I'm not sure how real plane behaves (didn't went out to real world with this yet), we'll see.- For this reason I plan to start playing with complete stabilization in ArduPilot, and controlling both elevator+throttle to get desired altitude.- You can play with dozen of various parameters to control behavior, most obvious are PID settings for throttle/rudder in ArduPilot, but also PID values in stabilization (which is here provided by simulator tool, in real world it is FMA Copilot which you can control by its sensitivity setting). Then you can change maximal servo rotation for ArduPilot to work with. All these values make the plane fly smoother, make more precise turns, etc etc. And the settings seem to depend on actual aircraft and its physical behavior. So there won't be single settings working for everyone.- It's somehow cumbersome to specify different altitude for various waypoints; while I converted waypoints from KML file out of Google Earth, I had to specify individual altitudes manually in waypoints.h file in ArduPilot code.After all, I'm pretty happy to see the plane flying in simulator and doing the task! Note that it's ArduPilot doing the navigation work. And in a real airplane, this simulation allows to reuse the ArduSim application as a base station, getting telemetry from plane over Xbee modem and displaying what it does as well as showing path in Google Earth.
E-mail me when people leave their comments –

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

Join diydrones


  • Michal,

    Thank you for sharing this simulator. I'm slowly getting it figured out. Although I used to do a lot of programming many many years ago, I barely qualify as a script kiddy today.

    I ran into the same errors that Kyle did but finally worked through them to get a hex file!

    I found that I had to follow your directory naming exactly like the readme says and that the object and hex ended up in the _build folder instead of the Applet folder that I expected.

    I also had to add an empty HardwareSerial.o to create the hex in MS VS.

    Finally, I ended up hard coding my com port in the upload.bat in addition to moving the hex file to the directory with the bat file.

    I've figured out how to create a path in GE and convert it into a KML. Then I was able to get the KML parser to create a new waypoints library and recompile and load with my waypoints.

    Tomorrow night I'll add some more header pins so I can add the jumpers for the mux and servo input signals. So I can hook it all together.

    I flew around in X-plane for a few minutes this evening with a RC sim controller. X-plane looks like it can be very complicated and ArduSim looks like it is very basic. Are there any tricks that I will need to be aware of to make GE, Ardupilot, ArduSim, and X-plane work together once I add the jumpers to my board?

    Thanks again,

  • Awesome! I got it to work. Very nice work. Has anyone else tried this too?
  • Note that you can build this version also with AVR Studio, just open ArduPilot\ArduPilot.pde file in it.
  • Ah, I had the AVR studio unzipped to the wrong folder, I misunderstood the ArduPilot.vs part. Now i see it all working correctly right up until:

    1>Creating executable...
    1>arduino-0012\hardware\tools\avr\bin\avr-ar: _build\HardwareSerial.o: No such file or directory
    1>Failed to build system files i just made a blank HardwareSerial.o file and it seem to write it just fine after that! Thanks for the help, it's greatly appreciated!
  • You need to download AVR studio v0012 (point 2 in the installation instructions on that page), and extract it to ArduPilot.vs\arduino-0012. Your error means that VS can't find AVR compiler.
  • I am not terribly familiar w/ MS VC++ studio too much, but I've enough experience in other languages to leave me scratching my head as to why I got this error on attempting to build:

    1>The system cannot find the path specified.
    1>Project : error PRJ0019: A tool returned an error code from "HardwareSerialX.cpp"

    I'm using the unmodified version of the code posted at the top of the page, is there any pre-compiling step that I am missing? (i can upload the error report too) Any hints would be greatly appreciated!
  • Code is public, look above for "Modified ArduPilot code..." link.
  • Michal,
    Could you email your code your using or attach it to the reply post as a zip file ??
    I think i have got my head around things now and have some theory's in what may fix the problems.

  • Michal interesting simulation. I assume the wind is from the west in which case what is also intresting is that the legs which are are at up to 45degrees to the wind are actually not too bad - especially when compared with the simulation at the top of the blog. I suppose when you arrived at a site it would be possible to make an assessment of the wind stength and direction and run a simulation of the proposed filghtplan and assess any changes required there and then.

  • Heavy wind simulation:

    Conclusion: don't fly in such weather... ;)
This reply was deleted.