Skip to content

feat(drivers/ptgl100): add JRT PTGL-100 UART rangefinder - #29088

Open
amovlgf wants to merge 17 commits into
PX4:mainfrom
amovlgf:pr/ptgl100-driver
Open

amovlgf wants to merge 17 commits into
PX4:mainfrom
amovlgf:pr/ptgl100-driver

Conversation

@amovlgf

@amovlgf amovlgf commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Make PTGL-100 measurements available through the standard distance_sensor, MAVLink and ULog paths.

Problem

PX4 currently does not support the JRT PTGL-100 laser rangefinder used for altitude measurement.

Solution

Add configurable serial-port assignment and orientation, reply validation, and rate-limited recovery without republishing stale measurements. Enable the driver in Flycore firmware and document wiring, setup and protocol limitations.

Testing

Hardware testing with the PTGL-100 module has been completed, and test logs can be provided on request.
Virtual-UART SITL tests also passed for fragmented, corrupt and legacy frames; range limits; outages and simulated power cycles; repeated start/stop; and standard MAVLink/ULog output.

@github-actions github-actions Bot added kind:feature Request or change that adds new functionality. kind:test Adds or improves tests. scope:sensors Sensor pipeline, calibration, voting, or sensor validation. labels Oct 12, 2026
@github-actions

github-actions Bot commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

No broken links found in changed files.

@amovlgf
amovlgf marked this pull request as ready for review October 12, 2026 09:40

@hamishwillee hamishwillee left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I pushed three commits of docs review edits to this branch (wording, formatting, restructure of the PTGL-100 page, and cross-links from the rangefinder overview and Flycore page). The inline comments below are the things I couldn't fill in or confirm myself. Note the docs link check will fail until the hero image is added, and the Where to Buy link is a placeholder; the parameter and module reference links resolve once those pages are regenerated after merge.

Comment thread docs/en/sensor/ptgl100.md Resolved
Comment thread docs/en/sensor/ptgl100.md Resolved
Comment thread docs/en/sensor/ptgl100.md Resolved
Comment thread docs/en/sensor/ptgl100.md Resolved
Comment thread docs/en/sensor/ptgl100.md Resolved
Comment thread docs/en/sensor/ptgl100.md Resolved
Comment thread docs/en/sensor/ptgl100.md Resolved
Comment thread docs/en/sensor/rangefinders.md Resolved
@amovlgf

amovlgf commented Oct 14, 2026

Copy link
Copy Markdown
Contributor Author

Thanks @hamishwillee for the documentation improvements. I've pushed the updates in 4d2642e:

  • Added the product image and manufacturer manual, including a direct link to the protocol pages.
  • Confirmed that hardware testing was completed on Flycore using TELEM3. The module was powered through TELEM3 VCC/GND, with TX/RX connected for UART communication. Updated the configuration and device examples to TELEM 3 (103) and /dev/ttyS3.
  • Documented the supplied cable and the tested connectors: GH1.25 at the flight controller and six-pin SH1.25 at the module.
  • Added the specified wavelength of 905±5 nm.

@hamishwillee hamishwillee left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the updates in 4d2642e. I've pushed 02ecf35 with further docs changes, mostly to bring the PTGL-100 page in line with the other rangefinder pages and our new template.

  • Added Specifications (from manual §2), Hardware Setup (Mounting, Pinouts, Wiring with pin numbers) and Firmware Support sections. The driver isn't in the common rangefinder set, so the page now says it's only in firmware for boards that enable it, and how to add it.
  • Used the standard port, baud-rate and Deconflicting Ports wording, linked the shared rangefinder Testing section, and reduced the Protocol section to the supported commands and a link to the manual.
  • Added version badges, the NDAA cell, a link to SENS_PTGL100_CFG from the Flycore page, and a release note.

The inline comments are questions I can't answer from the manual or the code. The most important is the manual's redistribution terms.

One firmware question as well: the driver is fixed at 460800 baud. If a module ships at 115200 (as manual §4.1 says) or is set to 921600, the driver gets no samples and only retries the start command. Should it probe other rates or fall back, or at least report the likely cause in ptgl100 status?

