msposd 开源代码之树莓派3B+ Bookworm部署
msposd 开源代码之树莓派3B+ Bookworm部署
- 1. 源由
- 2. 安装
- 3. 脚本
- 4. 服务
- 5. TODO
1. 源由
在前面文档中,我们已经基本上搭建了 树莓派FPV的 Ardupilot Rover测试平台:
- 《wfb-ng 开源代码之树莓派3B+ Bookworm安装》
- 《wfb-ng 开源代码之树莓派3B+ Bookworm无线配置》
在实际使用过程中,由于msposd采用了native build
方式,与OpenIPC的安装方式不太一样,所以有些细节需要进行调整。
- 天空端安装路径
- 自定义数据支持
2. 安装
msposd
由于navtive build
方式编译,安装应用了gs
目录结构。
- 目录结构:
$ tree /usr/local/bin/fpvdrone/
/usr/local/bin/fpvdrone/
├── font_ardu_hd.png
├── font_ardu.png
├── font_btfl_hd.png
├── font_btfl.png
├── font_inav_hd.png
├── font_inav.png
├── fpv-drone.sh
├── fpv-update.sh
├── vtxmenu.ini
└── msposd1 directory, 8 files
3. 脚本
- 自定义更新脚本 (每秒更新)
$ sudo nano /usr/local/bin/fpvdrone/fpv-update.sh
$ sudo chmod +x /usr/local/bin/fpvdrone/fpv-update.sh
$ cat /usr/local/bin/fpvdrone/fpv-update.sh
#!/bin/bashwhile true; doecho "Monitor... &L24 &F28 CPU:&C &B temp:&T" > /usr/local/bin/fpvdrone/MSPOSD.msgsleep 1
done
- 启动脚本支持
libcamera-vid
日志管道
$ cat /usr/local/bin/fpvdrone/fpv-drone.sh
#!/bin/bash# Set up environment variables
export PATH=$PATH:/usr/local/bin:/usr/bin
export LD_LIBRARY_PATH=/usr/local/lib:/usr/lib# Start the wfb_tx process
/usr/bin/wfb_tx \-p 17 \-u 14560 \-K /etc/drone.key \-B 20 \-M 1 \-S 1 \-L 1 \-G long \-k 1 \-n 2 \-T 0 \-i 7669206 \-f data \wfb-rf0 &# Check if /tmp/libcamera-logs FIFO file exists, create it if not
if [ ! -p /tmp/libcamera-logs ]; thenmkfifo /tmp/libcamera-logs
fi# Start libcamera-vid and pipe its output to GStreamer while logging to /tmp/libcamera-logs
/usr/bin/libcamera-vid \--verbose \--inline \--width 1920 \--height 1080 \--bitrate 4000000 \--framerate 30 \--hflip \--vflip \--timeout 0 \-o - 2> /tmp/libcamera-logs | \/usr/bin/gst-launch-1.0 \-v fdsrc ! h264parse ! rtph264pay config-interval=1 pt=35 ! udpsink sync=false host=127.0.0.1 port=5602 &# Change to the FPVDrone directory and start the msposd process
cd /usr/local/bin/fpvdrone/
/usr/local/bin/fpvdrone/msposd \--master /dev/ttyUSB0 \--baudrate 115200 \--out 127.0.0.1:14560 \--matrix 11 \--ahi 1 \-r 30 \-c 7 \-c 9 &# (Optional) Run the FPVDrone update script
# /usr/local/bin/fpvdrone/fpv-update.sh &# Wait for all background processes to finish
wait
4. 服务
- 服务配置路径更新
$ cat /etc/systemd/system/fpvdrone.service
[Unit]
Description=FPV Drone Service
Requires=wifibroadcast.service
ReloadPropagatedFrom=wifibroadcast.service
After=wifibroadcast.service[Service]
Type=simple
ExecStartPre=/bin/sleep 10
ExecStart=/usr/local/bin/fpvdrone/fpv-drone.shRestart=always
User=root
Group=root
AmbientCapabilities=CAP_NET_RAW CAP_NET_ADMIN
WorkingDirectory=/
StandardOutput=journal
StandardError=journal
Restart=on-failure
RestartSec=5s[Install]
WantedBy=multi-user.target
5. TODO
树莓派目前尚不在msposd支持范围,树莓派官网在制作工具链二进制方面的情况尚没有研究透,所以暂时还没有计划。
- How can I get up to date cross-compiler on x86 platform for Pi3B+ bookworm? #135
依据前面步骤,调整安装路径,脚本,以及相关配置,native build
是可以在树莓派Pi3B+上部署和使用的。
- [Request] Custom message(bitrate/fps) support for other platform except SIGMASTAR
以下libcamera-vid
日志数据可以提供FPS/bitrate分析:
#31 (30.00 fps) exp 33216.00 ag 8.00 dg 1.00
FileOutput: output buffer 0x7f9d97a000 size 21529
Viewfinder frame 32
#32 (30.01 fps) exp 33216.00 ag 8.00 dg 1.00
FileOutput: output buffer 0x7f9d8ba000 size 21331
Viewfinder frame 33
#33 (30.00 fps) exp 33216.00 ag 8.00 dg 1.00
FileOutput: output buffer 0x7f9d7fa000 size 20932
Viewfinder frame 34
#34 (29.99 fps) exp 33216.00 ag 8.00 dg 1.00
FileOutput: output buffer 0x7f9d73a000 size 21008
Viewfinder frame 35
#35 (30.02 fps) exp 33216.00 ag 8.00 dg 1.00
FileOutput: output buffer 0x7f9d67a000 size 14030
Viewfinder frame 36
FileOutput: output buffer 0x7f9d5ba000 size 20665
#36 (30.01 fps) exp 33216.00 ag 8.00 dg 1.00
Viewfinder frame 37
#37 (30.00 fps) exp 33216.00 ag 8.00 dg 1.00
FileOutput: output buffer 0x7fa40c0000 size 13858
FileOutput: output buffer 0x7fa4000000 size 13573
Viewfinder frame 38
#38 (30.00 fps) exp 33216.00 ag 8.00 dg 1.00
Viewfinder frame 39
#39 (30.00 fps) exp 33216.00 ag 8.00 dg 1.00
FileOutput: output buffer 0x7f9dc7a000 size 20551
FileOutput: output buffer 0x7f9dbba000 size 13894
Viewfinder frame 40
#40 (30.01 fps) exp 33216.00 ag 8.00 dg 1.00
Viewfinder frame 41
#41 (30.00 fps) exp 33216.00 ag 8.00 dg 1.00
FileOutput: output buffer 0x7f9dafa000 size 13314
Viewfinder frame 42
FileOutput: output buffer 0x7f9da3a000 size 26276
#42 (30.00 fps) exp 33216.00 ag 8.00 dg 1.00
Viewfinder frame 43
#43 (30.00 fps) exp 33216.00 ag 8.00 dg 1.00
FileOutput: output buffer 0x7f9d97a000 size 15762
Viewfinder frame 44
FileOutput: output buffer 0x7f9d8ba000 size 8856
#44 (30.00 fps) exp 33216.00 ag 8.00 dg 1.00
Viewfinder frame 45
FileOutput: output buffer 0x7f9d7fa000 size 10674
#45 (30.00 fps) exp 33216.00 ag 8.00 dg 1.00
Viewfinder frame 46
#46 (30.00 fps) exp 33216.00 ag 8.00 dg 1.00
FileOutput: output buffer 0x7f9d73a000 size 16184
Viewfinder frame 47
FileOutput: output buffer 0x7f9d67a000 size 16389
#47 (30.00 fps) exp 33216.00 ag 8.00 dg 1.00
Viewfinder frame 48
#48 (30.00 fps) exp 33216.00 ag 8.00 dg 1.00
FileOutput: output buffer 0x7f9d5ba000 size 16489
Viewfinder frame 49