Skip to content

Add filtering capability to ft_broadcaster #1814

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

Open
wants to merge 37 commits into
base: master
Choose a base branch
from

Conversation

OscarMrZ
Copy link

Good morning!

This is a continuation of #559 as it was inactive.

The changes are minimal:

  1. Applied @saikishor suggestions
  • Added sensor_filter_chain to the parameters, which serves as documentation.
  • I removed all the logic about the additional frames. I agree with @saikishor that transforming to different frames should be handled by the user in their application. With this, no tf calls inside the RT are needed.
  • No more publishing NaN if the update of the filter failed.
  1. Added some relevant tests
    IMHO, the previous tests were testing the business logic of the filters themselves, that is, checking that the actual computations were correct, rather than the actual new logic for adding filters. I added three tests for configuring, activating/deactivating, and updating with a configured filter chain. Just one consideration: I changed a little bit the logic of SetUpFTSBroadcaster a little bit to accept a node name. This is because I added some parameters in the YAML that are needed for the broadcaster with filters. I cannot do set_parameter because the filter chain expects the parameters to be overrides.

Thanks a lot for your time!

Óscar

destogl and others added 30 commits April 13, 2023 14:32
@OscarMrZ
Copy link
Author

Also, an additional consideration about the logic:

Because of ros/filters#89, there's not really a way to tell if a chain is actually configured. So now, even if the user doesn't provide a chain config, it will be configured with an empty filter list. At the end, this just means that the filtered message will always be published, with output = input. If ros/filters#90 gets merged, the broadcaster will know no filter chain was configured and omit publishing the unnecessary message.

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.

Thanks for picking this up.

This is a continuation of #559 as it was inactive.

It was not inactive, but it was missing more reviews ;)

2. Added some relevant tests
   IMHO, the previous tests were testing the business logic of the filters themselves, that is, checking that the actual computations were correct, rather than the actual new logic for adding filters. I added three tests for configuring, activating/deactivating, and updating with a configured filter chain. Just one consideration: I changed a little bit the logic of SetUpFTSBroadcaster a little bit to accept a node name. This is because I added some parameters in the YAML that are needed for the broadcaster with filters. I cannot do `set_parameter` because the filter chain expects the parameters to be overrides.

But now there is no test if any filtering is performed, or not? E.g., not calling the filter-update will not be covered by the tests?

Edit:
Please install pre-commit and fix the failing tests..

Copy link

codecov bot commented Jul 11, 2025

Codecov Report

Attention: Patch coverage is 93.26923% with 7 lines in your changes missing coverage. Please review.

Project coverage is 85.67%. Comparing base (76c07f9) to head (94106c2).

Files with missing lines Patch % Lines
...roadcaster/src/force_torque_sensor_broadcaster.cpp 87.17% 3 Missing and 2 partials ⚠️
...ce_torque_sensor_broadcaster/test/dummy_filter.cpp 80.00% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1814      +/-   ##
==========================================
+ Coverage   85.66%   85.67%   +0.01%     
==========================================
  Files         123      124       +1     
  Lines       12408    12467      +59     
  Branches     1056     1059       +3     
==========================================
+ Hits        10629    10681      +52     
- Misses       1430     1434       +4     
- Partials      349      352       +3     
Flag Coverage Δ
unittests 85.67% <93.26%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...ster/test/test_force_torque_sensor_broadcaster.cpp 98.46% <100.00%> (+0.30%) ⬆️
...ce_torque_sensor_broadcaster/test/dummy_filter.cpp 80.00% <80.00%> (ø)
...roadcaster/src/force_torque_sensor_broadcaster.cpp 89.78% <87.17%> (-2.72%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@OscarMrZ OscarMrZ force-pushed the ft_broadcaster/add-filtering-capability branch from 91c7785 to ad4dcfa Compare July 14, 2025 15:40
@OscarMrZ
Copy link
Author

Hello @christophfroehlich

Thanks for your comment!

True, my bad! I hope it's ok opening this new MR.

I had actually run it with pre-commit, but somehow pushed with some rules failing. It should be fixed now. Sorry for that!

But now there is no test if any filtering is performed, or not? E.g., not calling the filter-update will not be covered by the tests?

Yeah, you are right. I didn't know how to properly add it without including unnecessary logic checks for the underlying filters. Would you prefer re-adding a test with one of the simple filters or creating a dummy filter for testing?

P.D.: Sorry for the force push!

@christophfroehlich
Copy link
Contributor

creating a dummy filter would be ok, but using an existing one is also fine as we have control_toolbox as dependency in this repo (but not in this package, right? this would speak for the dummy or one from ros/filters directly)

@saikishor
Copy link
Member

creating a dummy filter would be ok, but using an existing one is also fine as we have control_toolbox as dependency in this repo (but not in this package, right? this would speak for the dummy or one from ros/filters directly)

Sounds good to me.

@OscarMrZ
Copy link
Author

OscarMrZ commented Jul 16, 2025

Good morning!

Yeah, there's no dependency for control_toolbox in the ft_broadcaster, but I think it's perfectly fine to use a filter from filters as we are introducing the dependency for the chain.

I added dummy_filter.cpp, which performs the template specialization for the WrenchStamped type of the increment filter update method. It will just add 1.0 to every field of the message.

I updated the tests accordingly and included an additional one to ensure the correct message is received. Everything seems to be working fine!

Thanks a lot!

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.


// As the sensor_filter_chain parameter is of type 'none', we cannot directly check if it is
// present. Even if the sensor_filter_chain parameter is not specified, the filter chain will be
// correctly configured with an empty list of filters (https://github.com/ros/filters/issues/89).
Copy link
Contributor

Choose a reason for hiding this comment

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

how to proceed here?

@@ -69,7 +71,33 @@ if(BUILD_TESTING)
target_include_directories(test_force_torque_sensor_broadcaster PRIVATE include)
target_link_libraries(test_force_torque_sensor_broadcaster
force_torque_sensor_broadcaster
force_torque_sensor_broadcaster_parameters
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
force_torque_sensor_broadcaster_parameters

do we have to link against the parameters here?

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.

9 participants