Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generalize decoder implementation #38

Closed
mojomex opened this issue Jul 21, 2023 · 0 comments · Fixed by #42
Closed

Generalize decoder implementation #38

mojomex opened this issue Jul 21, 2023 · 0 comments · Fixed by #42
Assignees
Labels
enhancement New feature or request

Comments

@mojomex
Copy link
Collaborator

mojomex commented Jul 21, 2023

Description

Currently, similar models from the same vendor share very little of their decoder code despite their decoders working largely the same. This issue calls for a generalized decoder (at least per vendor) that is only specialized where necessary.

Purpose

  • De-duplicated code is much more maintainable/understandable
  • Optimizations/bugfixes for one lidar decoder would automatically apply to all decoders

Details

For Hesai lidar packets:

  • The pre-header and header fields are the same format (except for Pandar-64 (short header) and Pandar-40P (no header))
  • The block (≈ lidar column) format is identical except for an optional fourth (mostly unused) byte
  • The body (group of blocks) format is the same except for number of blocks, fine azimuth and checksum fields
  • Formats in the tail are wildly different. However, only a few fields are used by Nebula and those do have the same format
  • Return modes can be handled in a generalized way (format is consistent across models)

The overall algorithm of decoding the packets is basically identical (parameterization is of course model-dependent).

Possible approaches

Implement the decoding algorithm fully generically, using specific model definitions (as they are already largely present) for parameterization. The model definitions should re-use structs for headers/blocks whereever possible. If the structs are packed, the memcpy-based parser from pandar_128_e4x_decoder can be used for all models. Accessor functions to the specific struct locations can then provide the necessary abstraction.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants