-
Notifications
You must be signed in to change notification settings - Fork 73
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
Conversation
- removed some layer dependent variables - removed server connection. It can be readded at a later point. But right now it is old code and we don't know how it works. So for now I think it's better to remove it.
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.
Nice additions to the map! I also like that you removed the service code.
Being able to load more kinds of meshes sounds very useful.
I added a few comments, the logic looks good.
I have some remarks that hopefully increase readability/maintainability, please check them out.
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 comment
The reason will be displayed to describe this comment to others. Learn more.
Whoops, was the descriptor never used when declaring the parameter? 🫢
Nice fix.
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.
Yeah, but at least it was described for anyone reading the code 😅
mesh_map/include/mesh_map/mesh_map.h
Outdated
|
||
//! dynamic params callback handle | ||
rclcpp::node_interfaces::OnSetParametersCallbackHandle::SharedPtr config_callback; | ||
|
||
rclcpp::Service<std_srvs::srv::Empty>::SharedPtr save_service; |
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 think it would be nice to get a response on whether saving worked out.
# empty request?
string path_to_map # or maybe allow defining a path here?
---
bool was_successful
string failure_reason # empty string if was_successful is true. Otherwise, e.g. "cannot open file '/path/to/map'"
Still, leaving it like it is now is a nice upgrade on the previous version. 👍
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, I would like this too. Perhaps something for the near future. Is there a std_srvs service for that already?
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, indeed: std_srvs/Trigger
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 changed the service from Empty to Trigger
@@ -141,6 +141,9 @@ class BorderLayer : public mesh_map::AbstractLayer | |||
double border_cost = 1.0; | |||
double factor = 1.0; | |||
} config_; | |||
|
|||
// put this to base class? | |||
std::string name; |
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
std::string name; | |
std::string name_; |
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.
mesh_map/include/mesh_map/mesh_map.h
Outdated
//! mesh file | ||
std::string mesh_file; | ||
|
||
//! mesh part | ||
std::string mesh_part; | ||
|
||
//! mesh working file | ||
std::string mesh_working_file; | ||
|
||
//! mesh working part | ||
std::string mesh_working_part; |
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.
The comments are superfluous, since they only consist of the variable's name. Leaving them in place does not add any clarity and they might become out-of-date when the code changes, leading to confusion.
Either remove them or replace them by an explanation, if necessary.
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.
Also, you could add a path
or file_path
to the variable name, if it is a path. I think e.g. mesh_file
is probably not the actual file (or pointer to some data in that file), but just the filesystem path. Since its type is std::string
! :) But that might just be my personal preference. 🤷
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.
What working
means could use an explanation.
Why are there working and non-working versions of file&part?
Maybe salvage a few words from your PR description:
Internally it is divided into an input file and working file. The input file is an arbitrary mesh format (that can be loaded by assimp or HDF5) the working file is always a HDF5. I added a service which can be used to save the current state to the working file.
Or maybe find better names, e.g. call them mesh_input_file
/mesh_input_part
and mesh_working_file
/mesh_working_part
.
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.
The comments are superfluous, since they only consist of the variable's name. Leaving them in place does not add any clarity and they might become out-of-date when the code changes, leading to confusion. Either remove them or replace them by an explanation, if necessary.
Agree. I was just adapting to the comment style that was already there 😁 There could be a complete PR about cleaning up all of the comments plus all the error messages.
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.
Also, you could add a
path
orfile_path
to the variable name, if it is a path. I think e.g.mesh_file
is probably not the actual file (or pointer to some data in that file), but just the filesystem path. Since its type isstd::string
! :) But that might just be my personal preference. 🤷
Agree, I was again just adapting the style. However, I would move that to a seperate "better style" PR.
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.
What
working
means could use an explanation. Why are there working and non-working versions of file&part?Maybe salvage a few words from your PR description: Internally it is divided into an input file and working file. The input file is an arbitrary mesh format (that can be loaded by assimp or HDF5) the working file is always a HDF5. I added a service which can be used to save the current state to the working file.
Or maybe find better names, e.g. call them
mesh_input_file
/mesh_input_part
andmesh_working_file
/mesh_working_part
.
Agree. I will push a commit with some docs soon.
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.
Great, thanks!
mesh_map/src/mesh_map.cpp
Outdated
// RCLCPP_INFO_STREAM(node->get_logger(), "Writing '" << layer_name << "' to file."); | ||
// layer_plugin->writeLayer(); | ||
// RCLCPP_INFO_STREAM(node->get_logger(), "Finished writing '" << layer_name << "' to file."); |
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.
Please delete these lines, if they are not necessary anymore.
Or, if you think they might become useful later, maybe make them DEBUG
logs. This will ensure they get considered in refactorings and won't become weird dead code (comments) in the long run.
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.
done
mesh_map/src/mesh_map.cpp
Outdated
// TODO how to declare param for each plugin? | ||
// Needs to be done after plugins are loaded, which happens when the map gets loaded. Who calls readMap() and when? |
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.
Is this outdated?
Each plugin needs to define its own parameters. They do that in the initialize()
method, but I see that you already found that method.
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.
outdated. removed
namespace mesh_map | ||
{ | ||
|
||
// again this function |
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.
What do you mean by that? Did you write / see this function someplace else already?
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 was just a joke. Because in 2024 I still have to write a split_by_delimiter function for a std::string. I removed it
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 see ^^
std::shared_ptr<std_srvs::srv::Empty::Response> response) | ||
{ | ||
saveLayers(); | ||
}); | ||
} | ||
|
||
bool MeshMap::readMap() |
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.
Reading the code that loads the mesh map was a bit confusing with all the different cases and different ways the working/non-working variables can be filled (via user or automatically).
Is there a way to simplify the logic?
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.
Perhaps there is a way. But I haven't found it yet :D
Co-authored-by: Matthias Holoch <[email protected]>
Co-authored-by: Matthias Holoch <[email protected]>
Co-authored-by: Matthias Holoch <[email protected]>
Co-authored-by: Matthias Holoch <[email protected]>
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 reiterating! 👍
@@ -434,16 +441,22 @@ class MeshMap | |||
//! global frame / coordinate system id | |||
std::string global_frame; | |||
|
|||
//! mesh file | |||
//! Filename of the input mesh. Can be any format the assimp library supports to load. | |||
//! https://github.com/assimp/assimp/blob/master/doc/Fileformats.md |
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.
nice
I tested the three maps from the mesh nav tutorials and everything went fine. |
I just ran a few successful tests with your branch and our tutorials. |
What I did: