transform polygone: Do not clear poly_in before transforming points#697
Open
Fellfalla wants to merge 2 commits intoros2:rollingfrom
Open
transform polygone: Do not clear poly_in before transforming points#697Fellfalla wants to merge 2 commits intoros2:rollingfrom
Fellfalla wants to merge 2 commits intoros2:rollingfrom
Conversation
ahcorde
requested changes
Jun 19, 2024
Contributor
ahcorde
left a comment
There was a problem hiding this comment.
CI is not compiling https://build.ros2.org/job/Rpr__geometry2__ubuntu_noble_amd64/97/console
CursedRock17
suggested changes
Aug 22, 2025
Contributor
CursedRock17
left a comment
There was a problem hiding this comment.
I have left a change that should resolve the bug fix, while implementing this feature, without adding extra bloat. Branch reference for a quick test of the code that works for me.
Comment on lines
+466
to
+470
| std::vector<geometry_msgs::msg::Point32> points_transformed(poly_in.points.size(), {}); | ||
| for (size_t i=0; i < poly_in.points.size(); ++i) { | ||
| doTransform(poly_in.points[i], points_transformed[i], transform); | ||
| } | ||
| poly_out.points = points_transformed; |
Contributor
There was a problem hiding this comment.
Suggested change
| std::vector<geometry_msgs::msg::Point32> points_transformed(poly_in.points.size(), {}); | |
| for (size_t i=0; i < poly_in.points.size(); ++i) { | |
| doTransform(poly_in.points[i], points_transformed[i], transform); | |
| } | |
| poly_out.points = points_transformed; | |
| poly_out.points.resize(poly_in.points.size()); | |
| for (size_t i = 0; i < poly_in.points.size(); ++i) { | |
| doTransform(poly_in.points[i], poly_out.points[i], transform); | |
| } |
The tf2::Polygon cannot handle the = assignment cleanly, so the corresponding test fails. But if we want, an easy fix is to just call reserve on poly_out before we run the doTransform loop, then it will ensure there's space for the referenced point to be moved into the function call. This is beneficial since we're not copying any values.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Before this MR,
doTransform(my_poly, my_poly, transform)did not work as it does for other messages, e.g. pose.If this is the desired behavior should be discussed.