Complete the code to import the DroneKit library.
from [1] import connect
DroneKit is imported using from dronekit import connect. This allows you to use its functions like connect.
Complete the code to connect to a drone using DroneKit.
vehicle = connect('[1]', wait_ready=True)
DroneKit connects to a drone using connection strings like udp:127.0.0.1:14550 for UDP connections.
Fix the error in the code to print the drone's battery level.
print(vehicle.[1].level)
The battery information is accessed via vehicle.battery. The level attribute gives the battery percentage.
Fill both blanks to create a dictionary of GPS coordinates if the drone has a fix.
if vehicle.gps_0.[1] > 0: location = {'lat': vehicle.location.[2].lat, 'lon': vehicle.location.[2].lon}
The GPS fix type is checked with vehicle.gps_0.fix_type. The global coordinates are accessed via vehicle.location.global_frame.
Fill all three blanks to create a dictionary comprehension of vehicle modes with their names and whether they are active.
modes = {mode.[1]: mode.[2] for mode in vehicle.mode.[3]Each mode has a name and active attribute. The modes are accessed from vehicle.mode.modes.