Comment thread docs/en/sensor/ptgl100.md Resolved
Comment thread docs/en/sensor/ptgl100.md Resolved
Comment thread docs/en/sensor/ptgl100.md Resolved
Comment thread docs/en/sensor/ptgl100.md Resolved
Comment thread docs/en/sensor/rangefinders.md Resolved
@amovlgf

amovlgf commented Nov 3, 2026

Copy link
Copy Markdown
Contributor Author

Thanks @hamishwillee for the documentation improvements and detailed review. I’ve pushed [bb173664b6](bb17366) with the documentation and driver diagnostic updates.

  1. Manual and product image: Removed the PDF and the product rendering taken from it. The documentation now directs readers to JRT to obtain the manual.

  2. Baud rate: PTGL-100 modules ship with a default baud rate of 460800, so factory-configured units require no baud-rate change. Users need to contact JRT for instructions to change the module’s baud rate. I added the Sensor Configuration section immediately after Where to Buy, including JRT’s contact details and the driver’s 460800 baud requirement.

  3. Connector and cable: The cable used in the Flycore hardware test was custom-made. The module connector is the six-pin HC-0.8-6PWT, with a 0.8 mm pitch; my earlier “SH1.25” description was incorrect. The flight-controller end uses JST-GH with a 1.25 mm pitch. The documentation now identifies the connectors and explains that an adapter cable is required.

  4. EN wiring: Users should connect pin 6 (EN) to GND for normal operation. I updated the wiring instructions and table accordingly. The earlier test with EN left unconnected should not be taken as a recommendation to leave it floating.

  5. Sensor technology: The PTGL-100 uses time-of-flight measurement. I updated the Technology cell to ToF (IR laser) and retained the specified wavelength of 905±5 nm. The NDAA marking remains unchanged.

  6. Driver diagnostics: The driver retains its fixed 460800 baud setting and existing one-second retry behaviour. If no measurement reply has arrived, or replies have stopped for at least one second, ptgl100 status now prompts users to check sensor power, EN grounding, TX/RX wiring and the module’s baud rate. Valid measurement-failure replies still count as communication and do not trigger this warning; it clears when measurement replies resume.

Validation passed: the SITL build, all 15 parser unit tests, and the virtual-UART integration test covering fragmented and invalid frames, measurement failures, communication outages, simulated module restarts, repeated start/stop, the new diagnostics, MAVLink output and ULog recording.

@hamishwillee

hamishwillee commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

Thanks @amovlgf, that covers everything from the last round. I've pushed 1a8939c with wording and template fixes to the page (mounting guidance from the manual, a generic wiring table, power and port details, and links).
Please sanity check that.

A few follow-ups:

  1. Baud rate (ptgl100.md:38): did JRT confirm 460800 as the shipping default? Manual §4.1 says 115200, so it's worth knowing whether that's just out of date.
  2. Manual link (ptgl100.md:34): is there a public URL for the PTGL-100 manual we can link here? If not, we'll drop "the sales address listed in the manual" and just give the address.
  3. Packing-list cable (ptgl100.md:65): what connectors does the supplied "power cable" have, and does it carry TX/RX? If it can be used as a pigtail, the Wiring section should say so.
  4. EN to GND (ptgl100.md:90): was this tested on the Flycore with EN grounded, or is it from the manual only?
  5. TELEM3 supply voltage (ptgl100.md:92): what voltage does Flycore TELEM3 VCC supply? The Flycore page doesn't say, and the module needs 3.3–5 V. It would be worth adding to the Flycore TELEM3 pinout too.
  6. Where to Buy (ptgl100.md:34): is the PTGL-100 sold through any store or distributor, Amovlab included? If so, we'll link it beside the JRT sales address.
  7. NDAA (rangefinders.md:27): does JRT have a compliance statement for the PTGL-100? It's marked ✖️ for now.
  8. Image: could you add a photo of the module that you took yourselves, at docs/assets/hardware/sensors/ptgl100/ptgl100_hero.jpg, and add it below the opening paragraph? That avoids the manual's copyright terms.
  9. History: the PDF and rendering are still in the branch history (324025810b). Please squash or drop those files from history before merge, or make sure the PR is squash-merged.

