-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Create iterator for custom height field in pointcloud. #5586
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
Draft
greganderson-vermeer
wants to merge
8
commits into
ros-navigation:main
Choose a base branch
from
greganderson-vermeer:feat/CustomCollisionPointFields
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+36
−3
Draft
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
5860a27
Create iterator for custom height field in pointcloud.
greganderson-vermeer 7e6ccc9
Add use_global_height_ parameter to allow configuration
greganderson-vermeer ca49b05
Ran ament lint/style tools, cleaned up.
greganderson-vermeer 11f04c7
Added some pointcloud field checking based on run time
greganderson-vermeer 869b5a9
Address PR formatting feedback.
greganderson-vermeer 1cdbc05
Add return false for error state.
greganderson-vermeer b2fbb06
Implemented additional changes for iterator feedback
greganderson-vermeer 5636fc1
Implementing Steve's suggestion for performance and
greganderson-vermeer File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -106,21 +106,43 @@ bool PointCloud::getData( | |||||
sensor_msgs::PointCloud2ConstIterator<float> iter_y(*data_, "y"); | ||||||
sensor_msgs::PointCloud2ConstIterator<float> iter_z(*data_, "z"); | ||||||
|
||||||
bool height_present = false; | ||||||
for(const auto & field : data_->fields) { | ||||||
if (field.name == "height") { | ||||||
height_present = true; | ||||||
} | ||||||
} | ||||||
|
||||||
// Reference height field | ||||||
std::string height_field{"z"}; | ||||||
if (use_global_height_ && height_present) { | ||||||
height_field = "height"; | ||||||
} else if (use_global_height_) { | ||||||
RCLCPP_ERROR(logger_, "[%s]: 'use_global_height' parameter true but height field not in cloud", | ||||||
source_name_.c_str()); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
return false; | ||||||
} | ||||||
sensor_msgs::PointCloud2ConstIterator<float> iter_height(*data_, height_field); | ||||||
|
||||||
// Refill data array with PointCloud points in base frame | ||||||
for (; iter_x != iter_x.end(); ++iter_x, ++iter_y, ++iter_z) { | ||||||
// Transform point coordinates from source frame -> to base frame | ||||||
tf2::Vector3 p_v3_s(*iter_x, *iter_y, *iter_z); | ||||||
|
||||||
double data_height = *iter_z; | ||||||
if (use_global_height_) { | ||||||
data_height = *iter_height; | ||||||
++iter_height; | ||||||
} | ||||||
|
||||||
// Check range from sensor origin before transformation | ||||||
double range = p_v3_s.length(); | ||||||
if (range < min_range_) { | ||||||
continue; | ||||||
} | ||||||
|
||||||
tf2::Vector3 p_v3_b = tf_transform * p_v3_s; | ||||||
|
||||||
// Refill data array | ||||||
if (p_v3_b.z() >= min_height_ && p_v3_b.z() <= max_height_) { | ||||||
if (data_height >= min_height_ && data_height <= max_height_) { | ||||||
data.push_back({p_v3_b.x(), p_v3_b.y()}); | ||||||
} | ||||||
} | ||||||
|
@@ -148,6 +170,9 @@ void PointCloud::getParameters(std::string & source_topic) | |||||
nav2::declare_parameter_if_not_declared( | ||||||
node, source_name_ + ".transport_type", rclcpp::ParameterValue(std::string("raw"))); | ||||||
transport_type_ = node->get_parameter(source_name_ + ".transport_type").as_string(); | ||||||
nav2::declare_parameter_if_not_declared( | ||||||
node, source_name_ + ".use_global_height", rclcpp::ParameterValue(false)); | ||||||
use_global_height_ = node->get_parameter(source_name_ + ".use_global_height").as_bool(); | ||||||
} | ||||||
|
||||||
void PointCloud::dataCallback(sensor_msgs::msg::PointCloud2::ConstSharedPtr msg) | ||||||
|
@@ -178,6 +203,8 @@ PointCloud::dynamicParametersCallback( | |||||
} else if (param_type == rcl_interfaces::msg::ParameterType::PARAMETER_BOOL) { | ||||||
if (param_name == source_name_ + "." + "enabled") { | ||||||
enabled_ = parameter.as_bool(); | ||||||
} else if (param_name == source_name_ + "." + "use_global_height") { | ||||||
use_global_height_ = parameter.as_bool(); | ||||||
} | ||||||
} | ||||||
} | ||||||
|
Oops, something went wrong.
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.
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.