Giter Site home page Giter Site logo

mavlink / mavlink2rest Goto Github PK

View Code? Open in Web Editor NEW
73.0 11.0 26.0 641 KB

mavlink2rest creates a REST server that provides mavlink information from a mavlink source

License: MIT License

Rust 74.59% HTML 17.44% Python 6.76% Dockerfile 1.21%
mavlink drone rest rest-api rest-server ardupilot companion-computer companion rust rust-mavlink mavlink-information cargo mavlink-source mavlink2rest hacktoberfest

mavlink2rest's Introduction

Mavlink2Rest

Build Test Cargo download Crate info Documentation

mavlink2rest is a tool that offers a RESTful API over the MAVLink protocol, facilitating seamless communication between unmanned systems and web applications. The tool supports the ArduPilotMega dialect, iCAROUS, and UAVionix, making it an ideal solution for developers who want to build custom interfaces for unmanned systems.

The current version supports the ardupilotmega dialect, that includes common, icarous and uavionix.

Grab it

Downloads ๐Ÿ“ฆ

Latest builds:

For others or different releases, check the releases menu.

Install โšก

If you prefer, you can install via cargo, if you don't know what it is, use the download section.

  • โš™๏ธ Cargo Install: cargo install mavlink2rest

Help

Capabilities via the command line:

USAGE:
  mavlink2rest [FLAGS] [OPTIONS]

FLAGS:
  -h, --help       Prints help information
  -V, --version    Prints version information
  -v, --verbose    Be verbose

OPTIONS:
      --component-id <COMPONENT_ID>
          Sets the component ID for this service, for more information, check:
          https://mavlink.io/en/messages/common.html#MAV_COMPONENT [default: 0]
  -c, --connect <TYPE:<IP/SERIAL>:<PORT/BAUDRATE>>
          Sets the mavlink connection string [default: udpin:0.0.0.0:14550]

      --mavlink <VERSION>
          Sets the mavlink version used to communicate [default: 2]  [possible values: 1, 2]

  -s, --server <IP:PORT>
          Sets the IP and port that the rest server will be provided [default: 0.0.0.0:8088]

      --system-id <SYSTEM_ID>                Sets system ID for this service. [default: 255]

Using Docker with mavlink2rest

You can also use the mavlink2rest with docker, the following command will start the service with the default settings:

docker run --rm --init -p 8088:8088 -p 14550:14550/udp --name mavlink2rest mavlink/mavlink2rest

The Dockerfile defines several environment variables that you can override at runtime:

MAVLINK_SRC: The MAVLink source connection string. Default is udpin:127.0.0.1:14550. SERVER_PORT: The IP and port for the REST server. Default is 0.0.0.0:8088. EXTRA_ARGS: Any additional command line arguments you want to pass to mavlink2rest. To customize these settings, use the -e flag with docker run:

docker run --rm --init\
    -p 8088:8088 \
    -p 14551:14551/udp \
    -e MAVLINK_SRC="udpin:0.0.0.0:14551" \
    -e SERVER_PORT="0.0.0.0:8088" \
    --name mavlink2rest mavlink/mavlink2rest

to build the docker image locally, you can use the following command:

docker build --build-arg TARGET_ARCH=x86_64-unknown-linux-musl -t mavlink/mavlink2rest .

Endpoints

Pages

  • Main webpage: GET /
    • Provides information about mavlink2rest and available messages.
  • Swagger: GET /docs
    • Provides information about mavlink2rest endpoints for the REST API.

API

  • MAVLink JSON:
  • Information:
    • GET /info, provides information about the service version.
      • http://0.0.0.0:8088/info
        {
          "version": 0,
          "service": {
            "name": "mavlink2rest",
            "version": "0.10.0",
            "sha": "bd7667d",
            "build_date": "2021-03-03",
            "authors": "Author <email>"
          }
        }

Examples

