Giter Site home page Giter Site logo

mavlink / mavlink-camera-manager Goto Github PK

View Code? Open in Web Editor NEW
79.0 79.0 24.0 2.63 MB

MAVLink Camera Manager Service

License: MIT License

Rust 85.63% HTML 4.87% JavaScript 0.07% Vue 1.83% CSS 0.52% TypeScript 6.80% Dockerfile 0.20% Shell 0.08%
ardupilot gstreamer hacktoberfest mavlink pixhawk px4-autopilot rtsp rust server

mavlink-camera-manager'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

mavlink-camera-manager's People

Contributors

joaoantoniocardoso avatar patrickelectric avatar williangalvani 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  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mavlink-camera-manager's Issues

Panic when loading bluerov udp

Because Stepwise is not supported yet, the sizes vector can be empty:

WARN  13:55:38.843 src/video/video_source_local.rs:163: Stepwise framesize not suppported for camera: /dev/video0, for configuration: FrameSize {
    index: 0,
    fourcc: FourCC {
        repr: [
            82,
            88,
            50,
            52,
        ],
    },
    typ: 3,
    size: Stepwise(
        Stepwise {
            min_width: 32,
            max_width: 2592,
            step_width: 2,
            min_height: 32,
            max_height: 1944,
            step_height: 2,
        },
    ),
}
thread 'main' panicked at 'called `Option::unwrap()` on a `None` value', src/custom/bluerov.rs:30:37
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Steps to reproduce:

  1. Enable the legacy camera mode via red-pill->raspi-config, reboot
  2. Boom, panic.

No errors when creating a stream with wrong Size/FPS

Related to #78.

When creating a stream using the wrongly associated Size/FPS for YUYV (eg. 1920x1080@30FPS), no errors are returned, and neither new stream populates the Stream list, but when trying to create another stream, it returns two possible errors:

  • Stream name already in use
  • Device already in use

Thus, indicating a bug on the back-end side.

Move UsbBus from struct to string

A struct is problematic since the type of the information can be a tree of usb bus of usb bus.
we are going to change to a string to be more generic.

Front-end shows wrong Size/FPS

For this specific camera, max. YUYV is 800x600@15FPS, but because MJPG accepts 1920x1080@30FPS, the Size and FPS lists get messed, wrongly associating YUYV with 1920x1080@30FPS. See the video below:

bug_size.mp4

Expose "inactive" flag for controls

root@companion:/# v4l2-ctl --list-ctrls -d2
                     brightness 0x00980900 (int)    : min=-64 max=64 step=1 default=0 value=0
                       contrast 0x00980901 (int)    : min=0 max=64 step=1 default=32 value=32
                     saturation 0x00980902 (int)    : min=0 max=128 step=1 default=56 value=56
                            hue 0x00980903 (int)    : min=-40 max=40 step=1 default=0 value=0
 white_balance_temperature_auto 0x0098090c (bool)   : default=1 value=1
                          gamma 0x00980910 (int)    : min=72 max=500 step=1 default=100 value=100
                           gain 0x00980913 (int)    : min=0 max=100 step=1 default=0 value=0
           power_line_frequency 0x00980918 (menu)   : min=0 max=2 default=1 value=1
      white_balance_temperature 0x0098091a (int)    : min=2800 max=6500 step=1 default=4600 value=4600 flags=inactive
                      sharpness 0x0098091b (int)    : min=0 max=6 step=1 default=3 value=3
         backlight_compensation 0x0098091c (int)    : min=0 max=2 step=1 default=1 value=1
                  exposure_auto 0x009a0901 (menu)   : min=0 max=3 default=3 value=3
              exposure_absolute 0x009a0902 (int)    : min=1 max=5000 step=1 default=156 value=156 flags=inactive
         exposure_auto_priority 0x009a0903 (bool)   : default=0 value=0

Exposing the "inactive" flag would allow frontends to deactivate controllers when they are disabled (for example exposure control when in automatic exposure mode).

Frontend fails to show available streams with old settings

image

image

warning: unused manifest key: package.path
   Compiling mavlink-camera-manager v0.2.4 (/home/patrick/git/patrick/ardupilot-camera-manager)
    Finished dev [unoptimized + debuginfo] target(s) in 19.92s
     Running `target/debug/mavlink-camera-manager`
INFO  15:51:24.017 src/logger/manager.rs:43: mavlink-camera-manager, version: 0.2.4-518535c, build date: 2022-02-07
INFO  15:51:24.017 src/logger/manager.rs:50: Starting at 2022-02-07T15:51:24
INFO  15:51:24.018 /home/patrick/.cargo/registry/src/github.com-1ecc6299db9ec823/actix-server-1.0.4/src/builder.rs:263: Starting 16 workers
INFO  15:51:24.020 /home/patrick/.cargo/registry/src/github.com-1ecc6299db9ec823/actix-server-1.0.4/src/builder.rs:277: Starting "actix-web-service-0.0.0.0:6020" service on 0.0.0.0:6020
[src/stream/stream_backend.rs:319] &pipeline = "videotestsrc pattern=ball ! video/x-raw,width=720,height=480,framerate=60/1 ! videoconvert ! x264enc bitrate=5000 ! video/x-h264, profile=baseline ! h264parse ! queue ! rtph264pay name=pay0 config-interval=10 pt=96"
INFO  15:51:24.020 src/stream/stream_backend.rs:320: Created pipeline: videotestsrc pattern=ball ! video/x-raw,width=720,height=480,framerate=60/1 ! videoconvert ! x264enc bitrate=5000 ! video/x-h264, profile=baseline ! h264parse ! queue ! rtph264pay name=pay0 config-interval=10 pt=96
[src/stream/stream_backend.rs:324] &stream = VideoStreamRtsp {
    pipeline: Pipeline {
        description: "videotestsrc pattern=ball ! video/x-raw,width=720,height=480,framerate=60/1 ! videoconvert ! x264enc bitrate=5000 ! video/x-h264, profile=baseline ! h264parse ! queue ! rtph264pay name=pay0 config-interval=10 pt=96",
    },
    endpoint_path: "/test0",
}

/streams

[
   {
      "running":true,
      "video_and_stream":{
         "name":"ball - Fake source",
         "stream_information":{
            "endpoints":[
               "rtsp://0.0.0.0:8554/test0"
            ],
            "configuration":{
               "encode":"H264",
               "height":480,
               "width":720,
               "frame_interval":{
                  "numerator":1,
                  "denominator":60
               }
            },
            "extended_configuration":null
         },
         "video_source":{
            "Gst":{
               "name":"Fake source",
               "source":{
                  "Fake":"ball"
               }
            }
         }
      }
   }
]

Move supported schemes to ENUM

The schemes that we are using, such as: "udp" | "udp265"| "rtsp" | "mpegts" | "tcp", should be enums to deal with it in a safer way

About the duplicated device

What seems to be 'duplicated devices' on our frontend is actually somewhat an extended feature from Linux Kernel.

image

Because the user can't use (I'm assuming this based on my tests) both videos from an unique bus, and the commands from one affects the others, I think we should deal with it, and use it in a more concise way.

My initial thought on that is that maybe we could merge all the /dev/video* that shares the same bus, but probably we can't simply merge the controls/capabilities and expect it to works using the devices interchangeably - lets say video0 has JPEG encode, and to the video2 has H264, but if we merge both and keep only the video0 reference, can we use video0 as H264? Probably not, then we would need to add an abstraction layer just to map each capability to its original device (in this example, map JPEG to video0 and H264 to video2).

Maybe we could change our model to something that encapsulates each device inside each bus:

{
'': {
    'bus': 'usb-0000:09:00.3-2.4',
    'devices': [
      {
        'name': 'Video Capture 6',
        'device_path': '/dev/video2',
        ...
      },
      {
        'name': 'Video Capture 5',
        'device_path': '/dev/video0',
        ...
      }
    ]
    'controls': ...,
    'formats': ...,
    ...
  }
}

Do we want to deal with it, or we'll let it to the user? Any ideas?

Control via mavlink messages using QGC master is broken

RROR 12:16:43.188 src/mavlink/mavlink_camera.rs:341: Failed to parse control id: ParseIntError {
    kind: InvalidDigit,
}
DEBUG 12:16:43.438 src/mavlink/mavlink_camera.rs:199: sending heartbeat
ERROR 12:16:43.742 src/mavlink/mavlink_camera.rs:341: Failed to parse control id: ParseIntError {
    kind: InvalidDigit,
}
ERROR 12:16:44.340 src/mavlink/mavlink_camera.rs:341: Failed to parse control id: ParseIntError {
    kind: InvalidDigit,
}
DEBUG 12:16:44.439 src/mavlink/mavlink_camera.rs:199: sending heartbeat
DEBUG 12:16:45.439 src/mavlink/mavlink_camera.rs:199: sending heartbeat
ERROR 12:16:46.322 src/mavlink/mavlink_camera.rs:341: Failed to parse control id: ParseIntError {
    kind: InvalidDigit,
}
DEBUG 12:16:46.439 src/mavlink/mavlink_camera.rs:199: sending heartbeat
ERROR 12:16:46.822 src/mavlink/mavlink_camera.rs:341: Failed to parse control id: ParseIntError {
    kind: InvalidDigit,
}
ERROR 12:16:47.322 src/mavlink/mavlink_camera.rs:341: Failed to parse control id: ParseIntError {
    kind: InvalidDigit,
}

Suggestion: Control components extend basic control type

Today, the structure (typescript version) of the controls are something like this:

export interface V4LMenuOption {
  name: string
  value: number
}

export interface V4LMenu {
  default: number
  value: number
  options: V4LMenuOption
}

export interface V4LBool {
  default: number
  value: number
}

export interface V4LSlider {
  default: number
  max: number
  min: number
  step: number
  value: number
}

export interface V4LConfiguration {
  Slider?: V4LSlider
  Menu?: V4LMenu
  Bool?: V4LBool
}

export interface V4LControl {
  configuration: V4LConfiguration
  cpp_type: string
  id: number
  name: string
}

The problem with this structure is that we have to check if the component we want (slider, menu or bool) actually exist before consuming it.

if (control.configuration.Slider !== undefined) {
  # use slider data
}

A suggestion would be to remove the V4LConfiguration and make Slider, Menu and Bool extend from V4LControl.

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.