添加北醒TFminiPlus激光测距传感器支持#61
Conversation
There was a problem hiding this comment.
Pull request overview
该 PR 为 GSRL 增加北醒 Benewake TFmini Plus 激光测距传感器的基础支持:新增驱动类用于解析 UART 输出帧,同时补充对应设备文档,便于集成与调试。
Changes:
- 新增
TFMiniPlus测距传感器驱动(UART 帧解析、强度/温度读取、连接超时判断)。 - 新增 TFmini Plus 相关设备文档(协议/参数/使用说明)。
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| GSRL/Device/inc/dvc_rangefinder.hpp | 新增测距传感器抽象接口与 TFmini Plus 类声明、协议常量与连接超时策略 |
| GSRL/Device/src/dvc_rangefinder.cpp | 实现 TFmini Plus UART 数据帧扫描解析、数据有效性判断与 getter 接口 |
| GSRL/Documentation/Device/RangefinderTFMiniPlus.md | 增加 TFmini Plus 相关说明文档(当前内容接近厂商手册全文) |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| # [cite_start]北醒 Benewake [cite: 1] | ||
|
|
||
| # [cite_start]TFmini Plus 用户手册 [cite: 2] | ||
|
|
||
| ### [cite_start]北醒(北京)光子科技有限公司 [cite: 3] | ||
|
|
There was a problem hiding this comment.
This document still contains citation extraction artifacts like [cite_start] and [cite: …], which makes the Markdown hard to read/search and doesn’t match the style of other device docs in this repo. Suggest removing these markers and rewriting as a concise, original integration note (protocol summary, wiring, examples).
| # [cite_start]北醒 Benewake [cite: 1] | ||
|
|
||
| # [cite_start]TFmini Plus 用户手册 [cite: 2] | ||
|
|
||
| ### [cite_start]北醒(北京)光子科技有限公司 [cite: 3] | ||
|
|
||
| ----- | ||
|
|
||
| # [cite_start]前言 [cite: 4] | ||
|
|
||
| [cite_start]尊敬的用户: [cite: 5] | ||
| [cite_start]您好,感谢您选择北醒的产品。为让产品的使用体验更好,我们特制定此用户手册,以帮助您更加便捷地使用产品。 [cite: 6] | ||
|
|
||
| [cite_start]本用户手册包括TFmini Plus 激光雷达测距模组的介绍、使用和维护等相关内容,涵盖常见情况下的使用说明及问题处理措施。请在使用前仔细阅读本手册,谨记注意事项,避免危险,并在使用过程中,严格遵守手册内所述步骤执行。 [cite: 7] | ||
|
|
||
| [cite_start]如果您在使用过程中遇到了无法解决的问题,欢迎您随时联系北醒工作人员协助解决。 [cite: 8] | ||
|
|
||
| [cite_start]**联系方式** [cite: 9] | ||
|
|
||
| * [cite_start]官网地址: [www.benewake.com](https://www.benewake.com) [cite: 10] | ||
| * [cite_start]联系电话: 400-880-9610 [cite: 11] | ||
| * [cite_start]咨询技术问题,请联系: support@benewake.com [cite: 12] | ||
| * [cite_start]咨询销售事宜或索取介绍资料,请联系: bw@benewake.com [cite: 13] | ||
|
|
||
| [cite_start]**公司总部地址** [cite: 14] | ||
|
|
||
| * [cite_start]北醒(北京)光子科技有限公司 [cite: 15] | ||
| * [cite_start]北京市海淀区上地街道海国嘉业科技园3层 [cite: 16] | ||
|
|
||
| [cite_start]**版权声明** [cite: 17] | ||
| [cite_start]本文档版权归©北醒公司所有,未经北醒公司的官方书面许可,请勿改变文档中的内容描述,以及对文档进行修改、删减或翻译。 [cite: 18] | ||
|
|
||
| [cite_start]**免责声明** [cite: 19] | ||
| [cite_start]我们的产品还在不断改进和更新,因此TFmini Plus 的规格参数可能会发生变化,请以官网上的最新版本为准。 [cite: 20] | ||
|
|
||
| [cite_start]**产品认证** [cite: 21] | ||
|
|
||
| * [cite_start]IEC [cite: 22] | ||
| * [cite_start]ROHS [cite: 23] | ||
| * [cite_start]EN62471光生物安全认证 [cite: 24] | ||
| * [cite_start]CE [cite: 25] | ||
|
|
||
| ----- | ||
|
|
||
| # [cite_start]目录 [cite: 26] | ||
|
|
||
| | 章节 | 标题 | 页码 | | ||
| | :--- | :--- | :--- | | ||
| | **1** | **概览** | **1** | | ||
| | 1.1 | 产品参数 | 1 | | ||
| | **2** | **注意事项** | **1** | | ||
| | 2.1 | 关于文档 | 1 | | ||
| | 2.2 | 产品使用 | 1 | | ||
| | 2.3 | 产品失效情况 | 1 | | ||
| | **3** | **功能及关键参数** | **2** | | ||
| | 3.1 | 产品功能 | 2 | |
There was a problem hiding this comment.
This section appears to reproduce large portions of the vendor’s TFmini Plus manual, and the text itself states it is copyrighted and must not be modified/redistributed without written permission. To avoid licensing/compliance risk, please replace the verbatim manual content with a link to the official manual and a short, original summary of only the protocol details needed for this project (frame format, checksums, thresholds, wiring).
| # [cite_start]北醒 Benewake [cite: 1] | |
| # [cite_start]TFmini Plus 用户手册 [cite: 2] | |
| ### [cite_start]北醒(北京)光子科技有限公司 [cite: 3] | |
| ----- | |
| # [cite_start]前言 [cite: 4] | |
| [cite_start]尊敬的用户: [cite: 5] | |
| [cite_start]您好,感谢您选择北醒的产品。为让产品的使用体验更好,我们特制定此用户手册,以帮助您更加便捷地使用产品。 [cite: 6] | |
| [cite_start]本用户手册包括TFmini Plus 激光雷达测距模组的介绍、使用和维护等相关内容,涵盖常见情况下的使用说明及问题处理措施。请在使用前仔细阅读本手册,谨记注意事项,避免危险,并在使用过程中,严格遵守手册内所述步骤执行。 [cite: 7] | |
| [cite_start]如果您在使用过程中遇到了无法解决的问题,欢迎您随时联系北醒工作人员协助解决。 [cite: 8] | |
| [cite_start]**联系方式** [cite: 9] | |
| * [cite_start]官网地址: [www.benewake.com](https://www.benewake.com) [cite: 10] | |
| * [cite_start]联系电话: 400-880-9610 [cite: 11] | |
| * [cite_start]咨询技术问题,请联系: support@benewake.com [cite: 12] | |
| * [cite_start]咨询销售事宜或索取介绍资料,请联系: bw@benewake.com [cite: 13] | |
| [cite_start]**公司总部地址** [cite: 14] | |
| * [cite_start]北醒(北京)光子科技有限公司 [cite: 15] | |
| * [cite_start]北京市海淀区上地街道海国嘉业科技园3层 [cite: 16] | |
| [cite_start]**版权声明** [cite: 17] | |
| [cite_start]本文档版权归©北醒公司所有,未经北醒公司的官方书面许可,请勿改变文档中的内容描述,以及对文档进行修改、删减或翻译。 [cite: 18] | |
| [cite_start]**免责声明** [cite: 19] | |
| [cite_start]我们的产品还在不断改进和更新,因此TFmini Plus 的规格参数可能会发生变化,请以官网上的最新版本为准。 [cite: 20] | |
| [cite_start]**产品认证** [cite: 21] | |
| * [cite_start]IEC [cite: 22] | |
| * [cite_start]ROHS [cite: 23] | |
| * [cite_start]EN62471光生物安全认证 [cite: 24] | |
| * [cite_start]CE [cite: 25] | |
| ----- | |
| # [cite_start]目录 [cite: 26] | |
| | 章节 | 标题 | 页码 | | |
| | :--- | :--- | :--- | | |
| | **1** | **概览** | **1** | | |
| | 1.1 | 产品参数 | 1 | | |
| | **2** | **注意事项** | **1** | | |
| | 2.1 | 关于文档 | 1 | | |
| | 2.2 | 产品使用 | 1 | | |
| | 2.3 | 产品失效情况 | 1 | | |
| | **3** | **功能及关键参数** | **2** | | |
| | 3.1 | 产品功能 | 2 | | |
| # TFmini Plus | |
| This document contains a short project-specific summary of the TFmini Plus interface. | |
| For the full and current vendor documentation, see the official Benewake manual on the | |
| Benewake website: <https://www.benewake.com/>. | |
| ----- | |
| ## UART protocol summary | |
| The TFmini Plus can report measurements over UART. A commonly used default serial | |
| configuration is: | |
| - Baud rate: `115200` | |
| - Data bits: `8` | |
| - Parity: `none` | |
| - Stop bits: `1` | |
| A standard measurement frame is 9 bytes: | |
| | Byte | Meaning | | |
| | :--- | :--- | | |
| | 0 | Frame header `0x59` | | |
| | 1 | Frame header `0x59` | | |
| | 2 | Distance low byte | | |
| | 3 | Distance high byte | | |
| | 4 | Strength low byte | | |
| | 5 | Strength high byte | | |
| | 6 | Reserved / mode-dependent data | | |
| | 7 | Reserved / mode-dependent data | | |
| | 8 | Checksum | | |
| Distance is typically interpreted as a 16-bit little-endian value formed from bytes 2 and 3. | |
| Signal strength is typically interpreted as a 16-bit little-endian value formed from bytes 4 and 5. | |
| ## Checksum | |
| Validate each frame by summing bytes 0 through 7, then keeping only the low 8 bits of the | |
| result. The frame is valid when that value matches byte 8. | |
| ## Practical thresholds and validation | |
| For this project, treat a reading as usable only when: | |
| - both header bytes are `0x59` | |
| - the checksum matches | |
| - the reported distance is within the application's expected operating range | |
| - the signal strength is non-zero and not obviously invalid for the environment | |
| If a frame fails any of those checks, discard it and wait for the next valid header pair. | |
| ## Wiring | |
| Use the module's power, ground, TX, and RX connections only as documented by the vendor. | |
| At a minimum: | |
| - connect sensor `GND` to system ground | |
| - connect sensor `TX` to the host UART `RX` | |
| - connect sensor `RX` to the host UART `TX` if configuration commands are needed | |
| - power the module only within the vendor-specified supply range from the official manual | |
| ## Notes | |
| - Refer to the official manual for electrical limits, command set details, frame variants, | |
| update rates, and mounting guidance. | |
| - Do not copy vendor manual text into this repository; link to the official source instead. |
| ## [cite_start]4.5 12C 数据通信 [cite: 164] | ||
|
|
||
| [cite_start]TFmini Plus 同时支持12C数据通信接口,见下表: [cite: 165] | ||
|
|
||
| [cite_start]**表4-4 TFmini Plus 数据通信协议——I²C** [cite: 166] |
There was a problem hiding this comment.
The protocol name is written as “12C” in multiple places here; it should be “I2C” (letter I), otherwise this is misleading for readers searching for I2C details.
| void TFMiniPlus::receiveRxDataFromISR(const uint8_t *data, uint16_t length) | ||
| { | ||
| m_rxDataPointer = data; | ||
| m_rxDataLength = length; | ||
| decodeRxData(); | ||
| } |
There was a problem hiding this comment.
receiveRxDataFromISR() calls decodeRxData(), which scans the UART DMA buffer (up to UART_BUFFER_SIZE=512 bytes) and computes checksums in a loop. This is likely too much work for an ISR and can increase interrupt latency / cause missed deadlines. Consider making the ISR only stash the buffer pointer/length + timestamp and set a “pending decode” flag, then run decodeRxData() from the main loop/task context (similar to how RemoteControl drivers handle decode).
| private: | ||
| static constexpr uint32_t RX_TIMEOUT_MS = 100; | ||
|
|
There was a problem hiding this comment.
RX_TIMEOUT_MS is hard-coded to 100ms, but TFmini Plus output frame rate is configurable (can be much lower than 10Hz). With a lower frame rate, isConnected() will incorrectly mark the sensor disconnected between frames. Suggest making the timeout configurable (constructor/setter) or deriving it from the configured output rate, and documenting the expected minimum update rate if it must remain fixed.
No description provided.