Get all messages:
curl --request GET http://0.0.0.0:8088/v1/mavlink
# The output is huge, you can get it here: [https://gist.github.com/patrickelectric/26a407c4e7749cdaa58d06b52212cb1e](https://gist.github.com/patrickelectric/26a407c4e7749cdaa58d06b52212cb1e)
Get attitude:
curl --request GET http://0.0.0.0:8088/v1/mavlink/vehicles/1/components/1/messages/ATTITUDE
{
  "message": {
    "pitch": 0.11506611853837967,
    "pitchspeed": 0.00003909762017428875,
    "roll": 0.02339238114655018,
    "rollspeed": 0.00035849903360940516,
    "time_boot_ms": 87110407,
    "type": "ATTITUDE",
    "yaw": -2.4364013671875,
    "yawspeed": 0.000020137056708335876
  },
  "status": {
    "time": {
      "counter": 22750,
      "first_update": "2024-05-31T11:59:44.313941926-03:00",
      "frequency": 5.495169162750244,
      "last_update": "2024-05-31T13:08:45.196118069-03:00"
    }
  }
}
Get time of last ATTITUDE message:
curl --request GET http://0.0.0.0:8088/v1/mavlink/ATTITUDE/status/time/last_update
"2020-03-28T14:28:51.577853-03:00"
Get a message structure example:
curl --request GET http://0.0.0.0:8088/v1/helper/mavlink?name=ATTITUDE
{
  "header": {
    "system_id": 255,
    "component_id": 0,
    "sequence": 0
  },
  "message": {
    "type": "ATTITUDE",
    "time_boot_ms": 0,
    "roll": 0.0,
    "pitch": 0.0,
    "yaw": 0.0,
    "rollspeed": 0.0,
    "pitchspeed": 0.0,
    "yawspeed": 0.0
  }
}
Request vehicle to be armed:
# ARM: param1 is 1.0
curl --request POST http://0.0.0.0:8088/v1/mavlink -H "Content-Type: application/json" --data \
'{
  "header": {
    "system_id": 255,
    "component_id": 240,
    "sequence": 0
  },
  "message": {
    "type":"COMMAND_LONG",
    "param1": 1.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": 1,
    "target_component": 1,
    "confirmation": 1
  }
}'
Request vehicle to be disarmed:
# ARM: param1 is 0.0
curl --request POST http://0.0.0.0:8088/v1/mavlink -H "Content-Type: application/json" --data \
'{
  "header": {
    "system_id": 255,
    "component_id": 240,
    "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": 1,
    "target_component": 1,
    "confirmation": 1
  }
}'

Note: For any invalid GET, you'll receive a 404 response with the error message. Note: The endpoints that allow GET and provides a JSON output, also allow the usage of the query parameter pretty with a boolean value true or false, E.g: http://0.0.0.0:8088/helper/mavlink?name=COMMAND_LONG&pretty=true

Websocket

It's also possible to connect multiple websockets with the following path /ws/mavlink, the endpoint also accepts the query parameter filter, the filter value should be a regex that matches MAVLink message names, E.g: /ws/mavlink?filter=.* for all messages, /ws/mavlink?filter=RC_.* will match RC_CHANNELS_RAW and RC_CHANNELS, resulting in the following output:

{ // First message
  "header": {
    "component_id": 1,
    "sequence": 98,
    "system_id": 1
  },
  "message": {
    "chan10_raw": 0,
    "chan11_raw": 0,
    "chan12_raw": 0,
    "chan13_raw": 0,
    "chan14_raw": 0,
    "chan15_raw": 0,
    "chan16_raw": 0,
    "chan17_raw": 0,
    "chan18_raw": 0,
    "chan1_raw": 1500,
    "chan2_raw": 1500,
    "chan3_raw": 1500,
    "chan4_raw": 1500,
    "chan5_raw": 1500,
    "chan6_raw": 1500,
    "chan7_raw": 1500,
    "chan8_raw": 1500,
    "chan9_raw": 0,
    "chancount": 16,
    "message_information": {
      "counter": 3732,
      "frequency": 4.0,
      "time": {
        "first_message": "2020-09-01T20:36:24.088099-03:00",
        "last_message": "2020-09-01T20:51:57.278901-03:00"
      }
    },
    "rssi": 0,
    "time_boot_ms": 3122812,
    "type": "RC_CHANNELS"
  }
}
{ // Second message
  "header": {
    "component_id": 1,
    "sequence": 98,
    "system_id": 1
  },
  "message": {
    "chan1_raw": 1500,
    "chan2_raw": 1500,
    "chan3_raw": 1500,
    "chan4_raw": 1500,
    "chan5_raw": 1500,
    "chan6_raw": 1500,
    "chan7_raw": 1500,
    "chan8_raw": 1500,
    "message_information": {
      "counter": 3732,
      "frequency": 4.0,
      "time": {
        "first_message": "2020-09-01T20:36:24.088310-03:00",
        "last_message": "2020-09-01T20:51:57.279438-03:00"
      }
    },
    "port": 0,
    "rssi": 0,
    "time_boot_ms": 3122812,
    "type": "RC_CHANNELS_RAW"
  }
}

