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

feat(hesai_hw_interface): configure and check SO_RCVBUF automatically #186

Merged
merged 2 commits into from
Sep 6, 2024

Conversation

mojomex
Copy link
Collaborator

@mojomex mojomex commented Aug 27, 2024

PR Type

  • Improvement

Related Links

Description

High-bandwidth sensors such as the OT128 may experience packet loss due to the UDP socket's receive buffer being too small by default. This PR adds functionality to set and confirm that buffer size.

The buffer has to be set to a size that

  1. is as small as possible to save memory
  2. large enough to store all packets that arrive while the UDP receiver thread is not scheduled or has its callback running

For now, the chosen (hard-coded) size is 1500 B * 3600 = 5.4 MB, which is the MTU size (1500 B) times the maximum number of packets in one full scan of OT128.
The memory footprint is still 'kind of' small compared to the size of pointcloud buffers etc., so condition 1 is fulfilled for the moment. In the future, computing the optimal buffer size based on sensor bandwidth would be preferable.

Review Procedure

Setting rmem_default and rmem_max is done like: sudo sysctl -w net.core.rmem_default=123.

  • Set rmem_default and rmem_max to a size smaller than 5.4 MB, e.g. 500000 for 500 KB. Nebula should refuse to launch with an error message telling you to increase rmem_max.
  • Set rmem_default to a small size like above, and set rmem_max to a value greater than 5.4 MB, e.g. 1000000000 for 1 GB. Nebula should now run, set its socket's buffer size to 5.4 MB and there should be no packet loss.

For the easiest review experience, comment out all point filters in hesai_decoder.hpp and hard-code the points' distance to be a fixed value. That way, you will see a perfect circle and immediately notice any missing secitons.

Pre-Review Checklist for the PR Author

PR Author should check the checkboxes below when creating the PR.

  • Assign PR to reviewer

Checklist for the PR Reviewer

Reviewers should check the checkboxes below before approval.

  • Commits are properly organized and messages are according to the guideline
  • (Optional) Unit tests have been written for new behavior
  • PR title describes the changes

Post-Review Checklist for the PR Author

PR Author should check the checkboxes below before merging.

  • All open points are addressed and tracked via issues or tickets

CI Checks

  • Build and test for PR: Required to pass before the merge.

Copy link
Collaborator

@knzo25 knzo25 left a comment

Choose a reason for hiding this comment

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

Left some small questions 🙏

@mojomex mojomex force-pushed the hesai-auto-kernel-buffer-size branch from d865579 to e888255 Compare September 5, 2024 07:46
@mojomex mojomex requested a review from knzo25 September 5, 2024 07:57
Copy link
Collaborator

@knzo25 knzo25 left a comment

Choose a reason for hiding this comment

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

LGTM

@knzo25
Copy link
Collaborator

knzo25 commented Sep 6, 2024

@mojomex

@mojomex mojomex merged commit 62a7406 into tier4:develop Sep 6, 2024
10 checks passed
@mojomex mojomex deleted the hesai-auto-kernel-buffer-size branch September 6, 2024 15:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants