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 ArduSim_20090211.zip (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 127.0.0.1 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.
Hmm, I am still at a loss for this problem - I think there is something serious wrong, and I am not sure what the root is. I tried entering the DebugInt(1); command into several places, and it does not show up on run. I get stabilization working to and from ArduSim, and it displays Pitch and Roll, so I know communiction there is good... but nothing with my ArduPilot board. No yellow lights (blue blinks about once per second, even if FTDI is not plugged in) and no test values. I have the Upload.bat configured to run as a hotkey, and that seems to work great, I always get success messages on builds and uploads.. just no calculations, and no traffic on the FTDI board. As a curiosity.. I plugged in a servo to ch1 and ch2 of the outs of the board, and both just cranked all the way over to full clockwise and kept on trying to keep turning.
Try changing the Port Number. I was having very similar issues but changed the Port to 49003 in ArduSim and X-Plane. Then the data started flowing into the ArduSim windows and the servo movement began showing in the bars. I also keep a servo plugged into the rudder channel to hear the movement.
My controls also seem very sensitive right now but I was able to fly for the entire ten minute time that the demo allows by using the aileron input from a Realflight controller to keep the wings level.
Kyle: Posted code should work. It's time to learn some debugging.
To get feedback from ArduPilot, you can use this command:
DebugInt(1);
This will send number 1 back to ArduSim, and will be displayed in "Debug Val" field. So you know that ArduPilot executed the command. Put it for example right after line with "ArduPilot!!!" in ArduPilot.cpp, upload code, run ArduSim, reset ArduPilot, and see if you get the number in ArduSim. If yes, then you know that board executed the code.
Now move the command DebugInt(...) to different location (e.g. to beginning of Loop function), or put there more of them with different numbers as parameters, and you'll learn which code AP just executed.
Also see if you have Lat/Lon/Alt filled in ArduSim, if yes, then certainly AP sent telemetry back.
Tip for Visual Studio: in Debug tab, configure Upload.bat as command, then you'll upload code by single key hit in VS. Here's the setting:
So In playing with the simulator some, I discovered that some of my crashes where due to the controls being set overly sensitive, and now I can (manually) fly the plan nicely.. but I am still not able to get a link to the board properly. I get a blinking blue light (about once per second) and successful connection over the com port, and x-plane is picking up network traffic properly, and if i engage the sim, it overrides power to lock at 50%, so I know that it is alteast partially working. What I do not get is any yellow light flashing indicating that calculations are being done, any movement on any of the servo channels, or (obviously) any movement in X-plane. I uploaded the .hex file that I compiled with the Upload.bat, so I am a bit stuck at where the problem is. Is there any modifications or re-compiling that needs to be done to ArduSim.exe?
Here's my another simulation, where I hold altitude by mix of throttle + elevator: Sim_2009-02-11.kmz
That produces much better altitude hold than using just throttle, and more constant speed. Also plane didn't crash in deadly spiral when returning home.
Algorithm is simple - keep throttle around 50%, and apply desired altitude change at 50% to throttle and at 50% to elevator. So climbing will add throttle and raise elevator, descending will lower throttle and push elevator. That allows for rapid altitude changes.
wendell: no hw modifications needed for this simulator to run.
Only if you want to have 4 servo in and 4 servo out signals, then some wires are needed. This may be useful if you consider adding stabilization to ArduPilot, or play with controlling 4 servos for more advanced navigation - such as throttle+elevator altitude control, or nicer turns using rudder+ailerons.
Comments
The photo below shows my plane flying the Innsbruck Route and Michal's Flight.kmz results that are posted above.
Try changing the Port Number. I was having very similar issues but changed the Port to 49003 in ArduSim and X-Plane. Then the data started flowing into the ArduSim windows and the servo movement began showing in the bars. I also keep a servo plugged into the rudder channel to hear the movement.
My controls also seem very sensitive right now but I was able to fly for the entire ten minute time that the demo allows by using the aileron input from a Realflight controller to keep the wings level.
To get feedback from ArduPilot, you can use this command:
DebugInt(1);
This will send number 1 back to ArduSim, and will be displayed in "Debug Val" field. So you know that ArduPilot executed the command. Put it for example right after line with "ArduPilot!!!" in ArduPilot.cpp, upload code, run ArduSim, reset ArduPilot, and see if you get the number in ArduSim. If yes, then you know that board executed the code.
Now move the command DebugInt(...) to different location (e.g. to beginning of Loop function), or put there more of them with different numbers as parameters, and you'll learn which code AP just executed.
Also see if you have Lat/Lon/Alt filled in ArduSim, if yes, then certainly AP sent telemetry back.
Tip for Visual Studio: in Debug tab, configure Upload.bat as command, then you'll upload code by single key hit in VS. Here's the setting:
So In playing with the simulator some, I discovered that some of my crashes where due to the controls being set overly sensitive, and now I can (manually) fly the plan nicely.. but I am still not able to get a link to the board properly. I get a blinking blue light (about once per second) and successful connection over the com port, and x-plane is picking up network traffic properly, and if i engage the sim, it overrides power to lock at 50%, so I know that it is alteast partially working. What I do not get is any yellow light flashing indicating that calculations are being done, any movement on any of the servo channels, or (obviously) any movement in X-plane. I uploaded the .hex file that I compiled with the Upload.bat, so I am a bit stuck at where the problem is. Is there any modifications or re-compiling that needs to be done to ArduSim.exe?

Complete flight: fly_2009-02-12.kmzSim_2009-02-11.kmz
That produces much better altitude hold than using just throttle, and more constant speed. Also plane didn't crash in deadly spiral when returning home.
Algorithm is simple - keep throttle around 50%, and apply desired altitude change at 50% to throttle and at 50% to elevator. So climbing will add throttle and raise elevator, descending will lower throttle and push elevator. That allows for rapid altitude changes.
Only if you want to have 4 servo in and 4 servo out signals, then some wires are needed. This may be useful if you consider adding stabilization to ArduPilot, or play with controlling 4 servos for more advanced navigation - such as throttle+elevator altitude control, or nicer turns using rudder+ailerons.
-
2
-
3
-
4
-
5
-
6
of 8 Next