# DroneKit

## DroneKit

> *Developer tools for drones. DroneKit offers an SDK and web API to easily develop apps for your drones. DroneKit helps you build apps for the air, ground or cloud.* [Homepage](http://dronekit.io/)

* [DroneKit-Python](http://python.dronekit.io/about/index.html)
* [ELC 2015 - DroneAPI: A Tutorial on Drone Control - Kevin Hester, 3DRobotics](https://www.youtube.com/watch?v=C3kk4XMpFjs)
  * [Drone API structure by Kevin Hester](https://wiki.dronecode.org/_media/u10.droneapi_structure_and_usage_-_kevin_hester.pdf)

## Architecture

```bash
user@workstation:~$ git clone https://github.com/dronekit/dronekit-python.git
user@workstation:~$ cd dronekit-python
user@workstation:~/dronekit-python$ ls
appveyor.yml  CONTRIBUTING.md  dronekit.egg-info  requirements.txt  windows
build          dist           examples          scripts
CHANGELOG.md  docs           LICENSE          setup.py
circle.yml    dronekit           README.md      Vagrantfile
```

```bash
user@workstation:~/dronekit-python$ cd examples
user@workstation:~/dronekit-python/examples$
```

```bash
user@workstation:~/dronekit-python/examples$ mavproxy.py --master=udp:127.0.0.1:6000
Connect udp:127.0.0.1:6000 source_system=255
Log Directory: 
Telemetry log: mav.tlog
Waiting for heartbeat from 127.0.0.1:6000
 MAV>
```

## DroneKit-Python :: Sitl

Default Port 14550

```bash
user@workstation:~$ ./QGroundControl.AppImage
```

```bash
user@workstation:~$ cd Bitol/VirtualDroneSolution/DeveloperAPI/DroneKit/
user@workstation:~/Bitol/VirtualDroneSolution/DeveloperAPI/DroneKit$ python DroneKitPythonSitl.py
```

## DroneKit-Python

```bash
user@workstation:~$ dronekit-sitl copter --home=20.6207591,-103.3991668,30,0
```

```bash
user@workstation:~$ mavproxy.py --master=tcp:127.0.0.1:5760 --out=udpout:127.0.0.1:14550 --out=udpout:127.0.0.1:14560
```

Default Port 14550

```bash
user@workstation:~$ ./QGroundControl.AppImage
```

```bash
user@workstation:~$ cd Bitol/VirtualDroneSolution/DeveloperAPI/DroneKit/
user@workstation:~/Bitol/VirtualDroneSolution/DeveloperAPI/DroneKit$ 
user@workstation:~/Bitol/VirtualDroneSolution/DeveloperAPI/DroneKit$ python DroneKitPython.py 
Connecting to vehicle on: 127.0.0.1:14560
>>> APM:Copter V3.3 (d6053245)
>>> Frame: QUAD
Get some vehicle attribute values:
 Autopilot Firmware version: APM:Copter-3.3.0
 Autopilot capabilities (supports ftp): False
 Global Location: LocationGlobal:lat=20.6207591,lon=-103.3991667,alt=30.0
 Global Location (relative altitude): LocationGlobalRelative:lat=20.6207591,lon=-103.3991667,alt=0.01
 Local Location: LocationLocal:north=None,east=None,down=None
 Attitude: Attitude:pitch=0.00167117756791,yaw=-0.113207355142,roll=0.00144902965985
 Velocity: [-0.02, 0.03, 0.0]
 GPS: GPSInfo:fix=3,num_sat=10
 Groundspeed: 0.0
 Airspeed: 0.0
 Gimbal status: Gimbal: pitch=None, roll=None, yaw=None
 Battery: Battery:voltage=12.587,current=0.0,level=100
 EKF OK?: True
 Last Heartbeat: 0.665645725967
 Rangefinder: Rangefinder: distance=None, voltage=None
 Rangefinder distance: None
 Rangefinder voltage: None
 Heading: 353
 Armed: False
 Is Armable?: True
 System status: STANDBY
 Mode: STABILIZE
Completed
user@workstation:~/Bitol/VirtualDroneSolution/DeveloperAPI/DroneKit$
```

## DroneKit-Python :: JMAVSim

```bash
user@workstation:~$ cd src/Fimrware
user@workstation:~/src/Firmware$ make posix jmavsim
```

```bash
user@workstation:~$ mavproxy.py --master=udp:127.0.0.1:14550 --out=udpout:127.0.0.1:14560 --out=udpout:127.0.0.1:14570 --out=udpout:127.0.0.1:14580
```

```bash
user@workstation:~$ cd Bitol/VirtualDroneSolution/DeveloperAPI/DroneKit/
user@workstation:~/Bitol/VirtualDroneSolution/DeveloperAPI/DroneKit$
```

Port 14580

```bash
# Copter should arm in GUIDED mode
# vehicle.mode    = VehicleMode("GUIDED")
# vehicle.mode    = VehicleMode("POSCTL")
MAV_MODE_AUTO   = 4
```

```bash
user@workstation:~/Bitol/VirtualDroneSolution/DeveloperAPI/DroneKit$ python DroneKitPythonLocation.py 
Connecting
Waiting for home position...
 Type: 2
 Armed: False
 System status: STANDBY
 GPS: GPSInfo:fix=3,num_sat=10
 Alt: -0.004
>>> Executing mission.
>>> Takeoff to 10.0 meters above home.
>>> Mission finished, landed.
>>> Executing mission.
>>> Takeoff to 10.0 meters above home.
>>> ARMED by arm/disarm component command
>>> Takeoff detected
Moving to waypoint 2
Moving to waypoint 3
Moving to waypoint 4
Moving to waypoint 5
Moving to waypoint 6
>>> Mission finished, landed.
>>> Landing detected
>>> DISARMED by auto disarm on land
>>> Executing mission.
>>> Takeoff to 10.0 meters above home.
user@workstation:~/Bitol/VirtualDroneSolution/DeveloperAPI/DroneKit$
```

Manual Mode, Port 14570, Set Copter in GUIDED mode

```bash
user@workstation:~$ ./QGroundControl.AppImage
```

```bash
QGroundControl Settings 14570
```

## DroneKit-Python :: Ardupilot SITL

```bash
user@workstation:~$ cd Bitol/
user@workstation:~/Bitol$ source Main.sh 
user@workstation:~/Bitol$ DroneKit.sh start
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://theiotlearninginitiative.gitbook.io/bitol/virtual-drone-solution/developer-api/dronekit.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
