# Drone Apps & APIs

Drone APIs let you write code to control and integrate with PX4-powered vehicles, without having to understand intimate details of the vehicle and flight stack, or having to think about safety-critical behaviour.

For example, you might want to create new "smart" flight modes, or custom geofence modes, or integrate new hardware. Drone APIs allow you to do this using high level instructions in your programming language of choice, and the code can then run on-vehicle in a [companion computer](/px4-user-guide/drone_parts/companion_computer.md) or from a ground station. Under the the hood the APIs communicate with PX4 using [MAVLink](/px4-user-guide/development/middleware/mavlink.md) or [uXRCE-DDS](/px4-user-guide/development/middleware/uxrce_dds.md).

PX4 supports the following SDKs/Robotics tools:

* [MAVSDK](https://mavsdk.mavlink.io/)
* [ROS 2](/px4-user-guide/robotics/ros.md)
* [ROS 1](/px4-user-guide/robotics/ros.md)

## What API should I use?

We recommend using MAVSDK where possible, primarily because it is far more intuitive and easier to learn. It can also run on more operating systems and less performant-hardware.

You may prefer ROS if you already know how to use it, or if you want to leverage pre-existing integrations (for example computer vision tasks). More generally, ROS is likely to be a better choice for tasks that require very low latency or a deeper integration with PX4 than is provided by MAVLink.

The main difference are:

* **MAVSDK:**
  * Intuitive and optimised for drones, with a small learning curve and easy setup.
  * You can write apps in C++, Python, Swift, Java, Go, and more.
  * Runs on resource-constrained hardware
  * Runs on broad range of OSs, including Android, Linux, Windows.
  * Communicates over MAVLink.
    * Stable and widely supported.
    * Limited to MAVLink services - needed information may not be exposed.
    * Latency may be too high for some use cases.
* **ROS:**
  * General-purpose robotics API that has been extended to support drone integration:
    * Conceptually not as well optimised for drones
    * Significant learning curve
  * Many pre-existing libraries: useful for code-reuse.
  * Supports C++ and Python libraries
  * Runs on Linux
  * ROS 2 is the latest version, which connects via DDS.
    * DDS interface layer allows deep integration into any aspect of PX4 that is exposed as a UORB topic (almost everything).
    * Can provide much lower latency.
    * Still under development. At time of writing requires a deeper understanding of PX4 than ROS 1
  * ROS 1 is the older version that can connect over MAVLink or via ROS 2. Users are encouraged to update to ROS 2 for new projects.


---

# 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://px4.gitbook.io/px4-user-guide/robotics.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.