Optional: in module.yaml:14, the long description of SENS_PTGL100_ROT repeats the short one, and the option labels already explain the values, so it can be removed.

@amovlgf

amovlgf commented Nov 11, 2026

Copy link
Copy Markdown
Contributor Author

Thanks @hamishwillee for the further review. I've checked your edits and pushed [dc0a788568](dc0a788) with the follow-up documentation updates and a module photo.

  1. Baud rate: The shipping default is 460800. The 115200 default stated in manual §4.1 is incorrect. After purchase, users can change the module to 115200 under JRT's guidance, but the current PX4 driver requires 460800. The documentation now makes this distinction explicit.

  2. Manual link: I don't have a public manual URL to link. I've removed “the sales address listed in the manual” and retained the contact address.

  3. Supplied cable: Both ends have six-pin, 0.8 mm-pitch connectors for the HC-0.8-6PWT interface. The cable carries power and UART TX/RX. I've documented that it can serve as a module-side pigtail by adapting the flight-controller end to the required connector and pinout.

  4. EN to GND: Yes, operation with EN connected to GND has been tested on Flycore and works. This is now stated in the wiring section.

  5. TELEM3 supply: Flycore TELEM3 VCC supplies 5 V, within the module's 3.3–5 V input range. I've added this to both the PTGL-100 wiring instructions and the Flycore TELEM3 pinout.

  6. Where to Buy: The module is available through the same Amovlab sales channel as Flycore. I've added shudajun@amovauto.com alongside JRT's contact address.

  7. NDAA: JRT does not provide an NDAA compliance statement for the PTGL-100. I've left the existing table entry unchanged.

  8. Image: Added a photograph of the actual module below the opening paragraph.

  9. History: The original PDF and rendering remain in earlier commits, although they are absent from the current files. Please use a squash merge as suggested, so those historical assets are not introduced into main.

@hamishwillee hamishwillee left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @amovlgf. This round is an AI-assisted docs review (Claude), which I've checked before posting.

I've pushed b3ca998 with the fixes it found that didn't need your input:

  • Cropped the module photo and converted it to WebP (220 KB → 6 KB).
  • Moved the connector type and the Pixhawk adapter sentence from Wiring to Pinouts, and removed lines that repeated other sections (the power draw, and the Flycore pointer above the TELEM3 table).
  • Corrected the Protocol summary to match the commands the driver actually sends.
  • Named SENS_PTGL100_CFG where the page said "the parameter(s)", and fixed some small wording and grammar issues.
  • Changed NDAA in the rangefinder table from ✖️ to ~. You said JRT makes no compliance statement, and ~ is what we use when the status is unknown.
  • Added min/max to SENS_PTGL100_ROT.

The inline comments are mostly questions only you or JRT can answer, plus two FYIs on changes you should check.

Questions that don't belong to a specific line:

  1. Direct sunlight: manual §7(2) says not to use the module in direct sunlight (请勿在阳光直射条件下使用该产品). Is that a real limit for outdoor use on a vehicle, or does it only refer to range being reduced (§5 item 7)? If it's a real limit, the page should say so.
  2. Merge: as agreed, this needs a squash merge so the manual PDF and rendering in earlier commits don't reach main.

Outstanding: all the earlier review threads are now resolved, so the only open items are the questions in this review.

Comment thread docs/en/sensor/ptgl100.md Resolved
Comment thread docs/en/sensor/ptgl100.md Resolved
Comment thread docs/en/sensor/ptgl100.md Resolved
Comment thread docs/en/sensor/ptgl100.md Resolved
Comment thread docs/en/sensor/ptgl100.md Resolved
Comment thread docs/en/sensor/ptgl100.md Resolved
@amovlgf

amovlgf commented Nov 13, 2026

Copy link
Copy Markdown
Contributor Author

