Skip to content
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

Yet Another filters port to ROS 2 #32

Merged
merged 20 commits into from
May 14, 2020
Merged

Conversation

sloretz
Copy link

@sloretz sloretz commented Apr 4, 2020

Alternative to #19 and #24. The parameter specification of filter1..filterN @swatifulzele came up with in #24 is used here, but implemented a bit differently.

I've been working on this a while. Here's a package where I was playing with porting laser filters with very similar code to this port: https://github.com/sloretz/ros2_laser_filters

TODO

  • @tfoote May I fast-forward merge the ros2 branch up to noetic-devel? edit: done
  • There's some dead code removal (seed_rand and generate_rand_vectors()) that could be moved to a separate PR and done in noetic-devel too edit opened [noetic] Delete unused code #33
  • There are some commented tests in test_chain.cpp that were deleted and could be done in a separate PR in noetic-devel too edit opened [noetic] Delete unused code #33
    *This PR moves headers from .h to .hpp, so it should not be squash merged because then the history of that move is lost. Instead it should be squashed to two commits where the first renames the files and the second is all the changes and then rebase and merged. edit opened [noetic] deprecate h for hpp #34
  • This PR does not address style; and does not enable the ROS 2 style tests. I figured that can be done in a follow up PR.

Differences from #24:

  • This builds on ROS Eloquent instead of ROS Bouncy
  • Use node logger and parameter interfaces instead of expecting rclcpp::Node so it works with lifecycle nodes
  • Keep getParam() functions so downstream filter changes are less
    • This is implemented by declaring the parameter if not declared in getParam()
  • Keeps license the same
  • I tried to only change lines if I needed to or if they caused a compiler warning
  • The original tests all run and pass 🎉

@sloretz sloretz requested a review from tfoote April 4, 2020 01:05
@sloretz sloretz self-assigned this Apr 4, 2020
@sloretz sloretz changed the base branch from ros2 to noetic-devel April 4, 2020 01:20
@sloretz sloretz changed the base branch from noetic-devel to ros2 April 4, 2020 01:20
This was referenced Apr 4, 2020
Signed-off-by: Shane Loretz <[email protected]>

include .h -> include .hpp

Signed-off-by: Shane Loretz <[email protected]>

Port FilterBase, MultiChannelFilterBase, and all filters to ROS 2

Signed-off-by: Shane Loretz <[email protected]>

Fix compile warning

Signed-off-by: Shane Loretz <[email protected]>

don't concatenate if prefix is empty

Signed-off-by: Shane Loretz <[email protected]>

Prefix param only once

Signed-off-by: Shane Loretz <[email protected]>

Don't install test_param plugin

Signed-off-by: Shane Loretz <[email protected]>

Build type ament_cmake

Signed-off-by: Shane Loretz <[email protected]>

Port single channel filter chain

Signed-off-by: Shane Loretz <[email protected]>

Factor out parameter parsing

Signed-off-by: Shane Loretz <[email protected]>

move load_chain_config to free function

Signed-off-by: Shane Loretz <[email protected]>

Port MultiChannelFilterChain to ROS 2

Signed-off-by: Shane Loretz <[email protected]>

Delete unused files from ROS 1

Signed-off-by: Shane Loretz <[email protected]>
Copy link

@clalancette clalancette left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First pass, mostly small things. I'll do another pass later that is more thorough.

include/filters/filter_base.hpp Show resolved Hide resolved
include/filters/filter_base.hpp Outdated Show resolved Hide resolved
include/filters/filter_base.hpp Outdated Show resolved Hide resolved
CMakeLists.txt Show resolved Hide resolved
CMakeLists.txt Outdated Show resolved Hide resolved
CMakeLists.txt Outdated Show resolved Hide resolved
CMakeLists.txt Show resolved Hide resolved
include/filters/filter_base.hpp Outdated Show resolved Hide resolved
include/filters/filter_chain.hpp Show resolved Hide resolved
Signed-off-by: Shane Loretz <[email protected]>
Copy link

@clalancette clalancette left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a lot of legacy stuff in here. I've left specific comments inline, but some overall comments:

  1. We should open an issue to follow-up and cleanup the style everywhere, including removing trailing whitespace.
  2. We should mark all of the methods that are overriding the parent methods as override to give the compiler a hint.
  3. The types in some of these classes are a bit loose. Comparing unsigned int/uint32_t to size_t, for instance, may be a problem on some architectures. Probably should make an issue to clean that up.

