Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

The simulator should exit after the drone lands, which takes occurs about 100 seconds for this taskafter start. Ctrl-c to stop the simulator early. If the simulator exits early or has some error, then you should go through your task 1 code again and make sure there aren't any bugs. You are encouraged to use the debugger and/or print statements in conjunction with the simulator, as long as you do not breakpoint or step into modules/private/ .

...

In addition, the drone report also contains its position and global destination (if applicable).

  • The report’s destination is the same as the report’s position for Halted and Landed.

There are 4 types of commands:

  • Null: Default. Does nothing but required to advance the simulator.

  • Set relative destination: Move distance relative to current position of the drone. Requires drone to be halted. The destination must also be within the flight boundary.

    • The flight boundary is a square from (-60.0, -60.0) to (60.0, 60.0). The drone’s initial position is (0, 0).

    • The drone halts when it reaches the destination.

  • Halt: Makes the drone stop immediately at its current position.

  • Land: Lands the drone at the current position and ends the simulation. Requires drone to be halted.

...

Once your code is implemented, the simulator should exit after the drone lands, which should take less than occur within 60 seconds of start. The difference between the coordinates of the drone position and waypoint under the text file in log/ should be less than 0.1 . You can also confirm with the screenshot.

Note

Hints:

  • You do not need to use landing_pad_locations in this task.

  • You can use the drone report’s destination to see if your relative command is correct.

  • Ideally, the drone will report Halted at the beginning of the simulation and when it reaches the waypoint. The rest of the time, it will report something that isn’t Halted.

    • So you’ll have to find a way to know the difference between Halted at initial position and Halted at the waypoint.

Note

Bonus:

  • While the simulated drone will always successfully complete its movement, what if it was possible for the drone to halt at any time (without your input)? Does your code handle this case?

Task 4: Putting it all together

...

Your task is to implement the code in __init__() and run() to travel to the designated waypoint, calculate which landing pad is closest (L-2 norm for the math nerds), and land at that landing pad. You can remove or comment out the NotImplementedError line.

Once your code is implemented, the simulator should exit after the drone lands, which should take less than occur within 60 seconds of start. The difference between the coordinates of the drone position and the landing pad under the text file in log/ should be less than 0.1 . You can also confirm with the screenshot.

Note

Hints:

  • You can write a helper function to calculate the distance between 2 Location objects. This will make the finding closest landing pad code easier to read and write.

  • You can initialize the distance value with a very large number (e.g. infinity). Then the first landing pad’s distance will definitely be smaller than this. Details of the loop and logic are for you to implement…

    • Don’t constantly recalculate the distances if you don’t need to.

Note

Bonus:

  • Square roots are computationally expensive, is there a way to avoid using it?