-
Notifications
You must be signed in to change notification settings - Fork 79
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
Dynamic loading of different mesh formats #66
Merged
Merged
Changes from 8 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
6367eb2
Cleanup of mesh map:
amock edd9cb2
added template for generic mesh file loading
amock 6324829
Added conversion from assimp scene to lvr meshbuffer
amock f1ed54a
added todos
amock ea31a4d
loaded geometry from a common mesh file format
amock 544bbba
loading PLY works. DAE cannot be loaded still don't know why.
amock fa39eb4
added service to save the changed layers
amock ec6721f
layer are pointing to same named hdf5 datasets
amock 1c9a67e
Update mesh_map/include/mesh_map/mesh_map.h
amock 07ca274
Update mesh_map/src/mesh_map.cpp
amock acb2c0f
Update mesh_map/src/mesh_map.cpp
amock c983453
cleanup
amock 0787ac1
Update mesh_map/src/util.cpp
amock c087a33
removed name member variable since it is not used anymore
amock 2b95a06
added docs to saveLayers
amock 8524819
added std_srvs Trigger instead of Empty
amock ef42e0a
if only a h5 is provided the same file is used as input and working file
amock 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 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 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 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 |
---|---|---|
|
@@ -48,13 +48,12 @@ namespace mesh_layers | |
bool BorderLayer::readLayer() | ||
{ | ||
RCLCPP_INFO_STREAM(node_->get_logger(), "Try to read border costs from map file..."); | ||
auto border_costs_opt = mesh_io_ptr_->getDenseAttributeMap<lvr2::DenseVertexMap<float>>("border"); | ||
auto border_costs_opt = mesh_io_ptr_->getDenseAttributeMap<lvr2::DenseVertexMap<float> >(layer_name_); | ||
|
||
if (border_costs_opt) | ||
{ | ||
RCLCPP_INFO_STREAM(node_->get_logger(), "Border costs have been read successfully."); | ||
border_costs_ = border_costs_opt.get(); | ||
|
||
return computeLethals(); | ||
} | ||
|
||
|
@@ -80,7 +79,7 @@ bool BorderLayer::computeLethals() | |
bool BorderLayer::writeLayer() | ||
{ | ||
RCLCPP_INFO_STREAM(node_->get_logger(), "Saving border costs to map file..."); | ||
if (mesh_io_ptr_->addDenseAttributeMap(border_costs_, "border")) | ||
if (mesh_io_ptr_->addDenseAttributeMap(border_costs_, layer_name_)) | ||
{ | ||
RCLCPP_INFO_STREAM(node_->get_logger(), "Saved border costs to map file."); | ||
return true; | ||
|
@@ -113,56 +112,76 @@ rcl_interfaces::msg::SetParametersResult BorderLayer::reconfigureCallback(std::v | |
rcl_interfaces::msg::SetParametersResult result; | ||
result.successful = true; | ||
|
||
bool has_threshold_changed = false; | ||
for (auto parameter : parameters) { | ||
// bool has_threshold_changed = false; | ||
bool recompute_costs = false; | ||
bool recompute_lethals = false; | ||
|
||
for (auto parameter : parameters) | ||
{ | ||
if (parameter.get_name() == mesh_map::MeshMap::MESH_MAP_NAMESPACE + "." + layer_name_ + ".threshold") { | ||
config_.threshold = parameter.as_double(); | ||
has_threshold_changed = true; | ||
recompute_lethals = true; | ||
} else if (parameter.get_name() == mesh_map::MeshMap::MESH_MAP_NAMESPACE + "." + layer_name_ + ".border_cost") { | ||
config_.border_cost = parameter.as_double(); | ||
recompute_costs = true; | ||
recompute_lethals = true; | ||
} else if (parameter.get_name() == mesh_map::MeshMap::MESH_MAP_NAMESPACE + "." + layer_name_ + ".factor") { | ||
config_.factor = parameter.as_double(); | ||
} | ||
} | ||
|
||
if (has_threshold_changed) { | ||
RCLCPP_INFO_STREAM(node_->get_logger(), "Recompute lethals and notify change from " << layer_name_ << " due to cfg change."); | ||
if(recompute_costs) | ||
{ | ||
RCLCPP_INFO_STREAM(node_->get_logger(), "'" << layer_name_ << "': Recompute layer costs due to cfg change."); | ||
computeLayer(); | ||
} | ||
|
||
if (recompute_lethals) | ||
{ | ||
RCLCPP_INFO_STREAM(node_->get_logger(), "'" << layer_name_ << "': Recompute lethals due to cfg change."); | ||
computeLethals(); | ||
} | ||
|
||
if(recompute_costs || recompute_lethals) | ||
{ | ||
RCLCPP_INFO_STREAM(node_->get_logger(), "'" << layer_name_ << "': Notify changes."); | ||
notifyChange(); | ||
} | ||
|
||
return result; | ||
} | ||
|
||
|
||
bool BorderLayer::initialize() | ||
{ | ||
{ // threshold | ||
rcl_interfaces::msg::ParameterDescriptor descriptor; | ||
descriptor.description = "Threshold for the local border costs to be counted as lethal."; | ||
descriptor.type = rcl_interfaces::msg::ParameterType::PARAMETER_DOUBLE; | ||
rcl_interfaces::msg::FloatingPointRange range; | ||
range.from_value = 0.05; | ||
range.to_value = 1.0; | ||
descriptor.floating_point_range.push_back(range); | ||
config_.threshold = node_->declare_parameter(mesh_map::MeshMap::MESH_MAP_NAMESPACE + "." + layer_name_ + ".threshold", config_.threshold); | ||
config_.threshold = node_->declare_parameter(mesh_map::MeshMap::MESH_MAP_NAMESPACE + "." + layer_name_ + ".threshold", config_.threshold, descriptor); | ||
} | ||
{ // border cost | ||
rcl_interfaces::msg::ParameterDescriptor descriptor; | ||
descriptor.description = "The cost value used for the border vertices."; | ||
descriptor.type = rcl_interfaces::msg::ParameterType::PARAMETER_DOUBLE; | ||
rcl_interfaces::msg::FloatingPointRange range; | ||
range.from_value = 0.02; | ||
range.to_value = 10.0; | ||
descriptor.floating_point_range.push_back(range); | ||
config_.border_cost = node_->declare_parameter(mesh_map::MeshMap::MESH_MAP_NAMESPACE + "." + layer_name_ + ".border_cost", config_.border_cost); | ||
config_.border_cost = node_->declare_parameter(mesh_map::MeshMap::MESH_MAP_NAMESPACE + "." + layer_name_ + ".border_cost", config_.border_cost, descriptor); | ||
} | ||
{ // factor | ||
rcl_interfaces::msg::ParameterDescriptor descriptor; | ||
descriptor.description = "Using this factor to weight this layer."; | ||
descriptor.type = rcl_interfaces::msg::ParameterType::PARAMETER_DOUBLE; | ||
rcl_interfaces::msg::FloatingPointRange range; | ||
range.from_value = 0.0; | ||
range.to_value = 1.0; | ||
descriptor.floating_point_range.push_back(range); | ||
config_.factor = node_->declare_parameter(mesh_map::MeshMap::MESH_MAP_NAMESPACE + "." + layer_name_ + ".factor", config_.factor); | ||
config_.factor = node_->declare_parameter(mesh_map::MeshMap::MESH_MAP_NAMESPACE + "." + layer_name_ + ".factor", config_.factor, descriptor); | ||
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. Whoops, was the descriptor never used when declaring the parameter? 🫢 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. Yeah, but at least it was described for anyone reading the code 😅 |
||
} | ||
dyn_params_handler_ = node_->add_on_set_parameters_callback(std::bind( | ||
&BorderLayer::reconfigureCallback, this, std::placeholders::_1)); | ||
|
This file contains 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 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 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
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.
codestyle
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.
Wait, is this even used? I think you're only using the
layer_name_
attribute from the base class in the cpp file.Looks like this is a leftover from experimenting.
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.
Yes, it's basically how it is written in the comments. "Put this to base class" then I jumped to the base class and saw, there is a variable already. So "name" can be removed safely.