当前位置:网站首页>PX4模块设计之十五:PX4 Log设计
PX4模块设计之十五:PX4 Log设计
2022-08-01 21:08:00 【lida2003】
PX4模块设计之十五:PX4 Log设计
1. PX4 Log介绍
PX4 Log主要是用于记录飞控内部数据状态和信息,应用场景主要有以下几种:
- 黑匣子数据记录
- 模拟飞行重现
- 程序异常记录
为此,PX4 Log在设计上通过以下进行切割:
- ULog文件格式
- Logger模块
- Replay模块
- HardFault模块
2. ULog文件格式
2.1. ULog文件结构
+--------------------+
| Header |
+--------------------+
| Definitions |
+--------------------+
| Data |
+--------------------+
2.2. ULog文件头结构
文件头结构
+------------------------------------+--------------+----------------+
| 0x55 0x4c 0x6f 0x67 0x01 0x12 0x35 | 0x01 | uint64_t |
| File magic (7B) | Version (1B) | Timestamp (8B) |
+------------------------------------+--------------+----------------+
- File Magic (7 Bytes): File type indicator that reads “ULogXYZ where XYZ is the magic bytes sequence 0x01 0x12 0x35”
- Version (1 Byte): File format version (currently 1)
- Timestamp (8 Bytes): uint64_t integer that denotes when the logging started in microseconds
2.3. ULog消息结构定义
消息体中的消息头结构
struct message_header_s {
uint16_t msg_size;
uint8_t msg_type;
};
2.3.1 B: Flag Bits 消息
struct ulog_message_flag_bits_s {
struct message_header_s header; // msg_type = 'B'
uint8_t compat_flags[8];
uint8_t incompat_flags[8];
uint64_t appended_offsets[3]; // file offset(s) for appended data if appending bit is set
};
2.3.2 F: Format 消息
struct message_format_s {
struct message_header_s header; // msg_type = 'F'
char format[header.msg_size];
};
2.3.3 I: Information 消息
struct ulog_message_info_header_s {
struct message_header_s header; // msg_type = 'I'
uint8_t key_len;
char key[key_len];
char value[header.msg_size-1-key_len]
};
2.3.4 M: Multi Information 消息
struct ulog_message_info_multiple_header_s {
struct message_header_s header; // msg_type = 'M'
uint8_t is_continued; // can be used for arrays
uint8_t key_len;
char key[key_len];
char value[header.msg_size-2-key_len]
};
2.3.5 P: Parameter 消息
struct message_info_s {
struct message_header_s header; // msg_type = 'P'
uint8_t key_len;
char key[key_len];
char value[header.msg_size-1-key_len]
};
2.3.6 Q: Default Parameter 消息
struct ulog_message_parameter_default_header_s {
struct message_header_s header; // msg_type = 'Q'
uint8_t default_types;
uint8_t key_len;
char key[key_len];
char value[header.msg_size-2-key_len]
};
2.4. ULog数据结构定义
2.4.1 A: Subscription 消息
struct message_add_logged_s {
struct message_header_s header; // msg_type = 'A'
uint8_t multi_id;
uint16_t msg_id;
char message_name[header.msg_size-3];
};
2.4.2 R: Unsubscription 消息
struct message_remove_logged_s {
struct message_header_s header; // msg_type = 'R'
uint16_t msg_id;
};
2.4.3 D: Logged Data 消息
struct message_data_s {
struct message_header_s header; // msg_type = 'D'
uint16_t msg_id;
uint8_t data[header.msg_size-2];
};
2.4.4 【*】L: Logged String 消息
struct message_logging_s {
struct message_header_s header; // msg_type = 'L'
uint8_t log_level;
uint64_t timestamp;
char message[header.msg_size-9]
};
2.4.5 【*】C: Tagged Logged String 消息
struct message_logging_tagged_s {
struct message_header_s header; // msg_type = 'C'
uint8_t log_level;
uint16_t tag;
uint64_t timestamp;
char message[header.msg_size-9]
};
2.4.6 S: Synchronization 消息
struct message_sync_s {
struct message_header_s header; // msg_type = 'S'
uint8_t sync_magic[8];
};
2.4.7 O: Dropout 消息
struct message_dropout_s {
struct message_header_s header; // msg_type = 'O'
uint16_t duration;
};
2.4.8 I: Information 消息
略:与3.3 I: Information 消息共用同样的消息结构体
2.4.9 M: Multi Information 消息
略:与3.4 M: Multi Information 消息共用同样的消息结构体
2.4.10 P: Parameter 消息
略:与3.5 P: Parameter 消息共用同样的消息结构体
2.4.11 Q: Default Parameter 消息
略:与3.6 Q: Default Parameter 消息共用同样的消息结构体
3. Logger模块
pxh> logger
### Description
System logger which logs a configurable set of uORB topics and system printf messages
(`PX4_WARN` and
Usage: logger <command> [arguments...]
Commands:
start
[-m <val>] Backend mode
values: file|mavlink|all, default: all
[-x] Enable/disable logging via Aux1 RC channel
[-e] Enable logging right after start until disarm (otherwise only when armed)
[-f] Log until shutdown (implies -e)
[-t] Use date/time for naming log directories and files
[-r <val>] Log rate in Hz, 0 means unlimited rate
default: 280
[-b <val>] Log buffer size in KiB
default: 12
[-p <val>] Poll on a topic instead of running with fixed rate (Log rate and topic intervals are ignored if this i
values: <topic_name>
[-c <val>] Log rate factor (higher is faster)
default: 1.0
on start logging now, override arming (logger must be running)
off stop logging now, override arming (logger must be running)
stop
status print status info
注:模块细节后续给出进一步研究和分析。
4. Replay模块
pxh> replay
### Description
This module is used to replay ULog files.
There are 2 environment variables used for configuration: `
Usage: replay <command> [arguments...]
Commands:
start Start replay, using log file from ENV variable 'replay'
trystart Same as 'start', but silently exit if no log file given
tryapplyparams Try to apply the parameters from the log file
stop
status print status info
注:模块细节后续给出进一步研究和分析。
5. Hardfault模块
pxh> hardfault_log
### Description
Hardfault utility
Used in startup scripts to handle hardfaults
Usage: hardfault_log command
check Check if there's an uncommited hardfault
rearm Drop an uncommited hardfault
fault Generate a hardfault (this command crashes the system :)
0|1 Hardfault type: 0=divide by 0, 1=Assertion (default=0)
commit Write uncommited hardfault to /fs/microsd/fault_-1816558944.txt (and rearm, but don't reset)
count Read the reboot counter, counts the number of reboots of an uncommited hardfault (returned as the exit code of the program)
reset Reset the reboot counter
注:模块细节后续给出进一步研究和分析。
6. 参考资料
【1】PX4开源软件框架简明简介
【2】PX4 Logging
【3】PX4 ULog File Format
【4】PX4 logger模块
【5】PX4 replay模块
【6】PX4 hardfault log模块
边栏推荐
- LeetCode
- R语言 数据的关系探索
- 网络安全与基础设施安全局(CISA):两国将在网络安全方面扩大合作
- tiup mirror clone
- 有点奇怪!访问目的网址,主机能容器却不行
- 【微信小程序】【AR】threejs-miniprogram 安装(76/100)
- [译] 容器和 Kubernetes 中的退出码完整指南
- How to choose Visibility, Display, and Opacity when interacting or animating
- Based on FPGA in any number of bytes (single-byte or multibyte) serial port (UART) to send (including source engineering)
- Godaddy domain name resolution is slow and how to use DNSPod resolution to solve it
猜你喜欢
职场如象棋,测试/开发程序员如何突破成长瓶颈期?
扣减库存方案
MySQL 中出现的字符编码错误 Incorrect string value: ‘\x\x\x\x‘ for column ‘x‘
【Kaggle】Classify Leaves
进行交互或动画时如何选择Visibility, Display, and Opacity
R语言 数据的关系探索
Excel advanced drawing techniques, 100 (22) - how to respectively the irregular data
C语言_联合体共用体引入
Interview Blitz 70: What are sticky packs and half packs?How to deal with it?
OSG笔记:设置DO_NOT_COMPUTE_NEAR_FAR,手动计算远近平面
随机推荐
这些 hook 更优雅的管理你的状态
仿牛客论坛项目
C陷阱与缺陷 第8章 建议与答案 8.1 建议
iptables的使用简单测试
Based on FPGA in any number of bytes (single-byte or multibyte) serial port (UART) to send (including source engineering)
响应式织梦模板清洁服务类网站
Pytorch框架学习记录12——完整的模型训练套路
正则表达式
【Kaggle】House Prices
附录A printf、varargs与stdarg A.3 stdarg.h ANSI版的varargs.h
记录第一次给开源项目提 PR
织梦发布文章提示body has not allow words错误
2022牛客多校联赛第五场 题解
淘宝获取收货地址列表的 API
OSG Notes: Set DO_NOT_COMPUTE_NEAR_FAR to manually calculate far and near planes
StringTable Detailed String Pool Performance Tuning String Concatenation
C陷阱与缺陷 第7章 可移植性缺陷 7.10 首先释放,然后重新分配
Goroutine Leaks - The Forgotten Sender
Go Atomic
tiup mirror grant