Thanks @hamishwillee for the review. I've pushed [9fb2236c1b](amovlgf@9fb2236) with the follow-up documentation updates:

  • Accepted the baud-rate suggestion: the page requires 460800 baud without naming an alternative rate.
  • Clarified that the blind zone is closer than 0.2 m.
  • Added the connector drawing with JRT's permission, showing pins 1–6, and clarified their orientation on the module socket.
  • Confirmed that the supplied cable carries pin 6 (EN). The adapter wiring instructions retain the requirement to connect it to GND.
  • Moved the build, parser unit-test and virtual-UART integration-test instructions into src/drivers/distance_sensor/ptgl100/README.md.
  • Retained the manual's direct-sunlight restriction and directed readers to JRT for guidance on outdoor use.

I also checked both FYIs: the protocol summary matches the driver, and the orientation limits of 0–25 match its startup validation. Both changes are retained.

@farhangnaderi

Copy link
Copy Markdown
Contributor

@amovlgf Hardware test logs could also be attached to this PR.

@hamishwillee hamishwillee left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note

This is an AI review (Claude).

Thanks @amovlgf. I've resolved the 6 threads that are now fixed, and pushed 26ba805a9b to your branch with these changes:

  • Pinout drawing: compressed ptgl100_pinout.png (181 KB → 95 KB).
  • Pin numbering: merged the two sentences describing pin order on the socket into one.
  • Direct sunlight: cited the manual section (§7(2)), as the page does elsewhere.

Please pull before making further changes.

New since the last review

No inline comments this round.

  1. Hardware test logs: @farhangnaderi asked for hardware test logs. Could you attach a log from the Flycore test (for example, a Flight Review link)?

Still open from earlier reviews

  • Pin 1 location: the drawing answers this for the module socket. For the supplied cable, is it wired 1:1, and how is pin 1 marked on it (wire colour, or a mark on the plug)? Please say so on the page instead of "check the corresponding contacts" (ptgl100.md:65).

EDIT. Once this is sorted I'll have a last look at the docs, but we're probably good :-)

@amovlgf

amovlgf commented Nov 18, 2026

Copy link
Copy Markdown
Contributor Author

Thanks @hamishwillee and @farhangnaderi.

I've pushed [013176f91e](amovlgf@013176f) with an annotated photo of the supplied cable connector. The documentation now confirms the pin-to-pin wiring (1–1 through 6–6). All wires shown are black; with the connector viewed as shown and the wires pointing downwards, pin 1 (GND) is the leftmost contact.

