Last active
September 30, 2023 06:56
-
-
Save royratcliffe/ddc2fcfd39cdab0a7648d4689277033a to your computer and use it in GitHub Desktop.
MAVLink
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DISPLAY=${DISPLAY} | |
WAYLAND_DISPLAY=${WAYLAND_DISPLAY} | |
XDG_RUNTIME_DIR=${XDG_RUNTIME_DIR} | |
PULSE_SERVER=${PULSE_SERVER} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
services: | |
sitl: | |
build: sitl | |
volumes: | |
- /tmp/.X11-unix:/tmp/.X11-unix:rw | |
- /mnt/wslg:/mnt/wslg:ro | |
env_file: | |
- display.env | |
environment: | |
- MAV_0_BROADCAST=1 | |
- MAV_1_BROADCAST=1 | |
- MAV_2_BROADCAST=1 | |
deploy: | |
resources: | |
reservations: | |
devices: | |
- driver: nvidia | |
count: 1 | |
capabilities: [gpu] | |
proxy: | |
build: proxy | |
volumes: | |
- /tmp/.X11-unix:/tmp/.X11-unix:rw | |
- /mnt/wslg:/mnt/wslg:ro | |
env_file: | |
- display.env | |
environment: | |
- MPLBACKEND=wxagg | |
shark: | |
# https://hub.docker.com/r/linuxserver/wireshark | |
image: linuxserver/wireshark | |
cap_add: | |
- NET_ADMIN | |
ports: | |
- 3000:3000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(reticulate) | |
docker <- import("docker") | |
client <- docker$DockerClient("tcp://localhost:2375") | |
# INFO [mavlink] mode: Normal, data rate: 4000000 B/s on udp port 18570 remote port 14550 | |
# INFO [mavlink] mode: Onboard, data rate: 4000000 B/s on udp port 14580 remote port 14540 | |
# INFO [mavlink] mode: Onboard, data rate: 4000 B/s on udp port 14280 remote port 14030 | |
# INFO [mavlink] mode: Gimbal, data rate: 400000 B/s on udp port 13030 remote port 13280 | |
# | |
# Usage for Server/daemon process: | |
# | |
# px4 [-h|-d] [-s <startup_file>] [-t <test_data_directory>] [<rootfs_directory>] [-i <instance>] [-w <working_directory>] | |
# | |
# -s <startup_file> shell script to be used as startup (default=etc/init.d-posix/rcS) | |
# <rootfs_directory> directory where startup files and mixers are located, | |
# (if not given, CWD is used) | |
# -i <instance> px4 instance id to run multiple instances [0...N], default=0 | |
# -w <working_directory> directory to change to | |
# -h help/usage information | |
# -d daemon mode, don't start pxh shell | |
# | |
px4sitl <- \(client, port = 14650L) { | |
client$containers$run( | |
client$images$get(name = "royratcliffe/px4sitl"), | |
remove = TRUE, | |
detach = TRUE, | |
environment = list(DISPLAY = ":0"), | |
volumes = list("/run/desktop/mnt/host/wslg/.X11-unix" = list(bind = "/tmp/.X11-unix")), | |
ports = list("14550/udp" = port)) | |
} | |
container <- px4sitl(client) | |
container$stop() | |
#' Starts a MAVLink router daemon. | |
#' | |
#' Exposes the server-mode endpoints only. Does *not* expose the client-mode | |
#' endpoints. All endpoints bind to any interface within the container. | |
#' | |
#' Assumes the Docker image is currently available. Pull the image first. | |
#' | |
#' @param docker.client Docker client. | |
#' @param server.ports Server ports to expose. There should always be at least | |
#' one server port, otherwise the daemon terminates immediately. | |
#' @param expose.offset Offsets the exposed (server) ports. | |
mavlink.routerd <- \(docker.client, ..., | |
client.ports = NULL, | |
server.ports = 14445L, | |
expose.offset = 0L, | |
client.ip = "172.17.0.0", | |
server.ip = "0.0.0.0", | |
remove = TRUE) { | |
if (!is.null(server.ports)) names(server.ports) <- paste0(server.ports, "/udp") | |
e.args <- if (!is.null(client.ports)) | |
sapply(paste(client.ip, client.ports, sep = ":"), c, "-e")[2:1, ] | |
command <- c("mavlink-routerd", "-t", 0L, e.args, | |
paste(server.ip, server.ports, sep = ":"), ...) | |
message(paste(command, collapse = " ")) | |
docker.client$containers$run( | |
docker.client$images$get(name = "royratcliffe/mavlinkrouter"), | |
command = command, | |
ports = as.list(server.ports + expose.offset), | |
remove = remove, | |
detach = TRUE) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM ubuntu:jammy | |
# https://ardupilot.org/mavproxy/docs/getting_started/download_and_installation.html | |
RUN apt update \ | |
&& export DEBIAN_FRONTEND=noninteractive \ | |
&& apt-get install -y --no-install-recommends python3-dev python3-opencv python3-wxgtk4.0 python3-pip python3-matplotlib python3-lxml python3-pygame \ | |
&& pip3 install PyYAML mavproxy --user | |
# Usage: mavproxy.py [options] | |
# | |
# Options: | |
# -h, --help show this help message and exit | |
# --master=DEVICE[,BAUD] | |
# MAVLink master port and optional baud rate | |
# --force-connected Use master even if initial connection fails | |
# --out=DEVICE[,BAUD] MAVLink output port and optional baud rate | |
# --baudrate=BAUDRATE default serial baud rate | |
# --sitl=SITL SITL output port | |
# --streamrate=STREAMRATE | |
# MAVLink stream rate | |
# --source-system=SOURCE_SYSTEM | |
# MAVLink source system for this GCS | |
# --source-component=SOURCE_COMPONENT | |
# MAVLink source component for this GCS | |
# --target-system=TARGET_SYSTEM | |
# MAVLink target master system | |
# --target-component=TARGET_COMPONENT | |
# MAVLink target master component | |
# --logfile=LOGFILE MAVLink master logfile | |
# -a, --append-log Append to log files | |
# --quadcopter use quadcopter controls | |
# --setup start in setup mode | |
# --nodtr disable DTR drop on close | |
# --show-errors show MAVLink error packets | |
# --speech use text to speech | |
# --aircraft=AIRCRAFT aircraft name | |
# --cmd=CMD initial commands | |
# --console use GUI console | |
# --map load map module | |
# --load-module=LOAD_MODULE | |
# Load the specified module. Can be used multiple times, | |
# or with a comma separated list | |
# --mav10 Use MAVLink protocol 1.0 | |
# --mav20 Use MAVLink protocol 2.0 | |
# --auto-protocol Auto detect MAVLink protocol version | |
# --mavversion=MAVVERSION | |
# Force MAVLink Version (1.0, 2.0). Otherwise autodetect | |
# version | |
# --nowait don't wait for HEARTBEAT on startup | |
# -c, --continue continue logs | |
# --dialect=DIALECT MAVLink dialect | |
# --rtscts enable hardware RTS/CTS flow control | |
# --moddebug=MODDEBUG module debug level | |
# --mission=MISSION mission name | |
# --daemon run in daemon mode, do not start interactive shell | |
# --non-interactive do not start interactive shell | |
# --profile run the Yappi python profiler | |
# --state-basedir=STATE_BASEDIR | |
# base directory for logs and aircraft directories | |
# --version version information | |
# --default-modules=DEFAULT_MODULES | |
# default module list | |
# --udp-timeout=UDP_TIMEOUT | |
# Timeout for udp clients in seconds | |
ENV PATH="$PATH:/root/.local/bin" | |
CMD [ "mavproxy.py", "--daemon", "--map", "--console" ,"--load-module=graph" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM px4io/px4-dev-nuttx-jammy | |
# The simulator runs *without* upgrading Jammy. It does not display the | |
# graphics, however. Upgrading fixes it. | |
RUN apt update && apt upgrade -y | |
RUN git clone --recurse-submodules https://github.com/PX4/PX4-Autopilot.git | |
WORKDIR PX4-Autopilot | |
RUN make | |
CMD [ "make", "px4_sitl", "jmavsim" ] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment