Skip to content
Open
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
52eb0a2
add filterd pointcloud counter function
ike-kazu Dec 20, 2024
4379451
ci(pre-commit): autofix
pre-commit-ci[bot] Dec 20, 2024
1e366d6
del submodule
ike-kazu Dec 20, 2024
c20d6bf
fix type
ike-kazu Dec 20, 2024
5cd9da2
fix reviewed points
ike-kazu Dec 27, 2024
aaa3495
ci(pre-commit): autofix
pre-commit-ci[bot] Dec 27, 2024
ff8b7f5
fix reviewed points
ike-kazu Dec 27, 2024
2706c08
ci(pre-commit): autofix
pre-commit-ci[bot] Dec 27, 2024
d83d65c
fix typo
ike-kazu Dec 27, 2024
411a9ba
fix reviewed points
ike-kazu Jan 10, 2025
b5fddfb
del submodule
ike-kazu Jan 10, 2025
6a62c3d
ci(pre-commit): autofix
pre-commit-ci[bot] Jan 10, 2025
cf3ddb5
fix json struct
ike-kazu Jan 10, 2025
92db91d
ci(pre-commit): autofix
pre-commit-ci[bot] Jan 10, 2025
915dc32
fix output layout
ike-kazu Feb 28, 2025
4675321
del comment-out
ike-kazu Feb 28, 2025
c2ea817
change json name
ike-kazu Feb 28, 2025
87ff4eb
Merge branch 'main' into feat/filterd_points_counter_first_stage
mojomex Mar 5, 2025
6cc219e
ci(pre-commit): autofix
pre-commit-ci[bot] Mar 5, 2025
0fa5a9b
chore: remove wrongly committed submodules
mojomex Mar 5, 2025
f77a721
chore: clean up decode filter info, add integraion for mask filter
mojomex Mar 5, 2025
1fdf864
chore: revert wrongly committed Pandar40P range setting
mojomex Mar 5, 2025
d0e82a8
chore: fix mask filter integration
mojomex Mar 5, 2025
247e9ac
chore: rename to PointcloudDecodeStatistics
mojomex Mar 5, 2025
24bc2e9
chore: remove print and pass decode_statistics along with pointcloud …
mojomex Mar 5, 2025
b030c22
chore: fix wrong timestamp type in Hesai tests
mojomex Mar 5, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,12 @@
#include <nebula_common/hesai/hesai_common.hpp>
#include <nebula_common/nebula_common.hpp>
#include <nebula_common/point_types.hpp>
#include <nlohmann/json.hpp>
#include <rclcpp/logging.hpp>
#include <rclcpp/rclcpp.hpp>

#include <sys/types.h>
Comment thread
mojomex marked this conversation as resolved.
Outdated