Here is the [Flycore TELEM3 hardware ground-test log](https://logs.px4.io/plot_app?log=f1046b38-c45d-42dc-be32-f3c0f66d26a5). It was recorded on firmware 4d2642e65e, with SENS_PTGL100_CFG=103 and SENS_PTGL100_ROT=25. The approximately 99.4-second recording contains 9,808 distance_sensor samples at approximately 100 Hz, with no ULog dropouts.

@hamishwillee hamishwillee left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note

This is an AI review (Claude).

Thanks @amovlgf, the cable photo answers the pin 1 question. Thanks also for the Flycore test log. I've resolved the 1 thread that is now fixed, and pushed edf11a7435 to your branch with these changes:

  • Units: removed the space between values and unit symbols throughout ptgl100.md (3.3V, 0.8mm, 25°C), which is the PX4 docs style.
  • Cable photo: compressed ptgl100_cable_pinout.png (1.65 MB → 938 KB).

Please pull before making further changes.

New since the last review

There's one inline suggestion, to tighten the cable description.

  1. TIMESYNC change: the PR still changes src/modules/mavlink/mavlink_timesync.cpp (0216ff6, a611639). The same fix is now on main (#29856), so this file has nothing to do with the rangefinder. Could you rebase onto main so it drops out of the PR diff?
  2. Cable photo size: at 938 KB it's still large for the docs. Most of it is empty background. Could you crop it to the connector and the top of the wires? Saving it as WebP (like ptgl100_hero.webp) would also make it much smaller.

Still open from earlier reviews

None.

Comment thread docs/en/sensor/ptgl100.md Resolved
@amovlgf

amovlgf commented Nov 23, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the review, @hamishwillee! I rebased onto upstream/main, and the TIMESYNC changes are gone from the PR diff. In 9e966dd, I cropped the cable photo, converted it to WebP, and combined the pin numbering explanation into one sentence.

@hamishwillee hamishwillee left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note

This is an AI review (Claude).

Thanks @amovlgf. I've resolved the 1 thread that is now fixed. I haven't pushed any changes this round.

  • Rebase: the TIMESYNC change has dropped out of the PR diff.
  • Cable photo: the cropped WebP is 31 KB, down from 938 KB.
  • Cable wording: the pin-order sentences are combined as suggested.

New since the last review

No inline comments. CI is green on 9e966dd08d.

Still open from earlier reviews

None. The docs look good to me.

amovlgf and others added 8 commits November 24, 2026 07:52
Support the revised PTGL-100 serial protocol and expose range data through the standard sensor, telemetry and logging interfaces.

Assisted-by: Codex
Signed-off-by: lvguofei <1969354053@qq.com>
Apply documentation review fixes: consistent measurement terminology, clearer wording, Prettier formatting, a Flycore power note, and cross-links from the rangefinder overview and Flycore board page. Shorten the SENS_PTGL100_ROT long description to the sibling drivers' wording.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Hamish Willee <hamishwillee@gmail.com>
Lead with what a user needs: move the driver, validation and protocol detail into a Developer Information section at the end, state the baud requirement up front, and link the parameters, module reference and general rangefinder setup. Add the sensor's entry to the rangefinder overview. The hero image link is a placeholder until the image is supplied.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Hamish Willee <hamishwillee@gmail.com>
Put the baud requirement ahead of the tested-on note, move Diagnostics under Developer Information, and add a Where to Buy section. The purchase link is a placeholder until the product page URL is supplied.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Hamish Willee <hamishwillee@gmail.com>
Provide the manufacturer resources and verified Flycore TELEM3 setup
needed to reproduce the completed hardware test.

Assisted-by: Codex
Signed-off-by: lvguofei <1969354053@qq.com>
Bring the PTGL-100 page in line with the rangefinder page template and
address review findings: add Specifications, Hardware Setup (mounting,
pinouts, wiring with pin numbers) and Firmware Support sections, since
the driver is only built for boards that enable it. Use the standard
port, baud and deconflicting wording, link the shared testing section,
and cut the protocol detail that duplicates the driver and manual.

Also add the version badge and NDAA status in the rangefinder overview,
link SENS_PTGL100_CFG from the Flycore page, and add a release note.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Hamish Willee <hamishwillee@gmail.com>
Make missing sensor replies actionable without treating failed range
measurements as a communication outage. Cover the diagnostics and
recovery in the virtual-UART integration test.

Document the factory baud rate, manufacturer configuration support,
connector, EN grounding and ToF technology. Remove the manufacturer
manual and rendering and direct readers to JRT for the manual.

Assisted-by: Codex
Signed-off-by: lvguofei <1969354053@qq.com>
State that the Flycore hardware test used a custom-made adapter cable
to distinguish it from the cable listed in the manufacturer packing list.

Assisted-by: Codex
Signed-off-by: lvguofei <1969354053@qq.com>
hamishwillee and others added 8 commits November 24, 2026 07:52
Bring the page closer to the rangefinder template after the author's
latest update, and add the manufacturer's mounting guidance.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Hamish Willee <hamishwillee@gmail.com>
Clarify the factory baud rate, supplied cable and tested Flycore wiring
so users can reproduce the documented setup.

Assisted-by: Codex
Signed-off-by: lvguofei <1969354053@qq.com>
Move the connector type to Pinouts, drop text that repeated other
sections, correct the protocol summary to match the commands the driver
sends, and use ~ for NDAA since JRT makes no compliance statement.
Crop the module photo and convert it to WebP. Bound SENS_PTGL100_ROT to
the 0-25 range the driver accepts.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Hamish Willee <hamishwillee@gmail.com>
Make the operating limits and connector orientation clear so users can wire and configure the sensor correctly. Keep developer validation instructions beside the tests.

Assisted-by: Codex
Signed-off-by: lvguofei <1969354053@qq.com>
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Hamish Willee <hamishwillee@gmail.com>
Make pin 1 identifiable on the supplied cable when preparing an adapter.

Assisted-by: Codex
Signed-off-by: lvguofei <1969354053@qq.com>
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Hamish Willee <hamishwillee@gmail.com>
Assisted-by: Codex
Signed-off-by: lvguofei <1969354053@qq.com>
hamishwillee
hamishwillee previously approved these changes Nov 23, 2026

@hamishwillee hamishwillee left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks very much @amovlgf !

@amovlgf

amovlgf commented Nov 24, 2026

Copy link
Copy Markdown
Contributor Author

Thanks @hamishwillee for your thorough review, documentation improvements, and approval!

Is there anything else needed from me before merging? Do you have a rough idea of when this PR might be merged? I'm happy to help with any remaining steps.

@hamishwillee

Copy link
Copy Markdown
Contributor

@farhangnaderi Could I please have a review of this? It should just be a "rubber stamp", because the code changes are minimal.

@farhangnaderi farhangnaderi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@amovlgf Please address the mentioned comments. Thnks


} else {
// The distance bytes are undefined on failure. Do not refresh an old sample.
perf_count(_measurement_failures);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we publish the sample with signal_quality = 0 instead? EKF2 already handles that through its bad-quality hysteresis in sensor_range_finder.cpp, and the log and GCS would show the sensor is alive but has no valid return. Something like:

} else {
	// Distance bytes are undefined on failure: publish as invalid rather than going silent.
	_rangefinder.update(now, 0.f, 0);
	perf_count(_measurement_failures);
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. A checksum-valid failure reply now publishes a fresh sample with current_distance = 0 and signal_quality = 0. The virtual UART test verified that the invalid samples appear in uORB, MAVLink, and ULog.

}

} else if (reply.command == ptgl100::SELF_TEST) {
_self_test_received = true;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the module reports a hardware fault at boot, the driver keeps publishing and nothing warns the user.

Could we surface it at least once? For example:

_self_test_received = true;
_self_test_status = reply.status;
_self_test_error = reply.error_code;

if (reply.status != ptgl100::STATUS_SUCCESS) {
	PX4_WARN("self test failed (status %u, error 0x%02x)", reply.status, reply.error_code);
}

An events::send might be even better, so the warning reaches QGC and the log, but a PX4_WARN is a good start.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. The driver now logs a warning with the status and error code when the module reports a failed self-test. The virtual UART test verified both the warning and that ranging resumes after the retry.

}
}

