-
Notifications
You must be signed in to change notification settings - Fork 59
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): add filtered pointcloud counter function #247
base: main
Are you sure you want to change the base?
feat(hesai): add filtered pointcloud counter function #247
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #247 +/- ##
==========================================
- Coverage 26.07% 26.06% -0.02%
==========================================
Files 101 104 +3
Lines 9232 9420 +188
Branches 2213 2248 +35
==========================================
+ Hits 2407 2455 +48
- Misses 6436 6578 +142
+ Partials 389 387 -2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR! Here is the review so far. Performance looks good but there are some more counters and naming changes I'd like to request 🙇
nebula_decoders/include/nebula_decoders/nebula_decoders_hesai/decoders/hesai_decoder.hpp
Outdated
Show resolved
Hide resolved
nebula_decoders/include/nebula_decoders/nebula_decoders_hesai/decoders/hesai_decoder.hpp
Outdated
Show resolved
Hide resolved
nebula_decoders/include/nebula_decoders/nebula_decoders_hesai/decoders/hesai_decoder.hpp
Show resolved
Hide resolved
nebula_decoders/include/nebula_decoders/nebula_decoders_hesai/decoders/hesai_decoder.hpp
Outdated
Show resolved
Hide resolved
NebulaPointCloud point_timestamp_start; | ||
NebulaPointCloud point_timestamp_end; | ||
|
||
void clear() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please make sure that all fields are reset (e.g. timestamp_counter is missing)
float distance_start = 0; | ||
float distance_end = 0; | ||
float raw_azimuth_start = 0; | ||
float raw_azimuth_end = 0; | ||
std::uint32_t packet_timestamp_start = 0; | ||
std::uint32_t packet_timestamp_end = 0; | ||
NebulaPointCloud point_azimuth_start; | ||
NebulaPointCloud point_azimuth_end; | ||
NebulaPointCloud point_timestamp_start; | ||
NebulaPointCloud point_timestamp_end; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Please rename from
start/end
tomin/max
. - Please also add unit suffixes like
_ns
for nanoseconds,_rad
for radians,_m
for meters etc. packet_timestamp_min/max
should probably have typeuint64_t
(uint32_t
cannot represent absolute timestamps in nanoseconds)
Instead of point_
, please rename to cloud_
so that it is clear that those values are among the points that were not filtered.
I would suggest replacing raw_
with packet_
as well, so we have packet_
(before filtering) vs. cloud_
(after filtering).
nebula_decoders/include/nebula_decoders/nebula_decoders_hesai/decoders/hesai_decoder.hpp
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ike-kazu Thanks for the changes, I have a few more small requests to polish everything!
After implementing the changes, could you also provide a self-evaluation (you running Nebula with different parameters for min_range/max_range, cloud_min_angle, cloud_max_angle, dual_return_distance_threshold
and showing the output JSON diagnostics?
Thank you!
nebula_decoders/include/nebula_decoders/nebula_decoders_hesai/decoders/hesai_decoder.hpp
Outdated
Show resolved
Hide resolved
nebula_decoders/include/nebula_decoders/nebula_decoders_hesai/decoders/hesai_decoder.hpp
Outdated
Show resolved
Hide resolved
nebula_decoders/include/nebula_decoders/nebula_decoders_hesai/decoders/hesai_decoder.hpp
Outdated
Show resolved
Hide resolved
nebula_decoders/include/nebula_decoders/nebula_decoders_hesai/decoders/hesai_decoder.hpp
Outdated
Show resolved
Hide resolved
nebula_decoders/include/nebula_decoders/nebula_decoders_hesai/decoders/hesai_decoder.hpp
Outdated
Show resolved
Hide resolved
nebula_decoders/include/nebula_decoders/nebula_decoders_hesai/decoders/hesai_decoder.hpp
Outdated
Show resolved
Hide resolved
nebula_decoders/include/nebula_decoders/nebula_decoders_hesai/decoders/hesai_decoder.hpp
Outdated
Show resolved
Hide resolved
float cloud_distance_max_m = 0; | ||
float cloud_azimuth_min_rad = 0; | ||
float cloud_azimuth_max_rad = 0; | ||
uint64_t packet_timestamp_min_ns = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For easier reaability, please make these deg
instead of rad
and convert accordingly in the get_minmax_info
function below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your updates. There were still some unaddressed issues from previous comments, and some small style changes I'd like to see after your self-evaluation.
Please double-check if the outputs in your evauation match what you expect (e.g. name: "invalid"
as a top-level entry should not be there).
Thanks 🙇
uint64_t total_kept_point_count = 0; | ||
uint64_t invalid_packet_count = 0; | ||
float cloud_distance_min_m = std::numeric_limits<float>::infinity(); | ||
float cloud_distance_max_m = std::numeric_limits<float>::lowest(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While also okay, lowest()
represents the lowest finite number, so for consistency, and to signal that the initial value is not a valid one, let's change this to -infinity()
instead:
float cloud_distance_max_m = std::numeric_limits<float>::lowest(); | |
float cloud_distance_max_m = -std::numeric_limits<float>::infinity(); |
float cloud_distance_min_m = std::numeric_limits<float>::infinity(); | ||
float cloud_distance_max_m = std::numeric_limits<float>::lowest(); | ||
float cloud_azimuth_min_deg = std::numeric_limits<float>::infinity(); | ||
float cloud_azimuth_max_rad = std::numeric_limits<float>::lowest(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
float cloud_azimuth_max_rad = std::numeric_limits<float>::lowest(); | |
float cloud_azimuth_max_rad = -std::numeric_limits<float>::infinity(); |
float cloud_azimuth_min_deg = std::numeric_limits<float>::infinity(); | ||
float cloud_azimuth_max_rad = std::numeric_limits<float>::lowest(); | ||
uint64_t packet_timestamp_min_ns = std::numeric_limits<uint64_t>::max(); | ||
uint64_t packet_timestamp_max_ns = std::numeric_limits<uint64_t>::min(); | ||
|
||
[[nodiscard]] nlohmann::ordered_json to_json() const | ||
{ | ||
nlohmann::json distance_j; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use ordered_json
throughout your code to preserve the field ordering when printing.
nlohmann::json invalid_j; | ||
invalid_j["filter"] = "invalid"; | ||
invalid_j["name"] = "invalid"; | ||
invalid_j["invalid_point_count"] = invalid_point_count; | ||
invalid_j["invalid_packet_count"] = invalid_packet_count; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Invalid points and packets are different concepts:
- while invalid points are normal (the sensor sends them when there was no object hit, or when an object is too close),
- invalid packets are an error (the size does not match our expectations)
So, please make the invalid points as part of the filter pipeline, and move invalid packets to the top level.
Also see this previous comment.
j["azimuth_deg"] = pointcloud_bounds_azimuth_j, | ||
j["distance_m"] = pointcloud_bounds_distance_j, | ||
j["timestamp_ns"] = pointcloud_bounds_timestamp_j, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This does not work as-is (see the 0/1/2 instead of azimuth_deg/distance_m/timestamp_nsin your self-evaluation). Please check the nlohmann json documentation for how to specify JSON {"key": value}
pairs.
cloud_azimuth_min_deg = std::min(cloud_azimuth_min_deg, point.azimuth); | ||
cloud_azimuth_max_rad = std::max(cloud_azimuth_max_rad, point.azimuth); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please implement this comment.
for (const auto & [key, value] : j.items()) { | ||
std::cout << key << ": " << std::endl; | ||
for (const auto & [k, v] : value.items()) { | ||
std::cout << k << ": " << v << std::endl; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could do:
for (const auto & [key, value] : j.items()) { | |
std::cout << key << ": " << std::endl; | |
for (const auto & [k, v] : value.items()) { | |
std::cout << k << ": " << v << std::endl; | |
} | |
} | |
j.dump(2); |
to get a pretty-printed version of the whole JSON with indent of 2 per nesting level.
PR Type
Description
This pr will be able to watch filtered pointcloud's count by each filtering such as distance, fov and so on. It is usefull for finding filtering error while seeking causes of lidar pointclouds error.
Review Procedure
Remarks
Pre-Review Checklist for the PR Author
PR Author should check the checkboxes below when creating the PR.
Checklist for the PR Reviewer
Reviewers should check the checkboxes below before approval.
Post-Review Checklist for the PR Author
PR Author should check the checkboxes below before merging.
CI Checks