Task 1

Pathing

Stage 1: Takeoff

There are two components to the takeoff sequence. The drone must first takeoff from the initial position to an altitude of 100 metres. The drone will then traverse to waypoint Alpha.

  1. Create a CSV file to store the location (in latitude and longitude) of waypoint Alpha.

  2. Create a takeoff command to climb to 5 metres.

  3. Add a command to go to waypoint Alpha at an altitude of 100 metres.

  4. Append these commands to the command sequence

Stage 2: Running Laps

The drone will run laps around waypoint Alpha to waypoint Bravo. A full lap consists of flying from waypoint Alpha to Bravo to Alpha. The drone must fly around the waypoints.

  1. Create a CSV file to store the location of 4 points. The 4 points will be used to mark the locations to run a lap around waypoints Alpha and Bravo.

  2. Create a list of commands to follow the waypoints 1 → 2 → 3 → 4. This represents a lap for the drone.

 

  1. Set a hardcoded value (let’s call this N) to determine the number of laps the drone will run in task 1.

  2. Get the mission to follow a lap, add it to the mission N number of times, add a command to return to launch (RTL) and upload the mission to the drone.

    1. So the command sequence will have a takeoff command, a command to go to waypoint Alpha, and then the commands to run N number of laps.

    2. Note: For the last lap, the program will need to append location 1 to the command sequence. This way, the drone will complete the last lap rather than stop at location 4.

  3. When the mission is uploaded to the drone, an evaluate function will run periodically. The purpose of the evaluation function is to determine if the drone should continue running laps or if it should clear the current mission and land (see the Landing section below). Below is a list of factors the program must consider to decide if it should land or continue running laps.

    1. Time: If we are let’s say 5 minutes away from the end of the flight time then we land. We will use a hardcoded value to determine how much time we will allocate for landing.

    2. Battery: TODO confirm if this automatically causes RTL.

Stage 3: Landing

If the program determines it is time for the drone to land, the landing sequence will be initiated.

  1. Clear the current mission on the drone.

  2. Create a RTL command.

  3. Add the RTL command to the drone’s command sequence.

  4. Upload the new mission which only contains the RTL command.

Implementation

  1. Create a DroneKit vehicle object.

# Wait ready is false as the drone may be on the ground drone = dronekit.connect(CONNECTION_ADDRESS, wait_ready = False)
  1. Create a dictionary that maps waypoint name (e.g. Alpha) to its latitude and longitude in decimal degrees. This will be done in the main function.

    1. Create a CSV file to store the waypoint name and its corresponding latitude, longitude

    2. Call the load_waypoint_name_to_coordinates_map module to read the waypoint CSV file and convert it into a dictionary.

  2. Create a dictionary that maps the locations 1, 2, 3, and 4 to its latitude and longitude in decimal degrees. TODO: We will want to come up with better names that location 1, 2, 3, and 4. This will be done in the main function.

    1. Create a CSV file to store the waypoint name and its corresponding latitude, longitude

    2. Call the load_waypoint_name_to_coordinates_map module to read the waypoint CSV file and convert it into a dictionary.

  3. Create a module that appends a takeoff command to the beginning of the drone’s command sequence and an RTL command at the end of the drone’s command sequence. (Note: this is similar to the add_takeoff_and_landing_command module but the RTL command is added instead of LAND command).

  4. Create a module that adds the laps N number of times (N is the hardcoded number of laps that is set)

    1. First, we need to convert the dictionary that maps waypoint names to world coordinates (latitude and longitude) to a list of coordinates. This can be done by calling the waypoints_dict_to_list module.

    2. Create a list that specifies the route the drone needs to take in order to run N laps

    3. Turn the list of waypoints to DroneKit commands. This can be done with the waypoints_to_commands module.

  5. In the main function, we can get the list of DroneKit commands to run laps by calling the module described in point 5, and append the takeoff and RTL command to the command sequence by the module described in point 4.

  6. Upload the mission to the drone. This is done in the main function. This can be done with the upload_commands module.

  7. Create a module that gets information from the drone and determines if the drone should RTL or continue with the mission. This module will return a boolean value that represents if the drone should land or not.

  8. To account for the time constraint, take the start time in as a parameter and subtract it from the current time to get the time difference. We can set a threshold for how much time we want to allocate for landing and see if we are past that threshold).

  9. Create a module that clears the drone’s current mission and sends an RTL command. The upload_commands function can be used to upload to the drone.

  10. In the main function, we can have an infinite while loop that has a delay of x number of seconds (x is a hardcoded value) and call the module described in point 8. If module returns true, then break out of the infinite loop and call the module described in point 9.

Conditions to Force Early RTL

  • Running out of time

  • Battery low (we have 12000mah, need to determine how much energy to keep for safe landing. Guessing ~ 1000 mAh for now)

  • Critical system failure →