3D Robotics

Setting up ArduPilot for autonomous flight

ArduPilot has two modes: programmed waypoints and return-to-launch (RTL). In the first one, you enter in GPS Latitude and Longitude coordinates of your waypoints into the code with the Arduino IDE. In the second, you don't enter in any waypoints and the aircraft just returns to the Lat/Lon it was at when you first powered on the board (at your launch location). I fyou're using ArudPilot 2.1 or above, you can set it up with a desktop utility, as described here. If you're using 1.0 to 2.0.1, you need to do it by hand. Here's the process: 1) Go into Google Maps, satellite view, and right click on the location you want to be your waypoint. Select "Center map here", then click on the "link" icon in the top right corner. You'll see a URL come up, which contains your Lat and Lon. Copy each one and past them the "wp-lat" and "wp_lon" declaration for that waypoint in the Mission Setup tab of the ArduPilot code. Continue until you've got all the waypoints. Add as many waypoints as you want, but remember to set the "waypoints" definition in the first tab to the number of waypoints you're using. [Again, this will all get easier and more intuitive in the next version of the code] The altitude is relative to the initial launch position, not above sea level. So if your airfield is 500 meters above sea level and you enter "500" as the waypoint altitude, the plane will fly at 1,000 meters above sea level (but just 500 meters above you). 2) If you just want to have ArduPilot Return To Launch, then go to the first tab in the code and look for "#define RTL 0". This is the RTL flag. Set it to 1 if you want the plane to just RTL, or 0 if you want it to follow the waypoints in the Mission Setup tab. Once you've got the waypoints and settings the way you want them, upload the code to the board. Unplug the GPS module if it was connected, plug in the FTDI cable and click on the upload to I/O board icon on the Arduino IDE. Once it's uploaded, you can reconnect the GPS module. 3) Now it's time to set up your FMA Co-Pilot. Follow the setup instructions that came with it. At the airfield, calibrated it and fly a bit to get a feel for how much gain to give it (using your proportional control on the transmitter). Once it's stable, try turning on the Co-Pilot and then turning the plane using just the rudder. It should "skid" around turns with a bit of rocking as the Co-Pilot tries to keep the wings level as the rudder yaws the plane. What you're doing is manually testing what the ArduPilot will do under autonomous control. 4) Once that is set up, it's time to try an autonomous flight. Take off manually, and get to the altitude you want to run the course at. Turn on the FMA co-pilot and ensure that it's working. Now flip the ArduPilot control switch (your channel 5 or 6 toggle, depending on how you've set it up.) The aircraft should navigate to the first waypoint. If anything seems to be going wrong, remember that you can always override the the FMA Co-Pilot with your aileron and elevator sticks. Even if ArduPilot has done something very wrong with the rudder and throttle, you should be above to regain control and bring the aircraft back to you. Once the aircraft is back in control, turn the autopilot off and you will regain control of the rudder and throttle so you can land and diagnose the problem.
E-mail me when people leave their comments –

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

Join diydrones

Comments

  • If I replace the 0 with a 1 in line 269 under the Ardupilot tab, will it repeat the waypoints instead of returning to home? One application I'm thinking of is setting the waypoints in a circle, but I don't want it to fly out of the circle and back to home every time.

    if(current_wp>waypoints)//Check if we've passed all the waypoints, if yes will return home..
    {
    current_wp=1;
  • @borneobear
    I wouldn't have my hopes high for GPS-only alt hold. Try combining it with a barometer, and you will be happy with the results
  • Yes, thanks Okoleo! That's very handy.
  • Thank you Pokoleo... Mush easier then google maps
  • It seems that someone wrote a script to get latitude and longitude from here:

    http://www.gorissen.info/Pierre/maps/googleMapLocation.php?lat=40.1...

    I hope that this will make programming your GPS much easier
    -Pokoleo
    OpenLayers Click Event Example
  • Has anyone tried the ArduPilot for Altitude hold on RC Helis? Alt Hold via GPS sounds very promising.
  • 3D Robotics
    SD card input/datalogging is something we're planning for ArduPilot pro. The single Atmega168 in ArduPilot doesn't have enough processing power to datalog on a SD card while doing all the other stuff, and adding a SD card reader just for waypoints seems like overkill. On ArduPilot Pro, however, we're considering adding a third Atmega just to datalog so that will be able to handle a lot of i/o function.
  • There's some 3000 bytes left, and each waypoint consumes 12 bytes, so you can have about 250 waypoints.
    The amount of free memory left for data will vary as code is developed, optimized, or new features added.
    Yes, this would be cool to have SD card reader, but some hardware guy could tell us if this is possible.
  • ArduPilot's description states that the number of waypoints to be loaded is limited by the internal memory. How much memory is there available, and corresponding to how many waypoints? A follow-up question would be if there would be a way to extend the memory limitation, for example with a minimalistic SD Card reader like the microSD Transflash Breakout Board? Wouldn't such card reader be a nice solution to upload a new mission into ArduPilot instead of connecting ArduPilot to the computer (with 2-3 cards, we could leave the laptop at home for a few missions)? Finally, since I am new on the DIYdrones, I hope my comment is not posted at the wrong place.
  • 3D Robotics
    @Jhon: Good catch. That's an outdated reference. We now have a Boolean variable RTL. If you set it to true you don't have to bother changing the waypoints--it will just return to launch and ignore the waypoints beyond [0,0]. I'll fix the instructions.
This reply was deleted.