Skip to content

Implemented a generic filters plugin #1634

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
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

ankurbodhe
Copy link

This PR migrates and enhances the chained_filter_controller originally implemented during the ROSCon 2024 control workshop. The controller enables chaining and filtering of state interfaces through a sequence of filters.

Changes introduced:

  1. Ported chained_filter_controller from workshop reference implementation.
  2. Developed unit tests covering:
    • Initialization and lifecycle behavior.
    • Filter configuration and chaining.
    • Correct propagation of state values through the filter stack.

@ankurbodhe
Copy link
Author

@christophfroehlich I just made another commit to fix the issues in the workflow.. requesting you to approve to workflow

@saikishor
Copy link
Member

@ankurbodhe can you fix the pre-commit jobs?

Is this ready for review?

Copy link
Contributor

@christophfroehlich christophfroehlich left a comment

Choose a reason for hiding this comment

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

Thank you for contribution!
In general, have a look at other packages in this repository to follow the (code) style, copyright claims etc.

Please address my comments and also fix the pre-commit failures as Sai already has mentioned.

Comment on lines +5 to +8
# Enable warnings
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wall -Wextra -Wpedantic)
endif()
Copy link
Contributor

Choose a reason for hiding this comment

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

please have a look at the other packages, we use ros2_control_cmake instead

Comment on lines +11 to +18
find_package(ament_cmake REQUIRED)
find_package(controller_interface REQUIRED)
find_package(filters REQUIRED)
find_package(pluginlib REQUIRED)
find_package(rclcpp REQUIRED)
find_package(rclcpp_lifecycle REQUIRED)
find_package(hardware_interface REQUIRED)
find_package(generate_parameter_library REQUIRED)
Copy link
Contributor

Choose a reason for hiding this comment

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

please have a look at the other packages to follow the same style (look for THIS_PACKAGE_INCLUDE_DEPENDS)

Copy link
Contributor

Choose a reason for hiding this comment

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

we usually put this in the src folder

Comment on lines +4 to +8
<name>chained_filter_controller</name>
<version>0.0.0</version>
<description>TODO: Package description</description>
<maintainer email="[email protected]">ankur-u24</maintainer>
<license>TODO: License declaration</license>
Copy link
Contributor

Choose a reason for hiding this comment

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

please copy maintainer, license from the other packages of this repo, and add you and Bence as authors
<author email="[email protected]">Bence Magyar</author>

you can copy the description of the plugin xml below.

Copy link
Contributor

Choose a reason for hiding this comment

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

please insert a copyright notice

@@ -0,0 +1,107 @@
// chained_filter.cpp (migrated from ROSCon 2024 workshop)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// chained_filter.cpp (migrated from ROSCon 2024 workshop)

please insert a copyright notice instead

@@ -0,0 +1,93 @@
#include <gtest/gtest.h>
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
#include <gtest/gtest.h>
#include <gmock/gmock.h>

We are using gmock consistently, see #1625

Comment on lines +59 to +78
TEST_F(ChainedFilterControllerTest, DeactivateDoesNotCrash)
{
EXPECT_NO_THROW({
controller_->on_deactivate(rclcpp_lifecycle::State());
});
}

TEST_F(ChainedFilterControllerTest, CleanupDoesNotCrash)
{
EXPECT_NO_THROW({
controller_->on_cleanup(rclcpp_lifecycle::State());
});
}

TEST_F(ChainedFilterControllerTest, ShutdownDoesNotCrash)
{
EXPECT_NO_THROW({
controller_->on_shutdown(rclcpp_lifecycle::State());
});
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think this is necessary to test. The controller manager assures that only the correct state transitions are called.

Comment on lines +30 to +36
ASSERT_EQ(
controller_->init(
"chained_filter", // controller name
"test_ns", // namespace
0, // intra-process (0 = disabled)
"test_node", // RCL node name
rclcpp::NodeOptions()), // node options
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

Please add a test if a filter is loaded and used to process data.

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