ros-perception / laser_filters

Assorted filters designed to operate on 2D planar laser scanners, which use the sensor_msgs/LaserScan type.
BSD 3-Clause "New" or "Revised" License
172 stars 204 forks source link

feature: components support #188

Closed jcarlosgm30 closed 2 months ago

jcarlosgm30 commented 9 months ago

Hello,

I think that it can be very interesting to transform the "filter_chains" into ROS2 components. This is crucial to facilitate the creation of more flexible and efficient laser pipelines.

This pull request fits this feature.

Key Changes:

Benefits:

Functionality Status:

I eagerly await feedback and am willing to make any necessary adaptations to align even more closely with the project's needs and expectations. These changes are designed to not only improve the current development experience but also to open up new possibilities for future enhancements and features.

jonbinney commented 9 months ago

Wow, this is cool! Thanks @jcarlosgm30 for implementing it! This seems like a good change, but since it is a big change it'll take some time to understand, review and test, especially to ensure backwards compatibility.

A few questions:

jcarlosgm30 commented 9 months ago

Hi @jonbinney,

Thank you for the reply! I will try to answer the questions as best I can:

how backwards compatible is this? Will people who depend on laser_filters be able to use their existing launchfiles and yaml files without modification? Currently, it is backward compatible with all its functionalities, except for the name of the executables. This is an item of discussion, as I have added *_node to the executables to maintain a naming convention concerning the libraries that generate the component. To maintain full backwards compatibility, we can keep the same name in the executables as before (without *_node) and assign the name you deem appropriate to the libraries.

could you give some more detail about how this is more efficient? and more flexible? than the current filters implementation? With composition, it is possible to:

Therefore, this allows us to create pipelines (e.g. driver+filters+other functionalities) that run in the same process improving efficiency and overhead. Or run the system, as it has been done so far, on a separate node.

have you been using this on your own robots? How much testing has it seen so far? The changes have been tested on simulation and also on a TIAGo robot from PAL Robotics. The system has been running while navigating the robot for one hour, without encountering any problems. But, I encourage you to test it anyway.

If you have any further questions or I can do anything to further align the solution with the project, please let me know

jonbinney commented 6 months ago

When I initially read the title of this PR, I thought it was turning each individual filter into a ros2 component.... but now I see that it is much simpler than that. The big scary diff is due to a few things:

  1. Adding header files and moving class declarations into them
  2. Adding a laser_filters namespace
  3. Appending _node the filter chain executable names

(1) and (2) are good changes overall, but usually I'd like to have them in a separate PR that doesn't change any functionality. IMixing them into a PR that adds components makes it very hard to see the actually important changes. Also they make it harder to look back through git history, so in general I tend to leave it as is. (3) breaks all launchfiles not hosted in this repo, so we'd need a very strong reason to allow it, and do at least one ROS distro with a deprecation notice where we have both executables, etc. etc.

@jcarlosgm30 can you undo the changes I describe in (1), (2), and (3) and just leave the changes that makes the filter chain nodes into components? I think that should be easier to review and merge. Or is there something about these other changes that is necessary?

jcarlosgm30 commented 6 months ago

Hi @jonbinney ,

The changes (2) and (3) are neither necessary nor significant. However, in my opinion, change (1) from a functionality and expressiveness point of view is recommendable. The component has to be compiled as a shared library, and we want to keep backward compatibility by having an executable node for each filter chain.

So in this case, from a software point of view, it makes sense to keep the library separate from the executable. The library can be loaded by the component container that needs it, while the executable simply makes use of the library.

jonbinney commented 6 months ago

The component has to be compiled as a shared library, and we want to keep backward compatibility by having an executable node for each filter chain.

Yes we want the executable - but that doesn't require doing (1), (2), or (3), right? Or am i misunderstanding?

jcarlosgm30 commented 6 months ago

Yes, it doesn't require doing (1), (2) or (3). But (1) is highly recommended from a functionality and expressiveness point of view. Otherwise, we must compile the same .cpp as a shared library and an executable. This is something I don't like because it violates many of the best practices in software development.

jonbinney commented 6 months ago

Adding new functionality and doing code reorganization in one commit also violates many of the best practices of software development :-)

Could you undo the renaming of the nodes and undo the adding of the laser_filters namespace, as well as split the file reorganization and adding of the components into two commits so that I can diff them separately? Then I'll do a detailed review to make sure everything looks good. Thanks @jcarlosgm30 !

jcarlosgm30 commented 4 months ago

Hi @jonbinney! Sorry for taking so long to reply, I've been away for a while.

Adding new functionality and doing code reorganization in one commit also violates many of the best practices of software development :-)

You are absolutely right! putting all the code in a commit is also a bad practice

Could you undo the renaming of the nodes and undo the adding of the laser_filters namespace, as well as split the file reorganization and adding of the components into two commits so that I can diff them separately?

Sure! once I get this done, let me know anything I can help with!

Thanks!

jonbinney commented 4 months ago

Looks like you update this PR - thanks for working on this! Is it ready for me to take another look?

jcarlosgm30 commented 4 months ago

@jonbinney Yes, I undid the renaming of the nodes and the laser_filters namespace. Also, I've split the file reorganization and the components into two different commits

jonbinney commented 2 months ago

Looks good. @jcarlosgm30 thanks for this PR!