Pymavrest - Python RESTful API for MAVLink enabled vehicles

Pymavrest is another RESTful API for MAVLink enabled vehicles written in Python.

With Pymavrest, you can easily monitor vehicle state (MAVLink messages) programmatically (using any programming language capable of doing HTTP POST/GET requests) or from your favorite browser, as a JSON object.

Here are the ready-to-use, key features:

  • Get all vehicular data at once.
  • Get a specific message by name or message id.
  • Get timestamp (wall clock, monotonic counter) or rate of messages at once, by name, message id.
  • Try to reconnect to master after some specific time if no message is received during some period.
  • Drop non-periodic messages after some specific time.
  • Whitelist & blacklist support of messages, if you only want or don’t want to see some specific messages.
  • Get all on-board parameters or a specific one.

This started as a self-paced project and it is still in its early phases, many more features will come.
Hope this will be useful to those who want to show vehicle state in some graphical interfaces or monitor vehicle state from different processes.
Feel free to comment down below, and if you want to see some features, face an issue, trouble using it, please create an issue on GitHub.
Happy coding :slight_smile:

2 Likes

Excellent !
It would be nice if you can sync with GitHub - patrickelectric/mavlink2rest: mavlink2rest creates a REST server that provides mavlink information from a mavlink source to have a commun rest protocol !

1 Like

Noted, will do it as soon as possible.

@patrickelectric do you still have the rest protocol documenation somewhere ?

Well that isn’t mandatory, but that would be nice to note have yet another web protocole !

Hi @khancyr,

The documentation is in the README, there is also generic support for all MAVLink messages inside the autopilotmega dialect supported by rust-mavlink.
There is the swagger documentation webpage provided in /docs:
image

Hi @Mustafa_Gokce,

Nice work! Do you have a benchmark table or something closer to compare with mavlink2rest ?
It was initially projected with Rust for performance reasons, and also to provide the tool as a single binary, making it easier to integrate with embedded linux solutions.
Is there also a websocket for async mavlink messages (Like parameters) ?

Thanks.
I will try to implement your suggestions.
I did a quick hammering benchmark on my laptop (not a fancy one) like the one below (will do a comprehensive one later).

import requests
import time

time_max = 0
while True:
    time_initial = time.monotonic()
    data = requests.get("http://127.0.0.1:2609/get/message/all").json()
    time_final = time.monotonic()
    time_delta = time_final - time_initial
    if time_delta > time_max:
        time_max = time_delta
        print(time_max)

I spawned this code 8 times and get at most 0.015 seconds on each client which gives a roughly 66Hz update rate, note that this endpoint contains all the telemetry data (maybe I reached the limits of requests module, IDK).
So seems like the API can handle 500Hz releasing all the data.
Of course, to compare I need to do this test with both pymavrest and mavlink2rest on the same device (especially on SBCs like RPi).
But basic functionality is there :smiley: