-
Notifications
You must be signed in to change notification settings - Fork 663
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(autoware_pointcloud_preprocessor): redesign concatenate and time sync node #8300
base: main
Are you sure you want to change the base?
feat(autoware_pointcloud_preprocessor): redesign concatenate and time sync node #8300
Conversation
Thank you for contributing to the Autoware project! 🚧 If your pull request is in progress, switch it to draft mode. Please ensure:
|
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #8300 +/- ##
==========================================
+ Coverage 29.76% 29.97% +0.20%
==========================================
Files 1444 1453 +9
Lines 108686 108993 +307
Branches 42664 42878 +214
==========================================
+ Hits 32352 32667 +315
+ Misses 73150 73101 -49
- Partials 3184 3225 +41
*This pull request uses carry forward flags. Click here to find out more. ☔ View full report in Codecov by Sentry. |
@kminoda |
@vividf Thanks. Let me do that later |
sensing/autoware_pointcloud_preprocessor/schema/cocatenate_and_time_sync_node.schema.json
Outdated
Show resolved
Hide resolved
sensing/autoware_pointcloud_preprocessor/schema/cocatenate_and_time_sync_node.schema.json
Outdated
Show resolved
Hide resolved
sensing/autoware_pointcloud_preprocessor/schema/cocatenate_and_time_sync_node.schema.json
Outdated
Show resolved
Hide resolved
sensing/autoware_pointcloud_preprocessor/docs/concatenate-data.md
Outdated
Show resolved
Hide resolved
...include/autoware/pointcloud_preprocessor/concatenate_data/concatenate_and_time_sync_node.hpp
Outdated
Show resolved
Hide resolved
...include/autoware/pointcloud_preprocessor/concatenate_data/concatenate_and_time_sync_node.hpp
Outdated
Show resolved
Hide resolved
...include/autoware/pointcloud_preprocessor/concatenate_data/concatenate_and_time_sync_node.hpp
Outdated
Show resolved
Hide resolved
...include/autoware/pointcloud_preprocessor/concatenate_data/concatenate_and_time_sync_node.hpp
Outdated
Show resolved
Hide resolved
sensing/autoware_pointcloud_preprocessor/src/concatenate_data/combine_cloud_handler.cpp
Outdated
Show resolved
Hide resolved
...ing/autoware_pointcloud_preprocessor/src/concatenate_data/concatenate_and_time_sync_node.cpp
Outdated
Show resolved
Hide resolved
sensing/autoware_pointcloud_preprocessor/src/concatenate_data/cloud_collector.cpp
Outdated
Show resolved
Hide resolved
sensing/autoware_pointcloud_preprocessor/src/concatenate_data/cloud_collector.cpp
Outdated
Show resolved
Hide resolved
sensing/autoware_pointcloud_preprocessor/src/concatenate_data/cloud_collector.cpp
Outdated
Show resolved
Hide resolved
sensing/autoware_pointcloud_preprocessor/src/concatenate_data/cloud_collector.cpp
Outdated
Show resolved
Hide resolved
sensing/autoware_pointcloud_preprocessor/src/concatenate_data/cloud_collector.cpp
Show resolved
Hide resolved
sensing/autoware_pointcloud_preprocessor/src/concatenate_data/cloud_collector.cpp
Outdated
Show resolved
Hide resolved
sensing/autoware_pointcloud_preprocessor/src/concatenate_data/combine_cloud_handler.cpp
Outdated
Show resolved
Hide resolved
sensing/autoware_pointcloud_preprocessor/src/concatenate_data/combine_cloud_handler.cpp
Outdated
Show resolved
Hide resolved
sensing/autoware_pointcloud_preprocessor/src/concatenate_data/combine_cloud_handler.cpp
Outdated
Show resolved
Hide resolved
sensing/autoware_pointcloud_preprocessor/src/concatenate_data/combine_cloud_handler.cpp
Outdated
Show resolved
Hide resolved
sensing/autoware_pointcloud_preprocessor/src/concatenate_data/combine_cloud_handler.cpp
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.
As the naive and "strict" approach are mutually exclusive, the code should be structured that only the parameters/variables of the enabled one exist.
Doing this leads to:
- no unused parameters in the config --> users will make less config mistakes
- less documentation needed
- no god object --> easier to debug, less chance of bugs, more maintainable
Instead of having all parameters in a flat hierarchy and documenting which of them are ignored when, you can make parameters tree-structured instead:
In the case of the naive approach:
# common parameters
debug_mode: false
[...]
approach:
type: naive
# this approach has no other parameters
In the case of the strict approach:
# common parameters
debug_mode: false
[...]
approach:
type: strict
lidar_timestamp_offsets: [...]
lidar_timestamp_noise_window: [...]
In ROS2, each hierarchy level becomes a .
in the parameter name --> approach.type
and so on.
When parsing these, you can use polymorphism
class SchemaError : public std::exception {
const char * what() const noexcept override {
return "JSON schema violation";
}
};
class Approach {
virtual std::optional<CloudCollector> match_cloud_to_collector(...) = 0;
};
struct ApproachNaive : public Approach {
std::optional<CloudCollector> match_cloud_to_collector(...) override;
};
struct ApproachStrict : public Approach {
std::vector<double> lidar_timestamp_offsets;
std::vector<double> lidar_timestamp_noise_window;
std::optional<CloudCollector> match_cloud_to_collector(...) override;
};
std::shared_ptr<Approach> parse_approach(rclcpp::Node & node) {
auto type = node.declare_parameter<std::string>("approach.type");
if (type == "naive") {
return std::make_shared<ApproachNaive>();
}
if (type == "strict") {
return std::make_shared<ApproachStrict>(
node.declare_parameter<std::vector<double>>("approach.lidar_timestamp_offsets"),
node.declare_parameter<std::vector<double>>("approach.lidar_timestamp_noise_window")
);
}
throw SchemaError{};
}
to declare only the needed parameters. This is only demonstration code, I'm sure there are nicer ways to write this.
From then, instead of if/else
in multiple places, you can use polymorphism so that the calling code can just call apporach.my_method
without having to know which approach is used.
Signed-off-by: vividf <[email protected]>
Signed-off-by: vividf <[email protected]>
Signed-off-by: vividf <[email protected]>
…hub.com:vividf/autoware.universe into feature/redesign_concatenate_and_time_sync_node
Signed-off-by: vividf <[email protected]>
sensing/autoware_pointcloud_preprocessor/src/concatenate_data/combine_cloud_handler.cpp
Outdated
Show resolved
Hide resolved
sensing/autoware_pointcloud_preprocessor/docs/concatenate-data.md
Outdated
Show resolved
Hide resolved
sensing/autoware_pointcloud_preprocessor/docs/concatenate-data.md
Outdated
Show resolved
Hide resolved
double reference_timestamp_min_{0.0}; | ||
double reference_timestamp_max_{0.0}; | ||
double arrival_timestamp_{0.0}; // This is used for the naive approach | ||
bool debug_mode_; |
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 code has the same problem I wanted to point out with my last comment:
The states of two separate and mutually exclusive approaches both end up here. At runtime, only one will be used but both exist, which is
- hard for other developers to understand/maintain
- bugprone if someone does not read this comment
Please refactor (maybe into CloudCollector
(base class), CloudCollectorNaive
and CloudCollectorAdvanced
, or CloudCollector(const Strategy & strategy)
) and have one common interface for both.
Same goes for set_arrival_timestamp
and set_reference_timestamp
and the related member functions above.
Personally I would probably go for the CloudCollector(const Strategy & strategy)
approach since you already have the strategy classes.
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.
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 changes!
There's still a bit of unused state in the cloud_collector, but refactoring so it references the chosen strategy should be quite quick.
Also, I left some small fixes for documentation rendering. see docs here or run locally via:
cd src/universe/autoware.universe
mkdocs serve
For running locally, you might also need to do this setup first.
Co-authored-by: Max Schmeller <[email protected]>
Co-authored-by: Max Schmeller <[email protected]>
Signed-off-by: vividf <[email protected]>
Signed-off-by: vividf <[email protected]>
Signed-off-by: vividf <[email protected]>
std::shared_ptr<CloudCollector> & collector, const MatchingParams & matching_params) = 0; | ||
|
||
protected: | ||
CollectorStrategyType strategy_type_; |
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 is redundant, please remove. Please make sure once more that you are implementing polymorphism properly:
The base class shall NEVER have any dependency on specific child classes/types/etc.
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!
commit fd7db92 fixed the problem.
{ | ||
double timestamp{0.0}; | ||
double noise_window{0.0}; | ||
CollectorStrategyType strategy_type{CollectorStrategyType::Naive}; |
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 is not polymorphic - the problem discussed in my previous comment has just been moved into this struct:
noise_window
is just a dead field when the strategy is Naive.
Please make sure all issues in the original comment are addressed.
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.
I understand! I was considering the cost of using dynamic_pointer_cast
.
commit fd7db92 fixed the problem.
Thanks for the review!!!!
|
||
bool topic_miss = false; | ||
|
||
int concatenated_cloud_status = 1; // Status of concatenated cloud, 1: success, 0: failure |
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 should be a bool
and named in such a way that no explanatory comment is needed.
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, fixed in f278aea
|
||
int concatenated_cloud_status = 1; // Status of concatenated cloud, 1: success, 0: failure | ||
for (const auto & topic : params_.input_topics) { | ||
int cloud_status = 1; // Status of each lidar's pointcloud |
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.
Same as above
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, fixed in f278aea
Signed-off-by: vividf <[email protected]>
Signed-off-by: vividf <[email protected]>
Description
This PR solved the issue #6832.
Previous designs have some issues concatenating the pointcloud correctly, therefore, this PR redesigns the logic of the concatenate node in order to handle the edge cases like pointcloud delay or pointcloud drop.
Changes
A more detailed description of the algorithm is on the Readme page.https://github.com/vividf/autoware.universe/blob/feature/redesign_concatenate_and_time_sync_node/sensing/autoware_pointcloud_preprocessor/docs/concatenate-data.md
Related links
Parent Issue:
How was this PR tested?
Unit test and Component test for concatenate node
Tested with sample rosbag
Please change the sample_sensor_kit_launch: autowarefoundation/sample_sensor_kit_launch#108
The result provided by @mojomex below #8300 (comment)
Tested with vehicle 1
data: TIER4_INTERNAL_LINK
modify the config file
concatenate_and_time_sync_node.param.yaml
Note
Tested with vehicle 2
data: TIER4_INTERNAL_LINK
modify the config file
concatenate_and_time_sync_node.param.yaml
Result
TIER4_INTERNAL_LINK
Time comparison (vehicle 1 bag)
From last arrived pointcloud to publish concatenate pointcloud (include publishing)
Before (move the toc to the beginning of the cloudcallback function)
Note that the huge latency is because a pointcloud is dropped.
After
By setting is_motion_compensated to false
Notes for reviewers
locking logic (mutex) might be an important part of double-checking :)
Interface changes
None.
Effects on system behavior
None.