Skip to content

Commit be4f119

Browse files
committed
chore: align module metadata and docs
1 parent 7b29a5a commit be4f119

2 files changed

Lines changed: 54 additions & 98 deletions

File tree

GreySensor.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
// clang-format off
44
/* === MODULE MANIFEST V2 ===
5-
module_description: Runtime-configurable digital grey sensor module with weighted line position and line-loss memory
5+
module_description: XRobot Module for digital grey sensors
66
constructor_args:
77
- channel_names:
88
- "grey_sensor_gpio_0"

README.md

Lines changed: 53 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -1,100 +1,56 @@
11
# GreySensor
22

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-
**English** | [中文](README_CN.md)
11-
12-
**GreySensor** is a runtime-configurable digital grey sensor module designed for
13-
line tracking and reflective optical sensor arrays.
14-
15-
## Module Introduction
16-
17-
GreySensor reads digital GPIO channels in the order provided by the application
18-
layer and publishes a compact line state through LibXR `Topic`. It keeps the
19-
driver independent from board-level pin names: the board or application registers
20-
GPIO hardware aliases, then passes those alias strings to the module constructor.
21-
22-
The module calculates a weighted line position from active channels and keeps the
23-
last valid position when the line is temporarily lost, simplifying upper-level
24-
control loops that need stable direction feedback.
25-
26-
## Features
27-
28-
- Based on `LibXR::GPIO` for hardware abstraction, decoupling the module from
29-
platform-specific GPIO implementations.
30-
31-
- Follows `Application` framework specifications, supporting dependency
32-
injection and automated lifecycle management through MANIFEST.
33-
34-
- Supports runtime channel count detection from the `channel_names` initializer
35-
list. The current bitmap payload supports 1-8 channels.
36-
37-
- Publishes raw channel state, active channel state, weighted position, line-loss
38-
state, remembered position, and consecutive lost-line count.
39-
40-
- Uses a signed fixed-point position scale where the left side is negative, the
41-
right side is positive, and the center is zero.
42-
43-
## Hardware Requirements
44-
45-
- GPIO device nodes matching each string in the `channel_names` configuration
46-
must be provided.
47-
48-
## Constructor Parameters
49-
50-
- `channel_names`
51-
- GPIO alias list ordered from left to right. The list length determines the
52-
active channel count.
53-
54-
- `active_low`
55-
- Whether low GPIO level means the corresponding channel detects the line.
56-
57-
- `topic_name`
58-
- Topic name used to publish `GreySensor::Sample`.
59-
60-
- `publish_period_ms`
61-
- Minimum publish interval in milliseconds. Set to `0` to publish on every
62-
monitor cycle.
63-
64-
### API Reference
65-
66-
```cpp
67-
struct Sample {
68-
uint8_t raw_mask;
69-
uint8_t active_mask;
70-
uint8_t changed_mask;
71-
uint8_t channel_count;
72-
uint8_t active_count;
73-
uint8_t line_detected;
74-
uint8_t line_lost;
75-
uint8_t lost_side;
76-
int16_t weighted_position;
77-
int16_t position;
78-
int16_t remembered_position;
79-
uint32_t lost_count;
80-
uint32_t sequence;
81-
std::array<uint8_t, MAX_CHANNEL_COUNT> raw;
82-
std::array<uint8_t, MAX_CHANNEL_COUNT> active;
83-
};
84-
```
85-
86-
For an 8-channel array, the default position scale maps channels to:
87-
88-
```text
89-
-3500, -2500, -1500, -500, 500, 1500, 2500, 3500
3+
Digital grey sensor array module for XRobot.
4+
5+
This module reads runtime-configurable digital GPIO channels in the order
6+
provided by the application layer, converts them into a compact line-tracking
7+
sample, and publishes raw state, active state, weighted position, line-loss
8+
state, and position memory through a LibXR topic.
9+
10+
The module stays independent from board-level pin names. The board or User layer
11+
registers GPIO aliases, then passes those alias strings in `channel_names`.
12+
13+
## Required Hardware
14+
15+
- `grey_sensor_gpio_0`
16+
- `grey_sensor_gpio_1`
17+
- `grey_sensor_gpio_2`
18+
- `grey_sensor_gpio_3`
19+
- `grey_sensor_gpio_4`
20+
- `grey_sensor_gpio_5`
21+
- `grey_sensor_gpio_6`
22+
- `grey_sensor_gpio_7`
23+
24+
The GPIO names are constructor arguments, so projects may use other hardware
25+
aliases and channel counts up to `GreySensor::MAX_CHANNEL_COUNT`.
26+
27+
## Constructor Arguments
28+
29+
- `channel_names`: GPIO alias list ordered from left to right
30+
- `active_low`: default `false`
31+
- `topic_name`: default `"grey_sensor"`
32+
- `publish_period_ms`: default `10`
33+
34+
## Published Topics
35+
36+
- `topic_name`: `GreySensor::Sample`, including raw / active masks, changed mask, active count, weighted position, remembered position, lost-line side, lost-line count, and sequence number
37+
38+
## XRobot Configuration Example
39+
40+
```yaml
41+
- id: grey_sensor
42+
name: GreySensor
43+
constructor_args:
44+
channel_names:
45+
- "grey_sensor_gpio_0"
46+
- "grey_sensor_gpio_1"
47+
- "grey_sensor_gpio_2"
48+
- "grey_sensor_gpio_3"
49+
- "grey_sensor_gpio_4"
50+
- "grey_sensor_gpio_5"
51+
- "grey_sensor_gpio_6"
52+
- "grey_sensor_gpio_7"
53+
active_low: false
54+
topic_name: "grey_sensor"
55+
publish_period_ms: 10
9056
```
91-
92-
When no channel is active, `line_lost` is set and `position` keeps the most
93-
recent valid `weighted_position`. `lost_side` is `0` for unknown, `1` for left,
94-
and `2` for right.
95-
96-
## Dependencies
97-
98-
- No dependencies except for the LibXR basic framework.
99-
100-

0 commit comments

Comments
 (0)