Skip to content

takeoff(), adds_mission(), land()

Selynna Sun edited this page Dec 14, 2018 · 1 revision

takeoff() and land() start and end the vehicle's flight, generateWaypoints() generate the waypoints for the mission, and adds_mission() puts waypoints in the current mission.

takeoff()

takeoff() ensures that before flying, that a few things get checked.

  1. Pre-arm checks - waits until autopilot is ready
  2. Motors arm properly - waits until arming process is complete
  3. Take off - uses Dronekit's vehicle.simple_takeoff function to take off to target altitude

adds_mission()

adds_mission() adds several commands to the current mission.

First, it adds a takeoff command, so when the vehicle mode is in auto, it takes off through the command list. Note: if the vehicle mode is in guided, it uses the actual takeoff function.

Next, it takes the array of generated waypoints (from generateWaypoints()) and adds each one as a command. It then adds a dummy waypoint so that the mission will know it has reached its destination.

Once all of those are added, commands are uploaded to the vehicle.

land()

land() is one simple call to Dronekit's vehicle.mode - it sets it to VehicleMode("RTL"), then closes the vehicle object using vehicle.close(). Setting the vehicle mode to RTL automatically lands it in the original GPS coordinates of the vehicle.