For a demonstration, please check the example under the examples filder: websocket_client.py

Benchmark

The following benchmarks were extracted from a raspberry pi 3 connected to a pixhawk running ArduSub.

  • In idle.

    6% CPU usage
    
  • 1 client requesting all mavlink messages at 10Hz

    9% CPU usage
    
  • 1 client requesting all mavlink messages at 100Hz

    20% CPU usage (~5% each core)
    
  • 1 websocket with no filters

    11% CPU usage
    
  • 5 websockets with no filters

    24% CPU usage (14% @ 1 core, ~3% @ 3 cores)
    
  • 20 websockets with filter only for ATTITUDE message (receiving at 10Hz)

    9% CPU usage
    
  • 20 websockets with filter only for NAMED_VALUE_FLOAT message (receiving at 70Hz)

    17% CPU usage (9% @ 1 core, ~2% @ 3 cores)
    
  • 20 websockets with no filters

    48% CPU usage (20% @ 1 core, ~9% @ 3 cores)
    
  • 1 client requesting all mavlink messages 1000 times

    60% CPU usage (~15% each core)
    Time taken for tests      3.7 seconds
    Total requests            1000
    Successful requests       1000
    Failed requests           0
    Requests per second       273.60 [#/sec]
    Median time per request   3ms
    Average time per request  4ms
    
  • 10 clients requesting all mavlink messages, 100 requests for each client.

    140% CPU usage (~46% each core)
    Time taken for tests      1.4 seconds
    Total requests            1000
    Successful requests       1000
    Failed requests           0
    Requests per second       733.14 [#/sec]
    Median time per request   13ms
    Average time per request  13ms
    Sample standard deviation 3ms
    
  • 100 clients requesting all mavlink messages, 1000 requests for each client.

    140% CPU usage (~46% each core)
    Time taken for tests      13.8 seconds
    Total requests            10000
    Successful requests       10000
    Failed requests           0
    Requests per second       725.83 [#/sec]
    Median time per request   132ms
    Average time per request  137ms
    Sample standard deviation 54ms
    

mavlink2rest's People

Contributors

ericjohnson97 avatar joaoantoniocardoso avatar joaomario109 avatar khancyr avatar noahbliss avatar patrickelectric avatar raultrombin avatar rotu avatar williangalvani avatar zhiburt avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  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  avatar  avatar

mavlink2rest's Issues

Thread panic when changing flight mode

Running the stock Ardusub Pi Image, with the Mavlink2Rest 0.6.0 release binary. Vehicle is using ArduRover 4.0 Stable.

When I change the flight mode (in QGC), the Mavlink2Rest server crashes with the following output

pi@champ:~/companion/tools $ ./mavlink2rest --connect udpin:127.0.0.1:9002 --server 0.0.0.0:4777
MAVLink connection string: udpin:127.0.0.1:9002
REST API address: 0.0.0.0:4777
thread '<unnamed>' panicked at 'Unexpected enum value 11.', /target/armv7-unknown-linux-musleabihf/release/build/mavlink-c1b7c2ed7a6a321a/out/common.rs:4124:13
stack backtrace:
   0:   0x60a6c4 - backtrace::backtrace::libunwind::trace::h2740b7779bb3fbf6
                       at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.40/src/backtrace/libunwind.rs:88
   1:   0x60a6c4 - backtrace::backtrace::trace_unsynchronized::hc587e09a69bdc583
                       at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.40/src/backtrace/mod.rs:66
   2:   0x60a6c4 - std::sys_common::backtrace::_print_fmt::hde9114c81a02c611
                       at src/libstd/sys_common/backtrace.rs:77
   3:   0x60a6c4 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h069b16b4a6ea2d7a
                       at src/libstd/sys_common/backtrace.rs:59
   4:   0x6307b0 - core::fmt::write::h3fe08fe0e1c8dec3
                       at src/libcore/fmt/mod.rs:1052
   5:   0x60508c - std::io::Write::write_fmt::hb40c902bf8e5da41
                       at src/libstd/io/mod.rs:1426
   6:   0x60cb3c - std::sys_common::backtrace::_print::hc4e20dd38a1f8083
                       at src/libstd/sys_common/backtrace.rs:62
   7:   0x60cb3c - std::sys_common::backtrace::print::hf29b05d8b728a743
                       at src/libstd/sys_common/backtrace.rs:49
   8:   0x60cb3c - std::panicking::default_hook::{{closure}}::h2c253e0d3587e013
                       at src/libstd/panicking.rs:204
   9:   0x60c7b0 - std::panicking::default_hook::h637f76a8fdb3ad07
                       at src/libstd/panicking.rs:224
  10:   0x60d1ec - std::panicking::rust_panic_with_hook::h2dccb74573dc29e8
                       at src/libstd/panicking.rs:472
  11:   0x60ce00 - rust_begin_unwind
                       at src/libstd/panicking.rs:380
  12:   0x62f064 - core::panicking::panic_fmt::hc9fedf85d2814a69
                       at src/libcore/panicking.rs:85
  13:   0x62ee44 - core::option::expect_failed::hb19b537baead1f0a
                       at src/libcore/option.rs:1191
  14:   0x40d764 - mavlink::common::COMMAND_ACK_DATA::deser::h72a1b199dc63d25b
  15:   0x4284ec - <mavlink::common::MavMessage as mavlink::Message>::parse::hfbe47a60d6f17d16
  16:   0x320a8c - mavlink::read_versioned_msg::h58b4e622963d9ac3
  17:   0x30749c - <mavlink::connection::udp::UdpConnection as mavlink::connection::MavConnection<M>>::recv::h351d371a76729332
  18:   0x3f6e10 - std::sys_common::backtrace::__rust_begin_short_backtrace::h851d5b082366ffcc
  19:   0x31d090 - std::panicking::try::do_call::hb53df87ce34ece45
  20:   0x610638 - __rust_maybe_catch_panic
                       at src/libpanic_unwind/lib.rs:86
  21:   0x32908c - core::ops::function::FnOnce::call_once{{vtable.shim}}::h71edd6a2fe43f6d5
  22:   0x5ff568 - <alloc::boxed::Box<F> as core::ops::function::FnOnce<A>>::call_once::haa16aef56df3b543
                       at /rustc/b8cedc00407a4c56a3bda1ed605c6fc166655447/src/liballoc/boxed.rs:1015
  23:   0x60fec8 - <alloc::boxed::Box<F> as core::ops::function::FnOnce<A>>::call_once::hddbf5f21bb2e7945
                       at /rustc/b8cedc00407a4c56a3bda1ed605c6fc166655447/src/liballoc/boxed.rs:1015
  24:   0x60fec8 - std::sys_common::thread::start_thread::ha699d94be8e2f96d
                       at src/libstd/sys_common/thread.rs:13
  25:   0x60fec8 - std::sys::unix::thread::Thread::new::thread_start::hd01e2c359672fbae
                       at src/libstd/sys/unix/thread.rs:80

And with RUST_BACKTRACE=full:

pi@champ:~/companion/tools $ ./mavlink2rest --connect udpin:127.0.0.1:9002 --server 0.0.0.0:4777
MAVLink connection string: udpin:127.0.0.1:9002
REST API address: 0.0.0.0:4777
thread '<unnamed>' panicked at 'Unexpected enum value 11.', /target/armv7-unknown-linux-musleabihf/release/build/mavlink-c1b7c2ed7a6a321a/out/common.rs:4124:13
stack backtrace:
   0:   0x60a6c4 - backtrace::backtrace::libunwind::trace::h2740b7779bb3fbf6
                       at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.40/src/backtrace/libunwind.rs:88
   1:   0x60a6c4 - backtrace::backtrace::trace_unsynchronized::hc587e09a69bdc583
                       at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.40/src/backtrace/mod.rs:66
   2:   0x60a6c4 - std::sys_common::backtrace::_print_fmt::hde9114c81a02c611
                       at src/libstd/sys_common/backtrace.rs:77
   3:   0x60a6c4 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h069b16b4a6ea2d7a
                       at src/libstd/sys_common/backtrace.rs:59
   4:   0x6307b0 - core::fmt::write::h3fe08fe0e1c8dec3
                       at src/libcore/fmt/mod.rs:1052
   5:   0x60508c - std::io::Write::write_fmt::hb40c902bf8e5da41
                       at src/libstd/io/mod.rs:1426
   6:   0x60cb3c - std::sys_common::backtrace::_print::hc4e20dd38a1f8083
                       at src/libstd/sys_common/backtrace.rs:62
   7:   0x60cb3c - std::sys_common::backtrace::print::hf29b05d8b728a743
                       at src/libstd/sys_common/backtrace.rs:49
   8:   0x60cb3c - std::panicking::default_hook::{{closure}}::h2c253e0d3587e013
                       at src/libstd/panicking.rs:204
   9:   0x60c7b0 - std::panicking::default_hook::h637f76a8fdb3ad07
                       at src/libstd/panicking.rs:224
  10:   0x60d1ec - std::panicking::rust_panic_with_hook::h2dccb74573dc29e8
                       at src/libstd/panicking.rs:472
  11:   0x60ce00 - rust_begin_unwind
                       at src/libstd/panicking.rs:380
  12:   0x62f064 - core::panicking::panic_fmt::hc9fedf85d2814a69
                       at src/libcore/panicking.rs:85
  13:   0x62ee44 - core::option::expect_failed::hb19b537baead1f0a
                       at src/libcore/option.rs:1191
  14:   0x40d764 - mavlink::common::COMMAND_ACK_DATA::deser::h72a1b199dc63d25b
  15:   0x4284ec - <mavlink::common::MavMessage as mavlink::Message>::parse::hfbe47a60d6f17d16
  16:   0x320a8c - mavlink::read_versioned_msg::h58b4e622963d9ac3
  17:   0x30749c - <mavlink::connection::udp::UdpConnection as mavlink::connection::MavConnection<M>>::recv::h351d371a76729332
  18:   0x3f6e10 - std::sys_common::backtrace::__rust_begin_short_backtrace::h851d5b082366ffcc
  19:   0x31d090 - std::panicking::try::do_call::hb53df87ce34ece45
  20:   0x610638 - __rust_maybe_catch_panic
                       at src/libpanic_unwind/lib.rs:86
  21:   0x32908c - core::ops::function::FnOnce::call_once{{vtable.shim}}::h71edd6a2fe43f6d5
  22:   0x5ff568 - <alloc::boxed::Box<F> as core::ops::function::FnOnce<A>>::call_once::haa16aef56df3b543
                       at /rustc/b8cedc00407a4c56a3bda1ed605c6fc166655447/src/liballoc/boxed.rs:1015
  23:   0x60fec8 - <alloc::boxed::Box<F> as core::ops::function::FnOnce<A>>::call_once::hddbf5f21bb2e7945
                       at /rustc/b8cedc00407a4c56a3bda1ed605c6fc166655447/src/liballoc/boxed.rs:1015
  24:   0x60fec8 - std::sys_common::thread::start_thread::ha699d94be8e2f96d
                       at src/libstd/sys_common/thread.rs:13
  25:   0x60fec8 - std::sys::unix::thread::Thread::new::thread_start::hd01e2c359672fbae
                       at src/libstd/sys/unix/thread.rs:80

unsupported message

Hello, when trying to send a set mode i get unsupported command.
I've tried using both that message body

{
        "header": {
            "system_id": 1,
            "component_id": 1,
            "sequence": 0
        },
        "message": {
            "type": "SET_MODE",
            "custom_mode": 2,
            "target_system": 0,
            "base_mode": {
                "type": "MAV_MODE_PREFLIGHT"
            }
        }
    }

and this one

{
        "header": {
            "system_id": 1,
            "component_id": 1,
            "sequence": 0
        },
        "message": {
            "type": "COMMAND_LONG",
            "param1": 2,  # mode
            "param2": 0.0,  # custom mode
            "param3": 0.0,  # custom submode
            "param4": 0.0,  # empty
            "param5": 0.0,  # empty
            "param6": 0.0,  # empty
            "param7": 0.0,  # empty
            "command": {
                "type": "MAV_CMD_DO_SET_MODE"
            },
            "target_system": 0,
            "target_component": 0,
            "confirmation": 0
      }
}

Any suggestion ?

Altitude not retrieved

Hi,
Using mavlink2rest with ardupilot autotest, altitude information is available in AHRS3 section. Data is updated regularly and correct.
Using physical BR2, this info is not available. Value is sticked to zero.
Any idea why ?
Tested with :

  • ArduSub 4.0.2
  • Companion software 0.0.22
    On two different ROVs.
    Thank you for your return.

Ardusub command MAV_CMD_DO_SET_MODE is unsupported

Hi,
Below message is submitted on "0.0.0.0:8088/mavlink" URL and works well using SITL autotest tool

msg.payload = {
      "header": {
        "system_id": 1,
        "component_id": 1,
        "sequence": 0
      },
      "message": {
        "type":"COMMAND_LONG",
        "param1":19.0,
        "param2":0.0,"param3":0.0,"param4":0.0,"param5":0.0,"param6":0.0,"param7":0.0,
        "command":{
          "type":"MAV_CMD_DO_SET_MODE"
        },
        "target_system":0,
        "target_component":0,
        "confirmation":0
      }
    };

In this case, system is set in STABILIZE mode.

But same message does not work on real BlueROV2.

When opening "0.0.0.0:8088/mavlink", I found this:

...
"COMMAND_ACK":{"command":{"type":"MAV_CMD_DO_SET_MODE"},"message_information":{"counter":3,"frequency":0.11999999731779099,"time":{"first_message":"2021-02-21T19:28:35.290372244+01:00","last_message":"2021-02-21T19:29:00.714305563+01:00"}},"progress":0,"result":{"type":"MAV_RESULT_UNSUPPORTED"},"result_param2":0,"target_component":0,"target_system":0,"type":"COMMAND_ACK"}
...

and

...
"HEARTBEAT":{"autopilot":{"type":"MAV_AUTOPILOT_ARDUPILOTMEGA"},"base_mode":{"bits":209},"custom_mode":19,"mavlink_version":3,"mavtype":{"type":"MAV_TYPE_SUBMARINE"},"message_information":{"counter":106,"frequency":1.009523868560791,"time":{"first_message":"2021-02-21T19:27:16.370862274+01:00","last_message":"2021-02-21T19:29:01.574418010+01:00"}},"system_status":{"type":"MAV_STATE_CRITICAL"},"type":"HEARTBEAT"}
...

Any idea why message is supported in SITL and not on BR2 ?
Thank you for your return.

NAMED_VALUE_FLOAT is invalid message

pi@raspberrypi:~/companion $ curl --request POST http://0.0.0.0:8088/mavlink -H "Content-Type: application/json" --data '{
"header": {
"system_id": 255,
"component_id": 0,
"sequence": 0
},
"message": {
"type":"NAMED_VALUE_FLOAT",
"time_boot_ms":0,
"name":"leak",
"value":0.0
}
}'
Failed to parse message, not a valid MAVLinkMessage.

tilting camera

Hi
I was wondering if its possible to tilt the camera with mavlink2rest.
I tried setting a tilt angle with the following body in the request 2500 centidegrees
"header": {{
"system_id": 1,
"component_id": 1,
"sequence": 0
}},
"message": {{
"type": "COMMAND_LONG",
"param1": 1,
"param2": 2500,
"param3": 0,
"param4": 0,
"param5": 0,
"param6": 0,
"param7": 0,
"command": {{
"type": "MAV_CMD_DO_MOUNT_CONTROL"
}},
"target_system": 0,
"target_component": 0,
"confirmation": 0

But i dont get any reaction.

Error messages appearing when using tcpout connection string

Getting lots of error messages when using a tcpout connection:

$ ./mavlink2rest-x86_64-unknown-linux-musl -c tcpout:127.0.0.1:14550
[2022-02-12T21:58:09Z ERROR mavlink2rest::mavlink_vehicle] Recv error: Io(Os { code: 11, kind: WouldBlock, message: "Resource temporarily unavailable" })
[2022-02-12T21:58:10Z ERROR mavlink2rest::mavlink_vehicle] Recv error: Io(Os { code: 11, kind: WouldBlock, message: "Resource temporarily unavailable" })
[2022-02-12T21:58:10Z ERROR mavlink2rest::mavlink_vehicle] Recv error: Io(Os { code: 11, kind: WouldBlock, message: "Resource temporarily unavailable" })
[2022-02-12T21:58:10Z ERROR mavlink2rest::mavlink_vehicle] Recv error: Io(Os { code: 11, kind: WouldBlock, message: "Resource temporarily unavailable" })

I don't get these error messages when using UDP or tcpin.

The application still appears to be working despite the error messages.

Add log list+download endpoint

Featurerequest

It would be nice to have a endpoint to list all logs and also being able to download *.bin logs from flash.

Add about endpoint

  • Add /about endpoint where it provides a json with payload related to the current version

Getting 404 response for MAV_CMD_FIXED_MAG_CAL_YAW

I get a 404 "Failed to parse image" response when sending the request below:

{
    "header": {
        "system_id": 255,
        "component_id": 0,
        "sequence": 0
    },
    "message":{
        "type": "COMMAND_LONG",
        "param1": 100.0,
        "param2": 0.0,
        "param3": 0.0,
        "param4": 0.0,
        "param5": 0.0,
        "param6": 0.0,
        "param7": 0.0,
        "command":{
            "type": "MAV_CMD_FIXED_MAG_CAL_YAW"
        },
        "target_system": 1,
        "target_component": 1,
        "confirmation":0
    }
}

I believe MAV_CMD_FIXED_MAG_CAL_YAW is part of ardupilotmega.xml so it should be supported. Is that correct?

(The MAV_CMD_COMPONENT_ARM_DISARM command is working great so everything else is set up correctly.)

Any assistance is appreciated!

Not working on RPi Zero

Hello,

I try to install on a RPi Zero (ARMv6).

If I download mavlink2rest-armv7-unknown-linux-musleabihf file (ARMv7) I got an error : Segmentation fault

If I try to install it with cargo I got this error (same error using sudo) :

error: failed to compile `mavlink2rest v0.7.3`, intermediate artifacts can be found at `/tmp/cargo-installK7vrEl`

Caused by:  failed to parse lock file at: /home/pi/.cargo/registry/src/github.com-1ecc6299db9ec823/mavlink2rest-0.7.3/Cargo.lock

Caused by:  invalid serialized PackageId for key `package.dependencies`


I tried to remove this file and execute again, but I got a lot of compilation error 
error[E0658]:` use of unstable library feature 'alloc': this library is unlikely to be stabilized in its current form or name (see issue #27783)
  --> /home/pi/.cargo/registry/src/github.com-1ecc6299db9ec823/gimli-0.21.0/src/lib.rs:41:1
   |
41 | extern crate alloc;
   | ^^^^^^^^^^^^^^^^^^^

error[E0658]: use of unstable library feature 'maybe_uninit' (see issue #53491)
 --> /home/pi/.cargo/registry/src/github.com-1ecc6299db9ec823/gimli-0.21.0/src/read/cfi.rs:5:23
  |
5 | use core::mem::{self, MaybeUninit};
  |                       ^^^^^^^^^^^

error[E0658]: use of unstable library feature 'maybe_uninit' (see issue #53491)
    --> /home/pi/.cargo/registry/src/github.com-1ecc6299db9ec823/gimli-0.21.0/src/read/cfi.rs:2312:20
     |
2312 |     rules_storage: MaybeUninit<[(Register, RegisterRule<R>); MAX_RULES]>,
     |                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error[E0658]: use of unstable library feature 'maybe_uninit' (see issue #53491)
    --> /home/pi/.cargo/registry/src/github.com-1ecc6299db9ec823/gimli-0.21.0/src/read/cfi.rs:2329:28
     |
2329 |             rules_storage: MaybeUninit::uninit(),
     |                            ^^^^^^^^^^^^^^^^^^^

error[E0599]: no function or associated item named `uninit` found for type `core::mem::MaybeUninit<_>` in the current scope
    --> /home/pi/.cargo/registry/src/github.com-1ecc6299db9ec823/gimli-0.21.0/src/read/cfi.rs:2329:41
     |
2329 |             rules_storage: MaybeUninit::uninit(),
     |                            -------------^^^^^^
     |                            |
     |                            function or associated item not found in `core::mem::MaybeUninit<_>`

error[E0658]: use of unstable library feature 'maybe_uninit' (see issue #53491)
    --> /home/pi/.cargo/registry/src/github.com-1ecc6299db9ec823/gimli-0.21.0/src/read/cfi.rs:2366:60
     |
2366 |             core::slice::from_raw_parts(self.rules_storage.as_ptr() as *const _, self.rules_len)
     |                                                            ^^^^^^

error[E0658]: use of unstable library feature 'maybe_uninit' (see issue #53491)
    --> /home/pi/.cargo/registry/src/github.com-1ecc6299db9ec823/gimli-0.21.0/src/read/cfi.rs:2374:36
     |
2374 |                 self.rules_storage.as_mut_ptr() as *mut _,
     |                                    ^^^^^^^^^^

error[E0658]: use of unstable library feature 'maybe_uninit' (see issue #53491)
    --> /home/pi/.cargo/registry/src/github.com-1ecc6299db9ec823/gimli-0.21.0/src/read/cfi.rs:2405:50
     |
2405 |                     let ptr = self.rules_storage.as_mut_ptr() as *mut (Register, RegisterRule<R>);
     |                                                  ^^^^^^^^^^

error[E0658]: use of unstable library feature 'maybe_uninit' (see issue #53491)
    --> /home/pi/.cargo/registry/src/github.com-1ecc6299db9ec823/gimli-0.21.0/src/read/cfi.rs:2446:42
     |
2446 |             let ptr = self.rules_storage.as_mut_ptr() as *mut (Register, RegisterRule<R>);
     |                                          ^^^^^^^^^^

error: aborting due to 9 previous errors

Some errors occurred: E0599, E0658.
For more information about an error, try `rustc --explain E0599`.
error: failed to compile `mavlink2rest v0.7.3`, intermediate artifacts can be found at `/tmp/cargo-installeZYCIG`

Caused by:
  Could not compile `gimli`.

MANUAL_CONTROL command not supported

Hi,
I try to control BlueROV2 by sending MANUAL_CONTROL messages in POST mode to: 0.0.0.0:8088/mavlink
Message content is retrieved and adapted from helper

{
        "header": {
        "system_id": 1,
        "component_id":1,
        "sequence":0
        },
        "message": {
            "type":"MANUAL_CONTROL",
            "x":1000,
            "y":0,
            "z":0,
            "r":0,
            "buttons":0,
            "target":0
        }
}

mavlink2rest logout is two parenthesis as if everything was fine: ()
But command has no effect whatever the control mode I use.
Any ideas what happens ? Thanks
Note. Other commands in COMMAND_LONG are working well: ARM, DISARM, SET_MODE

Parameter to activate logs of external requests

Feature proposal: add a parameter to log requests that are posted to the API.

The idea is to have a least a trace of paths that are called from clients and the HTTP status code associated (like you can have on a Web server or a proxy server). Result can be read in console or dedicated file if specified.

Something like:

mavlink2rest -f ~/myfile.log 

Note: personaly I won't include the "mavlink flow" in this file (AHRS, HEARTBEAT, ...) ; only external requests are logged.

Websocket handling

Hello,

When we use the websocket connection for sending a stream link RC_OVERRIDE_CHANNEL, the server is answering all message with

Ok(
    (),
)

Would it be possible to have this as json and maybe ack with the correct message number ?

The issue is that on JS, it raised a syntax exception as the answer isn't a json

   ws = new WebSocket(websocketServerLocation);
    ws.onmessage = function (event) {
        try {
            var data = JSON.parse(event.data);
        } catch (error) {
            // on sending message we get non JSON response
            //console.log(error);
            //console.log(event.data);
        }

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.