TEST(PTGL100Parser, RecoversAfterTruncationWithChecksumCollision)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test shows something worth stating openly: after a cut-off frame, the bytes 55 aa 69 01 01 55 aa 69 pass the additive checksum and decode as a successful 87.47 m reading. The driver then publishes it as a real measurement.

The test only checks that the parser recovers on the next frame. It doesn't check what happened to the bad one, so this is silently accepted.

I understand this comes from the protocol's weak 8-bit checksum and can't be fully prevented in the parser. EKF2's innovation checks would probably reject one spike, too. Still, could we either:

  • add a light plausibility check before publishing (for example, reject one sample that jumps far beyond what's physically possible at ~100 Hz), or
  • at minimum, add a comment in the driver (not only in the test) noting that a corrupted stream can occasionally produce an in-range phantom reading?

That way, whoever debugs an odd range spike in a log later knows where to look.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I documented the checksum limitation where the driver publishes measurements. The parser test now explicitly checks the spurious 87.466 m reading and recovery to the next valid 100 m reading. A fixed jump threshold could also reject real changes when the beam moves between surfaces.

Distinguish an invalid range return from a silent UART link and surface module self-test faults. Document the additive checksum collision so an apparently valid spike can be traced to the protocol.

Assisted-by: Codex:gpt-6.2-sol
Signed-off-by: lvguofei <1969354053@qq.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind:feature Request or change that adds new functionality. kind:test Adds or improves tests. scope:sensors Sensor pipeline, calibration, voting, or sensor validation.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants