Coder Social home page Coder Social logo

openipc / mavfwd Goto Github PK

View Code? Open in Web Editor NEW
9.0 4.0 11.0 660 KB

Simplest MAVLink serial port to UDP forwarder in pure C

Home Page: https://openipc.org

License: MIT License

Makefile 0.01% C 98.76% Shell 0.16% C++ 1.08%
fpv openipc openipc-fpv

mavfwd's Introduction

MAVFWD

Added stream parsing with official mavlink library.

mavfwd is a utility for broadcasting a mavlink telemetry stream between wifibroadcast and uart devices, for organizing one- or two-way telemetry between UAV and ground station.

mavfwd is included in the OpenIPC FPV firmware as a lighter alternative to mavlink routerd and is usually used on the air part (camera).

Also, mavfwd can monitor the mavlink RC _CHANNELS package, and call the script channels.sh (located at /usr/bin or /usr/sbin) passing the channel number and its value to it when changing as $1 and $2 parameters. An example of channels.sh is present.

This allows for controlling the camera via the Remote Control Transmitter

Usage: mavfwd [OPTIONS]
-m --master      Local MAVLink master port (%s by default)
-b --baudrate    Serial port baudrate (%d by default)
-o --out         Remote output port (%s by default)
-i --in          Remote input port (%s by default)
-c --channels    RC Channel to listen for commands (0 by default) and call channels.sh
-w --wait        Delay after each command received(2000ms defaulr)
-a --aggregate   Aggregate packets in frames (1 no aggregation, 0 no parsing only raw data forward) (%d by default) 
-f --folder      Folder for file mavlink.msg (default is current folder)
-p --persist     How long a channel value must persist to generate a command - for multiposition switches (0ms default)
-t --temp        Inject SoC temperature into telemetry(HiSilicon and SigmaStart supported)
-j --wfb         Reports wfb_tx dropped packets as Mavlink messages. wfb_tx console must be redirected to <temp>/wfb.log
-v --verbose     Display each packet, default not       
--help         Display this help

Example :

mavfwd --master /dev/ttyAMA0 --baudrate 115200 --out 192.168.1.20:14550 -c 7 -w 3000 -a 10 -t -f /tmp/

Will read on the first UART with baudrade 115200 and will listen for values in RC channel 7 that come from the Remote Control via Flight Controller.

Every time the value is changed with more than 5% the bash script channels.sh {Channel} {Value} will be started with params.

The script then can check the Value param (usually between 1000 and 2000) and do the tasks needed - reconfigure encoder, switch IR mode, restart WiFi, change MCS index. etc.

To protect the system from overloading (when rotating a pot on the Tx ), the script will not be started again for 3000ms. -p option is useful for rotary switches, where each switch step will generate a command till the desired one is reached.

In order to avoid this, the channel value must keep its value for a given period in order to be accepted, for example 1000ms.

This way if you never stay more than a second on a step of the rotary switch while rotating it, only the last one will be accepted. The drawback is the delay this options adds.

Packets will be aggregated in chunks of 10 into one UDP frame.

A MAVLINK_MSG_ID_ATTITUDE from the FC will flush the buffer.

This way the OSD will be updated with the same rate and no lag will be added.

-a 15 : will flush the cached messages into one UDP packet after count of message reaches 15

-a 1024 : will flush the cached messages into one UDP packet total length of all message reaches 1024 bytes

In both cases the buffer will be flushed if there are at least 3 packets and a MAVLINK_MSG_ID_ATTITUDE is received.

Temperature will be read from the board and will be injected into the mavlink stream each second via MAVLINK_MSG_ID_RAW_IMU 27 message.

Option to send text from the cam. The file mavlink.msg in {tempfolder} is monitored and when found, all data from it are send as plain text message via MAVLINK_MSG_ID_STATUSTEXT 253 to the ground station and the file is deleted.

Sample:

echo "Huston, this is IPC" >/tmp/mavlink.msg

killall -usr1 mavfwd # will send text message to ground station even no data are received in the serial port, can be used to test Camera to Ground connection.

wfb reporting scans /tmp/wfb.log file every second and extract values from "UDP rxq overflow: 2 packets dropped" lines.

wfb_tx stdout must be redirected to this file, like this :

wfb_tx -p ${stream} -u ${udp_port} -R 512000 -K ${keydir}/${unit}.key -B ${bandwidth} -M ${mcs_index} -S ${stbc} -L ${ldpc} -G ${guard_interval} -k ${fec_k} -n ${fec_n} -T ${pool_timeout} -i ${link_id} -f ${frame_type} ${wlan} 2>&1 | tee -a /tmp/wfb.log &

In order to cross-compile for a specific camera., pull OpenIPC locally and compile it for the desired chipset.

Assuming it is compiled in /home/home/src/openipc, then mavfwd can be compiled and copied to cam with IP 192.168.1.88 like this:

cp mavfwd.c /home/home/src/openipc/output/build/mavfwd-220d30e118d26008e94445887a03d77ba73c2d29/
make -C /home/home/src/openipc/output/ mavfwd-rebuild
scp /home/home/src/openipc/output/build/mavfwd-220d30e118d26008e94445887a03d77ba73c2d29/mavfwd [email protected]:/usr/bin/

mavfwd's People

Contributors

flyrouter avatar mariofpvdev avatar tipoman9 avatar whoim2 avatar widgetii avatar ystinia avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

mavfwd's Issues

upd endpoint instead of serial

The air part communicates with the flight controller via serial, but the ground part communicates via udp or tcp socket. Is it possible to make it so that the udp port is specified as "master" arg, and preferably two - udp (server) and/or tcp (connect to ip: port)?

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.