MAVLink to REST API

Hi,

I’m working to improve a mavlink to rest api tool, it provides any message and any valid element thanks to rust-mavlink library.
There is binaries available to download for MacOS, Linux (x64, ARM) and Windows, it’s also possible to install via cargo command line.
You can get useful information and a list of available messages:

You can fetch a message and use the pretty query element to visualize the json:

And it’s possible to get any element of such jsons individually:

Any feedback or feature request would be much appreciate!

6 Likes

Looks interesting. Will you be doing any POST to change params or upload missions?

Yes, Im already working to add this feature.

Feel free to plug this on the mavlink mailing list: mavlink@googlegroups.com
@hamishwillee

that is very nice ! At least we would be able to have some web support !

Cool. I am working on something a little similar (with pymavlink and bottlepy) but very specific to Rover and my coding skills are ordinary so we will see where it goes. I’ll be keeping an eye on yours for ideas!

Hi,

The last version 0.5.0 now supports POST methods, you can ARM and DISARM the drone with:

#! /bin/env bash
# ARM: Change param1 to 1.0
# DISARM: Change param1 to 0.0
curl --request POST http://0.0.0.0:8088/mavlink -H "Content-Type: application/json" --data \
'{
  "header": {
    "system_id": 1,
    "component_id": 1,
    "sequence": 0
  },
  "message": {
    "type":"COMMAND_LONG",
    "param1":0.0,
    "param2":0.0,"param3":0.0,"param4":0.0,"param5":0.0,"param6":0.0,"param7":0.0,
    "command":{
      "type":"MAV_CMD_COMPONENT_ARM_DISARM"
    },
    "target_system":0,
    "target_component":0,
    "confirmation":0
  }
}'

You also should be able to upload mission with it, but I have not tested.

The last version also has a new feature:

3 Likes

Hi @patrickelectric was keen to try this out tonight as it looks like it could be very helpful. I compiled this on my pi from cargo. I can get the webserver to run but it does not seem to access any mavlink data. I have attached a screenshot first of successful connection with mavproxy, then to mavlink2rest.

Going to web server loads webpage but does not seem to have any mavlink data.

Can you please give my any tips to resolve?

Changed SERIAL1_PROTOCOL to 2 and it seems to be working now.

Hi @BenRB ,

Thanks for your feedback, I have added a new option mavlink for you to specify which version of mavlink do you want to use, but by defualt is still mavlink 2.

I also have done a new release with this feature (0.6.0), it’s available in github and via cargo.

Let me know if you have any further questions.

1 Like

Just to updated this post.

mavlink2rest (0.8.0) now supports ardupilotmega dialect, and should handle all messages from ArduPilot vehicles, for both GET and POST methods.
Here an example of all messages parsed by ArduPlane SITL test.
It also deploys ARMv6 binary besides ARMv7 to allow compatibility with boards such as Raspberry Pi A or Zero.

1 Like

Just a kind update.

mavlink2rest (0.9.0) now supports websockets, it support multiple websockets and a regex filter for the client to not receive undesirable messages. E.g: /ws/mavlink?filter=^RC will match RC_CHANNELS_RAW and RC_CHANNELS, and /ws/mavlink?filter=RAW$ will match SERVO_OUTPUT_RAW and RC_CHANNELS_RAW.

With this feature it’s possible to receive messages asynchronously and messages that are necessary to be processed multiple times, like PARAM_VALUE after PARAM_REQUEST_LIST.

2 Likes

Update for the latest version.

mavlink2rest (0.10.0) now supports bidirectional websocket, can be used to receive and send mavlink messages over it, this makes the API more flexible without the necessity to handle multiple endpoints.
Windows binaries are back and available for download.

I have been working in a web based GCS to demonstrate some cool functionalities with mavlink2rest, hope to share it soon.

3 Likes

Hello Patrick,
very interesting project - which may open some new ways of doing things; thanks for sharing it.

I was wondering, if you might have a hardware recommendation for suitable telemetry links in conjunction with your software?

Hi @camti,

mavlink2rest supports multiple connection methods, so it’s not restricted to any hardware or operating system.
You can use it with UDP, TCP, serial or just a simple file, one of these is probably supported by any hardware that you want to try. I have used it with pixhawks, SITL, telemetry files, ardupilot linux and arduino running mavlink.

Thanks! (I had mistakenly thought it would require a TCP/ Ethernet link.)

Could you please add some starting options on the github readme?

For example if i want to start it listening on an udp port where mavlink is coming and publish on another port what would be the starting syntax?

Thanks, great work!!

Hi @Corrado_Steri,

Thanks for the comment, that’s usually documented by the help command: mavlink2rest --help, it’ll provide all necessary information.

But, just to make sure and friendly to new users, I have added it on README as you suggested.

Great thanks!!!

Corrado

Maybe a few more lines on how to install it, do we need to install rust? or sudo apt install cargo is ok?