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(autoware_pointcloud_preprocessor): templated version of the pointcloud concatenation #10298

Open
wants to merge 20 commits into
base: main
Choose a base branch
from

Conversation

knzo25
Copy link
Contributor

@knzo25 knzo25 commented Mar 19, 2025

Description

As part of #9722,
the pointcloud concatenation as accelerated using cuda.
Since we do not want to add a cuda dependency to this package, nor want to duplicate a node that has become more complex, I implemented a templated version of the node, which will enable cuda acceleration in the respective package with minimal code duplication and will easily enable to reuse this logic for radar concatenation.

In addition, this node PR changes the use of some shared pointers to unique pointers, which reduces an entire copy of the pointclouds.

The layout checks were also copied to the autoware_point_types package, yet they are still in this package. I will move them in a later PR

Related links

Parent Issue:

How was this PR tested?

Tested using my local environment an a robotaxi rosbag

Notes for reviewers

This PR should work the same as the baseline as it only refactors it into a templated form

Interface changes

None.

Effects on system behavior

None.

knzo25 added 2 commits March 19, 2025 09:05
…lementations and extend it to radars

Signed-off-by: Kenzo Lobos-Tsunekawa <[email protected]>
@github-actions github-actions bot added the component:sensing Data acquisition from sensors, drivers, preprocessing. (auto-assigned) label Mar 19, 2025
Copy link

github-actions bot commented Mar 19, 2025

Thank you for contributing to the Autoware project!

🚧 If your pull request is in progress, switch it to draft mode.

Please ensure:

Signed-off-by: Kenzo Lobos-Tsunekawa <[email protected]>
@knzo25 knzo25 added the run:build-and-test-differential Mark to enable build-and-test-differential workflow. (used-by-ci) label Mar 19, 2025
Copy link

codecov bot commented Mar 19, 2025

Codecov Report

Attention: Patch coverage is 64.70588% with 150 lines in your changes missing coverage. Please review.

Project coverage is 25.90%. Comparing base (b70f555) to head (8b615c8).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...oncatenate_data/concatenate_and_time_sync_node.ipp 64.17% 45 Missing and 27 partials ⚠️
..._preprocessor/concatenate_data/cloud_collector.ipp 40.90% 32 Missing and 7 partials ⚠️
...r/concatenate_data/collector_matching_strategy.ipp 52.38% 17 Missing and 3 partials ⚠️
...are_pointcloud_preprocessor/src/utility/memory.cpp 37.50% 8 Missing and 2 partials ⚠️
...rc/concatenate_data/combine_cloud_handler_base.cpp 84.48% 5 Missing and 4 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #10298      +/-   ##
==========================================
+ Coverage   25.44%   25.90%   +0.46%     
==========================================
  Files        1321     1385      +64     
  Lines      102799   107044    +4245     
  Branches    39102    40990    +1888     
==========================================
+ Hits        26154    27728    +1574     
- Misses      74131    76603    +2472     
- Partials     2514     2713     +199     
Flag Coverage Δ *Carryforward flag
differential 21.77% <64.70%> (?)
differential-cuda 18.80% <64.23%> (?)
total 25.76% <ø> (+0.32%) ⬆️ Carriedforward from d83e50a

*This pull request uses carry forward flags. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Signed-off-by: Kenzo Lobos-Tsunekawa <[email protected]>
Copy link
Contributor

@vividf vividf left a 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!

I noticed that one or more functions might not be using the latest version from the concatenation node.
Could you please update them to reflect the most recent implementation?

double timeout_sec, bool debug_mode);
bool topic_exists(const std::string & topic_name);
void process_pointcloud(
const std::string & topic_name, sensor_msgs::msg::PointCloud2::SharedPtr cloud);
bool process_pointcloud(
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you update this function to reflect the latest version?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry, the rebase did not work as expected. Check at a glance all the cpp from the base with the ipp and cpp from this PR. This once is addressed in 593ddc6

Copy link
Contributor

@mojomex mojomex left a comment

Choose a reason for hiding this comment

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

Looking good functionally!
I left some comments on factoring out unrelated classes into their own files, and on reducing templated code by introducing ..Base versions of some classes. Please have a look!

if (
(*concatenated_cloud_result.topic_to_transformed_cloud_map).find(topic) !=
(*concatenated_cloud_result.topic_to_transformed_cloud_map).end()) {
auto transformed_cloud_output = std::move((*concatenated_cloud_result.topic_to_transformed_cloud_map).at(topic));
Copy link
Contributor

Choose a reason for hiding this comment

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

This leaves moved-from unique ptr in the map (which will be a nullptr).
Using .extract instead of .at is a safe alternative that removes the element.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The method you provided does not compile.
If it is for peace of mind, I used an erase afterwards in 34f8008

topic_to_transformed_cloud_publisher_map_;
std::unique_ptr<autoware_utils::DebugPublisher> debug_publisher_;

std::unique_ptr<autoware_utils::StopWatch<std::chrono::milliseconds>> stop_watch_ptr_;
diagnostic_updater::Updater diagnostic_updater_{this};

void initialize();
Copy link
Contributor

Choose a reason for hiding this comment

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

Please choose a more descriptive name, such as initialize_pub_sub etc.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Addressed in 2e49f11

// See the License for the specific language governing permissions and
// limitations under the License.

//#include "autoware/pointcloud_preprocessor/concatenate_data/concatenate_and_time_sync_node.hpp"
Copy link
Contributor

Choose a reason for hiding this comment

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

Please remove this unneeded commented out statement

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks. Addressed in 2c51d20

Comment on lines 210 to 212
this->get_clock()->now().seconds(),
this->get_clock()->now().seconds() - rclcpp::Time(input_ptr->header.stamp).seconds());
}
Copy link
Contributor

Choose a reason for hiding this comment

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

This should be reverted to cloud_arrival_time given that's what the log message says.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks. It seem this got into due to the rebases...
Addressed in 8fe850c

Copy link
Contributor

Choose a reason for hiding this comment

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

As far as I can tell, nothing in the CollectorMatchingStrategy directly interacts with pointclouds and thus no templating should be necessary.

It looks like templating was done because CloudCollector is also templated and appears as an argument. I would suggest creating a non-templated CloudCollectorBase to solve this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I did try that, but ended up creating more mess than it solved. For such simple structure, I don't think that the increased binary size is a problem. Additionally, when everything is templated, it is easier to extend behavior later down the line

}

template <typename MsgTraits>
std::string PointCloudConcatenateDataSynchronizerComponentTemplated<MsgTraits>::format_timestamp(
Copy link
Contributor

Choose a reason for hiding this comment

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

Functions like these should not need to be templated. With this particular one, moving it out of the class is probably best.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If there were more than just this one or there was an helper header with these functions I would agree. But I prefer having it here repeated by each template instantiation rather than have a single dangling method

Copy link
Contributor

Choose a reason for hiding this comment

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

Please put CombineCloudHandlerBase and CombineCloudHandler<PointCloud2Traits> into separate files. It is difficult to quickly discern between common and PC2-specific functionality.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Addressed in 8b44c16

knzo25 added 5 commits March 27, 2025 17:28
Signed-off-by: Kenzo Lobos-Tsunekawa <[email protected]>
Signed-off-by: Kenzo Lobos-Tsunekawa <[email protected]>
Signed-off-by: Kenzo Lobos-Tsunekawa <[email protected]>
Signed-off-by: Kenzo Lobos-Tsunekawa <[email protected]>
Signed-off-by: Kenzo Lobos-Tsunekawa <[email protected]>
knzo25 added 6 commits March 27, 2025 20:42
Signed-off-by: Kenzo Lobos-Tsunekawa <[email protected]>
Signed-off-by: Kenzo Lobos-Tsunekawa <[email protected]>
Signed-off-by: Kenzo Lobos-Tsunekawa <[email protected]>
@knzo25 knzo25 requested review from vividf, mojomex and amadeuszsz March 27, 2025 12:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component:sensing Data acquisition from sensors, drivers, preprocessing. (auto-assigned) run:build-and-test-differential Mark to enable build-and-test-differential workflow. (used-by-ci)
Projects
Status: To Triage
Development

Successfully merging this pull request may close these issues.

4 participants