-
Notifications
You must be signed in to change notification settings - Fork 2
Auto Land
!ArduPilot Mega can automatically launch and land an aircraft, as part of a mission plan. Here's how:
The basic idea of automatic takeoff is for the APM to set the throttle to maximum and climb until a designated altitude is reached. To cause the plane to execute a takeoff, add a NAV_TAKEOFF command to your mission, probably as the first command. This goal is handled slightly differently depending on what sensors are attached, but the altitude parameter always specifies the altitude that must be attained before the APM will consider its takeoff complete and load the next Must command.
The APM will initially hold the wings level on takeoff, but as soon as a takeoff heading is established, the APM will adjust roll to maintain that heading.
If you do not have a magnetometer:
As soon as the ground speed, as measured by the GPS, exceeds 3 m/s, the takeoff heading will be set to the GPS ground course. This means that, in a crosswind, the APM may turn downwind somewhat during takeoff. Sometimes, the takeoff heading is accidentally set too early and this will cause the APM to turn the plane to an undesired heading during takeoff. To minimize this problem, try not to move the plane after Auto has been engaged except to throw it in the direction of takeoff. Try not to "wind up" by moving the plane backwards before throwing it. As much as possible, try to duplicate the behavior of a catapult launcher.
If you have a magnetometer:
As soon as the ground speed, as measured by the GPS, exceeds 3 m/s, the takeoff heading will be set to the magnetometer's yaw sensor.
If you do not have an airspeed sensor:
The first parameter of the NAV_TAKEOFF command will specify the maximum pitch the APM will target on takeoff. The minimum pitch is automatically set to 5 degrees positive pitch. As the plane increases in speed (as measured by the GPS), its pitch will increase. The exact formula is:
target pitch = (GPS speed / cruise speed) x maximum pitch / 2
If you have an airspeed sensor:
The first parameter of the NAV_TAKEOFF command will specify the minimum pitch the APM will target on takeoff. The APM will adjust pitch to achieve airspeed_cruise (pitch up if airspeed is above cruise, pitch down if airspeed is below cruise), but it will not pitch below the minimum pitch set by NAV_TAKEOFF.
To land the plane, simply add a NAV_LAND command to the end of your mission indicating the latitude, longitude and altitude of your desired touchdown point. In most cases, the altitude should be set to 0. During landing, the APM will shut down the throttle and hold the current heading as soon as the plane is within 2 seconds of the touchdown point horizontally, or as soon as the plane is lower than 3 meters above the touchdown point, whichever occurs first.
On approach, the APM will fly normally if you have an airspeed sensor. If you do not have an airspeed sensor, the APM will hold 0 pitch.
Here is an example mission around the Sparkfun building that autotakeoffs, goes around the building and then sets up a landing pattern for an autoland. Note that the waypoints kick in once the plane has reached 30m altitude after autotakeff, and that it lands at 0m altitude (altitude is given relative to home/launch altitude)
http://ardupilot-mega.googlecode.com/svn/ArduPilotMegaImages/autotakeoff.PNG
wiki:comment
You can adjust both of these behaviors by issuing a NAV_LAND_OPTIONS command just after your NAV_LAND command.
The last three parameters of the NAV_LAND_OPTIONS command define a modification of flight behavior for the APM. If you do not have an airspeed sensor, the last parameter defines the pitch for the APM to hold. This parameter has no effect if you have an airspeed sensor -- instead, the APM will pitch the plane in order to hold airspeed_cruise.
The third parameter defines the new value for throttle_cruise. throttle_cruise serves as the throttle setting for equilibrium; if the plane is at the correct altitude (and speed, if you have an airspeed sensor), the throttle will be set to throttle_cruise. Marginal changes away from equilibrium (if the plane is slightly too high, for example) result in marginal changes in throttle away from throttle_cruise. Setting throttle_cruise lower will cause the plane to lose energy, which is desirable during landing. If you have an airspeed sensor, changes in throttle_cruise should be coordinated with corresponding changes to airspeed_cruise to maintain good flight characteristics.
The second parameter defines the new value for airspeed_cruise, but this parameter has no effect if you do not have an airspeed sensor (except during takeoff). If you do have an airspeed sensor, this parameter should be matched to throttle_cruise. That is, in straight and level flight, a particular throttle setting results in a corresponding airspeed for a given plane. You should choose the value for airspeed_cruise that corresponds to the airspeed observed in straight and level flight with a throttle setting of throttle_cruise that you selected for this NAV_LAND_OPTIONS command.
NOTE: If you use a two-way GCS (DebugTerminal, for instance) to manipulate the plane's mission in flight, be aware that changes in throttle_cruise and airspeed_cruise are not automatically reset when the plane exits a NAV_LAND_OPTIONS command.
Since NAV_LAND_OPTIONS is a level 2 "May" command, it will be executed immediately after loading the preceeding Must command -- in this case, NAV_LAND. It will block execution of subsequent "May" commands until the APM is within a certain distance of the next waypoint -- in this case, the waypoint defined by NAV_LAND -- as defined by the first parameter in the NAV_LAND_OPTIONS command, interpreted as meters. For this reason, if the first parameter of your NAV_LAND_OPTIONS command is 0, then all further execution of "May" commands will be blocked since the APM will never be closer than 0 meters from the target waypoint. If a value other than 0 is chosen for the first parameter, that NAV_LAND_OPTIONS command will be considered complete as soon as the APM is within the number of meters specified in the first parameter of the target waypoint. For this reason, multiple changes in flight behavior may be defined for a single NAV_LAND command.
A landing mission with an airspeed sensor might look like this:
NAV_LAND: p1 = 0, alt = 0, lat = 34.158121, -118.166592
NAV_LAND_OPTIONS: p1 = 150, p2 = 15, p3 = 75, p4 = N/A
NAV_LAND_OPTIONS: p1 = 50, p2 = 13, p3 = 65, p4 = N/A
NAV_LAND_OPTIONS: p1 = 0, p2 = 10, p3 = 45, p4 = N/A
In this mission, the plane's nominal airspeed is set to 15 m/s with a nominal throttle setting of 75% as soon as the NAV_LAND command is loaded. When the plane is within 150m of the waypoint specified in NAV_LAND, the first NAV_LAND_OPTIONS command is completed and the second NAV_LAND_OPTIONS command is loaded, which reduces the plane's nominal airspeed to 13 m/s with a nominal throttle of 65%. When the plane is within 50m of the waypoint, the second NAV_LAND_OPTIONS command is completed and the third NAV_LAND_OPTIONS command is loaded, which reduces the plane's nominal airspeed to 10 m/s with a nominal throttle of 45%. This third NAV_LAND_OPTIONS command will never complete because the plane will never be within 0m of the waypoint. So, the plane will remain at a nominal airspeed of 10 m/s with a nominal throttle of 45% all the way through landing.
A landing mission without an airspeed sensor might look like this:
NAV_LAND: p1 = 0, alt = 0, lat = 34.158121, -118.166592
NAV_LAND_OPTIONS: p1 = 150, p2 = N/A, p3 = 75, p4 = -3
NAV_LAND_OPTIONS: p1 = 50, p2 = N/A, p3 = 65, p4 = 0
NAV_LAND_OPTIONS: p1 = 0, p2 = N/A, p3 = 45, p4 = 3
This mission will proceed identically to the preceding example, except that instead of monitoring and reducing airspeed, the APM will monitor and increase the fixed pitch at which the plane flies. </wiki:comment>