Git Product home page Git Product logo

mavsdk-docs's Introduction

Build Status

MAVLink

MAVLink -- Micro Air Vehicle Message Marshalling Library.

MAVLink is a very lightweight, header-only message library for communication between drones and/or ground control stations. It consists primarily of message-set specifications for different systems ("dialects") defined in XML files, and Python tools that convert these into appropriate source code for supported languages. There are additional Python scripts providing examples and utilities for working with MAVLink data.

Tip MAVLink is very well suited for applications with very limited communication bandwidth. Its reference implementation in C is highly optimized for resource-constrained systems with limited RAM and flash memory. It is field-proven and deployed in many products where it serves as interoperability interface between components of different manufacturers.

Quick start

Generate C headers

To install the minimal MAVLink environment on Ubuntu LTS 20.04 or 22.04, enter the following on a terminal:

# Dependencies
sudo apt install python3-pip

# Clone mavlink into the directory of your choice
git clone https://github.com/mavlink/mavlink.git --recursive
cd mavlink

python3 -m pip install -r pymavlink/requirements.txt

You can then build the MAVLink2 C-library for message_definitions/v1.0/common.xml from the /mavlink directory as shown:

python3 -m pymavlink.tools.mavgen --lang=C --wire-protocol=2.0 --output=generated/include/mavlink/v2.0 message_definitions/v1.0/common.xml

Use from cmake

To include the headers in cmake, install them locally, e.g. into the directory install:

cmake -Bbuild -H. -DCMAKE_INSTALL_PREFIX=install -DMAVLINK_DIALECT=common -DMAVLINK_VERSION=2.0
cmake --build build --target install

Then use find_package to get the dependency in CMakeLists.txt:

find_package(MAVLink REQUIRED)

add_executable(my_program my_program.c)

target_link_libraries(my_program PRIVATE MAVLink::mavlink)

And pass the local install directory to cmake (adapt to your directory structure):

cd ../my_program
cmake -Bbuild -H. -DCMAKE_PREFIX_PATH=../mavlink/install

For a full example, check examples/c.

Note: even though we use target_link_libraries in cmake, it doesn't actually "link" to MAVLink as it's just a header-only library.

Other instructions

Instructions for using the C libraries are then covered in Using C MAVLink Libraries (mavgen).

Note: Installing the MAVLink Toolchain explains how to install MAVLink on other Ubuntu platforms and Windows, while Generating MAVLink Libraries explains how to build MAVLink for the other programming languages supported by the project. The sub-topics of Using MAVLink Libraries explain how to use the generated libraries.

Key Links

mavsdk-docs's People

Contributors

bazfp avatar bys1123 avatar carlolsson avatar cbjornram avatar cnpcshangbo avatar crowdedlight avatar dagar avatar dakejahl avatar danielhonies avatar dlech avatar hamishwillee avatar jonasvautherin avatar julianoes avatar junwoo091400 avatar katawann avatar levevg avatar maetugr avatar mrpollo avatar raceking37 avatar sfuhrer avatar shrit avatar takamasanumuro avatar unipheas avatar ytaskiran avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mavsdk-docs's Issues

Doc Bug: Connecting to Systems (Vehicles) · MAVSDK Guide

@JonasVautherin This problem has come up a few times - people do not know how to format the strings, and all our examples use SITL.

What we need to do is add connection string info for common cases. Probably in Connecting to Systems (Vehicles) · MAVSDK Guide, and either linked or reproduced in http://mavsdk-python-docs.s3-website.eu-central-1.amazonaws.com/#run-the-examples

Also add the info about how you can get it on linux using dmesg.

Some of the options to cover:

  • Linux computer connected to the vehicle via Serial port - presumably for a companion like RaPi? - "serial:///dev/ttyACM0" [as above - do we need these three forward slashes at start?]
  • Linux computer via USB - "serial /dev/ttyUSB0"? [Can we see this via dmesg?]
  • SITL connected to the vehicle via UDP -
  • SITL connected to the vehicle via TCP -
  • OSX computer connected to the vehicle via USB -
  • Windows computer connected to the vehicle via USB (in this case on COM1) |- ?
  • Windows computer connected to the vehicle telemetry radio?
  • Any more.

Upshot, let's have a link that people can find this one.

Can you fill in the table, and show me an example output of using dmesg?

Doc Bug: FAQ - CAMERA_INFORMATION doc not clear

Bug Page: FAQ · DroneCore Guide

Re

> ### Why is libCURL a dependency?

