Skip to content

Commit 33a0fee

Browse files
committed
docs: add Chinese README
1 parent e1b143a commit 33a0fee

2 files changed

Lines changed: 82 additions & 1 deletion

File tree

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
[![GitHub stars](https://img.shields.io/github/stars/verdancy-org/GreySensor?style=social)](https://github.com/verdancy-org/GreySensor/stargazers)
77
[![GitHub forks](https://img.shields.io/github/forks/verdancy-org/GreySensor?style=social)](https://github.com/verdancy-org/GreySensor/network/members)
88
[![GitHub issues](https://img.shields.io/github/issues/verdancy-org/GreySensor)](https://github.com/verdancy-org/GreySensor/issues)
9-
9+
`r`n**English** | [中文](README_CN.md)`r`n
1010
**GreySensor** is a runtime-configurable digital grey sensor module designed for
1111
line tracking and reflective optical sensor arrays.
1212

@@ -94,3 +94,4 @@ and `2` for right.
9494
## Dependencies
9595

9696
- No dependencies except for the LibXR basic framework.
97+

README_CN.md

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
# GreySensor
2+
3+
[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](LICENSE)
4+
[![Language](https://img.shields.io/badge/language-C++20-orange.svg)](https://en.cppreference.com/)
5+
[![Framework](https://img.shields.io/badge/Framework-LibXR-green)](https://github.com/Jiu-xiao/libxr)
6+
[![GitHub stars](https://img.shields.io/github/stars/verdancy-org/GreySensor?style=social)](https://github.com/verdancy-org/GreySensor/stargazers)
7+
[![GitHub forks](https://img.shields.io/github/forks/verdancy-org/GreySensor?style=social)](https://github.com/verdancy-org/GreySensor/network/members)
8+
[![GitHub issues](https://img.shields.io/github/issues/verdancy-org/GreySensor)](https://github.com/verdancy-org/GreySensor/issues)
9+
10+
**GreySensor** 是一个面向循迹和反射式光电阵列的可运行时配置数字灰度传感器模块。
11+
12+
## 模块介绍
13+
14+
GreySensor 按应用层传入的顺序读取数字 GPIO 通道,并通过 LibXR `Topic` 发布紧凑的循迹状态。模块不绑定具体板级引脚命名:板级或应用层负责注册 GPIO 硬件别名,再把这些别名字符串传给模块构造函数。
15+
16+
模块会根据有效通道计算加权线位置,并在短暂丢线时保留最近一次有效位置,方便上层控制环获得稳定的方向反馈。
17+
18+
## 功能特性
19+
20+
- 基于 `LibXR::GPIO` 硬件抽象接口,模块与具体平台 GPIO 实现解耦。
21+
22+
- 遵循 `Application` 框架规范,支持依赖注入,并通过 MANIFEST 接入自动化生命周期管理。
23+
24+
- 支持从 `channel_names` initializer list 自动推导通道数量。当前位图载荷支持 1-8 路通道。
25+
26+
- 发布原始通道状态、有效通道状态、加权位置、丢线状态、记忆位置和连续丢线计数。
27+
28+
- 使用有符号定点位置刻度:左侧为负,右侧为正,中心为 0。
29+
30+
## 硬件需求
31+
32+
- 需要提供与 `channel_names` 配置中每个字符串匹配的 GPIO 设备节点。
33+
34+
## 构造参数
35+
36+
- `channel_names`
37+
- 从左到右排列的 GPIO 别名列表。列表长度决定实际启用的通道数量。
38+
39+
- `active_low`
40+
- 是否使用低电平表示对应通道检测到线。
41+
42+
- `topic_name`
43+
- 用于发布 `GreySensor::Sample` 的 Topic 名称。
44+
45+
- `publish_period_ms`
46+
- 最小发布间隔,单位为毫秒。设置为 `0` 时在每次 monitor 周期都发布。
47+
48+
### API 参考
49+
50+
```cpp
51+
struct Sample {
52+
uint8_t raw_mask;
53+
uint8_t active_mask;
54+
uint8_t changed_mask;
55+
uint8_t channel_count;
56+
uint8_t active_count;
57+
uint8_t line_detected;
58+
uint8_t line_lost;
59+
uint8_t lost_side;
60+
int16_t weighted_position;
61+
int16_t position;
62+
int16_t remembered_position;
63+
uint32_t lost_count;
64+
uint32_t sequence;
65+
std::array<uint8_t, MAX_CHANNEL_COUNT> raw;
66+
std::array<uint8_t, MAX_CHANNEL_COUNT> active;
67+
};
68+
```
69+
70+
对于 8 路阵列,默认位置刻度映射为:
71+
72+
```text
73+
-3500, -2500, -1500, -500, 500, 1500, 2500, 3500
74+
```
75+
76+
当没有通道有效时,`line_lost` 置位,`position` 保持最近一次有效 `weighted_position``lost_side``0` 表示未知,`1` 表示左侧,`2` 表示右侧。
77+
78+
## 依赖
79+
80+
- 除 LibXR 基础框架外无额外依赖。

0 commit comments

Comments
 (0)