#include <algorithm>
#include <array>
#include <cmath>
Expand All @@ -36,6 +39,96 @@
namespace nebula::drivers
{

struct HesaiDecodeFilteredInfo
Comment thread
mojomex marked this conversation as resolved.
Outdated
{
uint16_t distance_filtered_count = 0;
uint16_t fov_filtered_count = 0;
uint16_t timestamp_filtered_count = 0;
Comment thread
mojomex marked this conversation as resolved.
Outdated
uint16_t invalid_point_count = 0;
uint16_t multiple_return_point_count = 0;
Comment thread
mojomex marked this conversation as resolved.
Outdated
uint16_t mutliple_return_point_count = 0;
Comment thread
mojomex marked this conversation as resolved.
Outdated
uint16_t total_kept_point_count = 0;
uint16_t invalid_packet_count = 0;
Comment thread
mojomex marked this conversation as resolved.
Outdated
float cloud_distance_min_m = 0;
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;
Comment thread
mojomex marked this conversation as resolved.
Outdated
uint64_t packet_timestamp_max_ns = 0;

Comment thread
mojomex marked this conversation as resolved.
Outdated
void clear()
Comment thread
mojomex marked this conversation as resolved.
Outdated
{
distance_filtered_count = 0;
fov_filtered_count = 0;
timestamp_filtered_count = 0;
invalid_point_count = 0;
multiple_return_point_count = 0;
mutliple_return_point_count = 0;
total_kept_point_count = 0;
invalid_packet_count = 0;
cloud_distance_min_m = 0;
cloud_distance_max_m = 0;
cloud_azimuth_min_rad = 0;
cloud_azimuth_max_rad = 0;
packet_timestamp_min_ns = 0;
packet_timestamp_max_ns = 0;
}

Comment thread
mojomex marked this conversation as resolved.
Outdated
[[nodiscard]] nlohmann::ordered_json to_json() const
{
nlohmann::json distance_j;
Comment thread
mojomex marked this conversation as resolved.
Outdated
distance_j["filter"] = "distance";
distance_j["distance_filtered_count"] = distance_filtered_count;
distance_j["cloud_distance_min_m"] = cloud_distance_min_m;
distance_j["cloud_distance_max_m"] = cloud_distance_max_m;
nlohmann::json fov_j;
fov_j["filter"] = "fov";
fov_j["fov_filtered_count"] = fov_filtered_count;
fov_j["cloud_azimuth_min_rad"] = cloud_azimuth_min_rad;
fov_j["cloud_azimuth_max_rad"] = cloud_azimuth_max_rad;
nlohmann::json timestamp_j;
timestamp_j["filter"] = "timestamp";
timestamp_j["timestamp_filtered_count"] = timestamp_filtered_count;
timestamp_j["packet_timestamp_min_ns"] = packet_timestamp_min_ns;
timestamp_j["packet_timestamp_max_ns"] = packet_timestamp_max_ns;
nlohmann::json invalid_j;
invalid_j["filter"] = "invalid";
invalid_j["invalid_point_count"] = invalid_point_count;
invalid_j["invalid_packet_count"] = invalid_packet_count;
Comment thread
mojomex marked this conversation as resolved.
Outdated
nlohmann::json identical_j;
identical_j["filter"] = "identical";
identical_j["multiple_return_point_count"] = multiple_return_point_count;
nlohmann::json multiple_j;
multiple_j["filter"] = "multiple";
multiple_j["mutliple_return_point_count"] = mutliple_return_point_count;
Comment thread
mojomex marked this conversation as resolved.
Outdated

nlohmann::json j;
j["filter_pipeline"] = nlohmann::json::array({
distance_j,
fov_j,
timestamp_j,
invalid_j,
identical_j,
multiple_j,
});
j["total_kept_point_count"] = total_kept_point_count;

return j;
}

void get_minmax_info(const NebulaPoint & point)
Comment thread
mojomex marked this conversation as resolved.
Outdated
{
cloud_azimuth_min_rad = std::min(cloud_azimuth_min_rad, point.azimuth);
cloud_azimuth_max_rad = std::max(cloud_azimuth_max_rad, point.azimuth);
packet_timestamp_min_ns =
std::min(packet_timestamp_min_ns, static_cast<uint64_t>(point.time_stamp));
packet_timestamp_max_ns =
std::max(packet_timestamp_max_ns, static_cast<uint64_t>(point.time_stamp));
cloud_distance_min_m = std::min(cloud_distance_min_m, point.distance);
cloud_distance_max_m = std::max(cloud_distance_max_m, point.distance);
}
};

template <typename SensorT>
class HesaiDecoder : public HesaiScanDecoder
{
Expand Down Expand Up @@ -76,6 +169,9 @@ class HesaiDecoder : public HesaiScanDecoder

rclcpp::Logger logger_;

// filtered pointcloud counter
HesaiDecodeFilteredInfo decode_filtered_info_;

/// @brief For each channel, its firing offset relative to the block in nanoseconds
std::array<int, SensorT::packet_t::n_channels> channel_firing_offset_ns_;
/// @brief For each return mode, the firing offset of each block relative to its packet in
Expand Down Expand Up @@ -129,6 +225,7 @@ class HesaiDecoder : public HesaiScanDecoder
auto & unit = *return_units[block_offset];

if (unit.distance == 0) {
decode_filtered_info_.invalid_point_count++;
continue;
}

Expand All @@ -138,6 +235,7 @@ class HesaiDecoder : public HesaiScanDecoder
distance < SensorT::min_range || SensorT::max_range < distance ||
distance < sensor_configuration_->min_range ||
sensor_configuration_->max_range < distance) {
decode_filtered_info_.distance_filtered_count++;
continue;
}

Expand All @@ -147,6 +245,7 @@ class HesaiDecoder : public HesaiScanDecoder

// Keep only last of multiple identical points
if (return_type == ReturnType::IDENTICAL && block_offset != n_blocks - 1) {
decode_filtered_info_.multiple_return_point_count++;
continue;
}

Expand All @@ -168,6 +267,7 @@ class HesaiDecoder : public HesaiScanDecoder
}

if (is_below_multi_return_threshold) {
decode_filtered_info_.mutliple_return_point_count++;
continue;
}
}
Expand All @@ -178,6 +278,7 @@ class HesaiDecoder : public HesaiScanDecoder

bool in_fov = angle_is_between(scan_cut_angles_.fov_min, scan_cut_angles_.fov_max, azimuth);
if (!in_fov) {
decode_filtered_info_.fov_filtered_count++;
continue;
}

Expand Down Expand Up @@ -214,6 +315,9 @@ class HesaiDecoder : public HesaiScanDecoder
// The driver wrapper converts to degrees, expects radians
point.azimuth = corrected_angle_data.azimuth_rad;
point.elevation = corrected_angle_data.elevation_rad;

decode_filtered_info_.get_minmax_info(point);
decode_filtered_info_.total_kept_point_count++;
}
}
}
Expand Down Expand Up @@ -269,6 +373,7 @@ class HesaiDecoder : public HesaiScanDecoder
int unpack(const std::vector<uint8_t> & packet) override
{
if (!parse_packet(packet)) {
decode_filtered_info_.invalid_packet_count++;
return -1;
}

Expand Down Expand Up @@ -320,6 +425,16 @@ class HesaiDecoder : public HesaiScanDecoder
std::swap(decode_pc_, output_pc_);
std::swap(decode_scan_timestamp_ns_, output_scan_timestamp_ns_);
has_scanned_ = true;
nlohmann::ordered_json j = decode_filtered_info_.to_json();
std::cout << "=======================" << std::endl;
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;
}
}
Comment thread
mojomex marked this conversation as resolved.
Outdated
std::cout << "=======================" << std::endl;
decode_filtered_info_.clear();
}

last_azimuth_ = block_azimuth;
Expand Down
1 change: 1 addition & 0 deletions ros2_socketcan
Comment thread
mojomex marked this conversation as resolved.
Outdated
Submodule ros2_socketcan added at 4ced52
1 change: 1 addition & 0 deletions transport_drivers
Comment thread
mojomex marked this conversation as resolved.
Outdated
Submodule transport_drivers added at 86b9aa