-libCURL will be required to download the camera definition file which is referenced in [CAMERA_INFORMATION](http://mavlink.org/messages/common#CAMERA_INFORMATION). It might also come in handy whenever any other REST resources are required.       

This needs to be updated because it isn't clear why DroneCore needs CAMERA_INFORMATION

This requires camera plugin - still not open sourced - note, follow up with @julianoes .

class ParamsRaw ·- how does this work in the Python library?

class ParamsRaw

  • IN theory you can send all types here MAV_PARAM_TYPE but you only provide interfaces for a few
  • In the Python API how are types managed? Specifically, you can use an API like this to get a real or a bool or whatever, and you know what type it is. However once you have the parameter (an int say), Python doesn't know if it float, int32, uint64 or whatever. So if you store this value and decide to send the parameter again later, how do you "remember" what the type of the incoming parameter was so you can send it appropriately?

takeoff command denied

I've been trying to run the takeoff_and_land.py example on a live drone. The drone connects, it arms briefly (1-3 sec), then the motors stop and the result is COMMAND_DENIED: origin: takeoff(): params().
I can takeoff and even run missions directly from QGC without issue. Seems there's something QGC is doing that the example code is not.

Getting the error: mavsdk.action.ActionError: COMMAND_DENIED:, when doing "python3 takeoff_and_land.py"

I set up an environment on my Raspberry Pi 4, mavproxy + mavsdk + pixhawk

The mavproxy command (which I run from the Raspberry, works as intended):

mavproxy.py --master=/dev/ttyACM0 --out=udp:127.0.0.1:14540 --out=udp:127.0.0.1:14550 --out=udp:127.0.0.1:14560 --out=udp:192.168.1.107:14540 --out=udp:192.168.1.107:14550 --out=udp:192.168.1.107:14560 --out=udp:192.168.1.107:57600 --aircraft=ABZERO --daemon &

The connection to Mission Planner:
Mission Planner Screenshot

takeoff_and_land.py actual code:

#!/usr/bin/env python3

import asyncio
from mavsdk import System


async def run():

    drone = System()
    await drone.connect(system_address="serial:///dev/ttyACM0:57600")

    print("Waiting for drone to connect...")
    async for state in drone.core.connection_state():
        if state.is_connected:
            print(f"Drone discovered with UUID: {state.uuid}")
            break

    print("Waiting for drone to have a global position estimate...")
    async for health in drone.telemetry.health():
        if health.is_global_position_ok:
            print("Global position estimate ok")
            break

    print("-- Arming")
    await drone.action.arm()

    print("-- Taking off")
    await drone.action.takeoff()

    await asyncio.sleep(5)

    print("-- Landing")
    await drone.action.land()


if __name__ == "__main__":
    loop = asyncio.get_event_loop()
    loop.run_until_complete(run())

The actual error when doing takeoff_and_land.py:

pi@raspberrypi:~/drone $ python3 takeoff_and_land.py
Waiting for mavsdk_server to be ready...
Connected to mavsdk_server!
Waiting for drone to connect...
Drone discovered with UUID: 0
Waiting for drone to have a global position estimate...
Global position estimate ok
-- Arming
-- Taking off
Traceback (most recent call last):
  File "takeoff_and_land.py", line 38, in <module>
    loop.run_until_complete(run())
  File "/usr/lib/python3.7/asyncio/base_events.py", line 584, in run_until_complete
    return future.result()
  File "takeoff_and_land.py", line 28, in run
    await drone.action.takeoff()
  File "/home/pi/.local/lib/python3.7/site-packages/mavsdk/action.py", line 360, in takeoff
    raise ActionError(result, "takeoff()")
mavsdk.action.ActionError: COMMAND_DENIED: 'Command Denied'; origin: takeoff(); params: ()
Exception ignored in: <function System.__del__ at 0xb5387660>
Traceback (most recent call last):
  File "/home/pi/.local/lib/python3.7/site-packages/mavsdk/system.py", line 54, in __del__
  File "/home/pi/.local/lib/python3.7/site-packages/mavsdk/system.py", line 90, in _stop_mavsdk_server
ImportError: sys.meta_path is None, Python is likely shutting down

The mavproxy output when I do takeoff_and_land.py:

ARMED
Arming checks disabled
APM: finished motor test
DISARMED

Rename Taking Off and Landing to Actions ...

The topic "Taking Off and Landing" covers all actions. I named it that because taking off and landing is the action that people first try to do. However this does a lot more than just those actions now.

So plan is to rename

  • TOC: Actions
  • Page: Actions - Taking Off , Landing, RTL (OR at least see how this looks)

Camera/Gimbal guide and example docs

The Gimbal and Camera plugins currently have API reference.

  • Need to create a guide page explaining how to use camera and gimbal
  • should cover options - ie both missions and outside of missions.
  • Should show main API options.
  • Should link to the integration tests.

Possibly also create example, but that could wait.

Related issues:

Add note asking for support from Windows developers

Some C++ library build functionality is not supported "seamlessly" on Windows builds. For example, you can't automatically build docs, and the system install does not work.

Action is to add a note asking for help. Probably in the contribution section, but also in the "current status" or roadmap sections. Maybe also on README for the DroneCore repo.

Noticed potentially outdated documentation within MAVSDK on C++

I recently updated MAVSDK on my project and noticed that using mavsdk within my project does not match the documentation.

The documentation recommends initialization like:

`
Mavsdk mavsdk;

ConnectionResult connection_result = mavsdk.add_any_connection("udp://:14540");
`

but the above code does not work anymore because the default constructor has been deleted. Reading through the repo I was able to resolve my issue, but just wanted to make sure that the documentation is outdated and I am using MAVSDK correctly. If the documentation is outdated, I am open to spending sometime refining portions of the documentation.

LAND mode blocks arming

I thought I should open this as it's own issue and maybe there's a short answer. When running the takeoff_and_land.py example, the drone (live drone over RFD900 telemetry) remains in LAND mode after land command. This prevents arming until the mode is changed to an armable mode - thru QGC or an RC TX.
From what I've found, there's no way change mode or really even see mode (it's always mode = UNKNOWN). When TAKEOFF is executed it switches to GUIDED mode (according to the documentation). Shouldn't ARM do the same thing, or does it already?

a

a

Serial Connection to Jetson Xavier

I am trying to connect via serial (ttyUSB0) from pixhawk to a jetson xavier. I have installed mavsdk-python via pip3 and I am trying to execute examples/takeoff_and_land.py. With the only difference that

await drone.connect(system_address="udp://:14545")

has been changed to

await drone.connect(system_address="serial:///dev/ttyUSB0")
However I am getting the following error

This installation does not provide an embedded 'mavsdk_server' binary.
If you installed using pip, this means that 'mavsdk_server' is not distributed
for your platform yet (e.g. arm).

You will need to get and run the 'mavsdk_server' binary manually:

  1. Download 'mavsdk_server' from: https://github.com/mavlink/mavsdk/releases
     or build it from source.

  2. Run it, e.g. on port 50051:
     './mavsdk_server -p 50051'

  3. Set the 'mavsdk_server_address' and port when creating the System:
     'drone = System(mavsdk_server_address='localhost', port=50051)'

Any ideas why this is happening ?
P.S I have checked that the FTDI is connected to ttyUSB0. I have enabled the mavlink connection (MAV_1_CONFIG = TELEM 2). I am using a HITL approach via AirSim (Although I believe that this is not relevant)

Update docs to choose reference over pointer

As discussed here: mavlink/MAVSDK#314. Depends on this PR: mavlink/MAVSDK#316

From a docs perspective this pretty much involves doing a global search->replace of "&device" to device where the device is used:

auto telemetry = std::make_shared<Telemetry>(&device);

TO

auto telemetry = std::make_shared<Telemetry>(device);

BUT cannot do a pure replace, because we still create the reference in the same way:

Device &device = dc.device();

Will also need to rebuild API reference.

Re run all example docs to fix up device_impl.cpp

Low priority, but all the examples precede the update where device_impl.cpp was renamed device.cpp. As a result the console log has Debug messages from the device_impl file that no longer exists.

Action is to run the examples again and update the console log.

Low priority

Document how to write/run tests for external plugins

Currently running tests on external plugins is broken. The docs have been updated to some extent, but can't be tested (and could be wrong because of that).

Action to update docs on how to do this, once the functionality is fixed:

  • Information on how to run integration tests for external plugins
  • Information on how to run unit tests for external plugins

Note, this follows on from #95

Add debugging topic

Seed with information here: mavlink/MAVSDK#150 (comment)

Add info on developer logging - ie both messages you can add to plugins, and the message logging for all MAVLink comms: https://docs.dronecore.io/v/develop/en/contributing/dev_logging.html#message_logging

Perhaps start a FAQ on how to deal with particular types of issues - e.g. "What do to if you get a timeout" - with "ways to check that message is actually sent".

For this, from Julian - to solve this problem (timeout)

  • You need to know that a mavlink command gets published as a uORB vehicle_command
  • And that a vehicle_command_ack as a mavlink command ack again

Fix up installation and example docs when 130 deb fix goes in

mavlink/MAVSDK#130

  • Change Builds to reflect system wide install default
  • Update examples to include new CMakeLists
  • Update guide to explain how to create CMakeLists
  • Test can build apiref and update
  • Test can build debug/release and update
  • Test everything on windows and update appropriately .
  • Remove requirement to link against pthread (now done inside dronecore)
  • Confirm all the other ios build etc stuff works.
  • Confirm and doc external library build. Do in both build doc and the extension doc.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.