package.xml Outdated
<run_depend>boost</run_depend>
<depend>pluginlib</depend>
<depend>rclcpp</depend>
<depend>boost</depend>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bah. We could almost make the boost dependency a build_depend; we only use circular_buffer, which is header only. The only problem is that it is used in an exported header (include/filters/realtime_circular_buffer.hpp), so downstream consumers still need to know about it. I'll suggest that we either remove boost completely, or change this to a PIMPL pattern so we can do that. But feel free to punt on that and just open an issue to follow-up in the future.

(also nit: alphabetize)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I started the port by trying to eliminate the dependency on boost in ROS 1, but I wasn't able to find a good replacement for realtime_circular_buffer :( . #30

I'll punt on the pimpl pattern for now.

CMakeLists.txt Outdated
)

if(BUILD_TESTING)
# TODO(sloretz) this disables ROS 2 style tests; reenable and fix style

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please open an issue to follow-up on this.

CMakeLists.txt Show resolved Hide resolved
package.xml Outdated Show resolved Hide resolved
return true;
}

protected:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we collapse all of the protected sections into one? And then put the private section after that?

include/filters/filter_base.hpp Outdated Show resolved Hide resolved
const rclcpp::node_interfaces::NodeParametersInterface::SharedPtr & node_params,
std::vector<struct FoundFilter> & found_filters)
{
// TODO(sloretz) error if someone tries to do filter0

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you open an issue for this?

Comment on lines 60 to 66
// Make prefix be an empty string or a string ending in '.'
std::string norm_param_prefix = param_prefix;
if (!norm_param_prefix.empty()) {
if ('.' != norm_param_prefix.back()) {
norm_param_prefix += '.';
}
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like common code, at least it is duplicated here with FilterBase. Maybe make a utility? Feel free to open an issue to followup.

include/filters/increment.hpp Outdated Show resolved Hide resolved
sloretz and others added 10 commits April 22, 2020 18:37
Co-Authored-By: Chris Lalancette <[email protected]>
Co-Authored-By: Chris Lalancette <[email protected]>
Co-Authored-By: Chris Lalancette <[email protected]>
Signed-off-by: Shane Loretz <[email protected]>
Signed-off-by: Shane Loretz <[email protected]>
Signed-off-by: Shane Loretz <[email protected]>
Signed-off-by: Shane Loretz <[email protected]>
Signed-off-by: Shane Loretz <[email protected]>
Signed-off-by: Shane Loretz <[email protected]>
@clalancette
Copy link

All right, with the latest changes this is getting closer. I think there are a few open problems that would be nice to fix now, and a few to punt until later. The ones I think we can do now without too much work:

  1. Make a utility method to normalize the parameter prefix to be empty or a string and .
  2. Mark methods with override as appropriate.
  3. Collapse all of the FilterBase class protected/private sections into one of each.

And then here are ones I think we can punt on until a later PR:

  1. Remove boost::circular_buffer, or at least PIMPL it so it is a build_depend only.
  2. Cleanup style and whitespace everywhere.
  3. Cleanup types, particularly around uint/size_t
  4. Fix errors if someone does filter0.

Signed-off-by: Michel Hidalgo <[email protected]>
Signed-off-by: Michel Hidalgo <[email protected]>
Signed-off-by: Michel Hidalgo <[email protected]>
Signed-off-by: Michel Hidalgo <[email protected]>
@hidmic
Copy link

hidmic commented Apr 30, 2020

@sloretz @clalancette I've opened sloretz#1 against this PR's branch. I believe I've addressed most pain points, except:

Remove boost::circular_buffer, or at least PIMPL it so it is a build_depend only.

Which is somewhat tricky as filters:;RealtimeCircularBuffer is a template class itself and a type erased PIMPL seemed a bit too much to me, and

Fix errors if someone does filter0.

As I think that should be entirely handled by rclcpp itself. It currently bans setting undeclared parameters if allow_undeclared_parameters is false, but you can still provide an undeclared parameter override on start up and that will not produce any error nor warning. API to let rclcpp know that no further parameter declaration will occur may help with this.

Copy link

@clalancette clalancette left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've reviewed this pretty thoroughly in both @sloretz's original incarnation and @hidmic's PR, so I'm comfortable with this now. I'll see about getting this merged and released.

These are also backwards compatible with Eloquent's uncrustify.

Signed-off-by: Chris Lalancette <[email protected]>
Only shows up in Foxy, but it is definitely a bug.

Signed-off-by: Chris Lalancette <[email protected]>
@clalancette
Copy link

All right, this is relatively happy on both Eloquent and Foxy now. With blessing from @tfoote , merging this in and doing some releases for Eloquent and Foxy. Thanks to @swatifulzele for the initial work, @sloretz for this port, and @hidmic for the updates.

@clalancette clalancette merged commit 1b9ffbf into ros:ros2 May 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants