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

add a demo of content filter listener #557

Merged
merged 10 commits into from
May 2, 2022

Conversation

iuhilnehc-ynos
Copy link
Contributor

Signed-off-by: Chen Lihui lihui.chen@sony.com

Signed-off-by: Chen Lihui <lihui.chen@sony.com>
@iuhilnehc-ynos
Copy link
Contributor Author

@asorbini @MiguelCompany

As we know, the content filter has operations as below,
`RelOp ::= ‘=’ | ‘>’ | ‘>=’ | ‘<’ | ‘<=’ | ‘<>’ | like``

I expected that the keyword like can work as https://www.w3schools.com/sql/sql_ref_like.asp.
Unfortunately, it seems it doesn't work.

Is there a limitation in the DDS?

Signed-off-by: Chen Lihui <lihui.chen@sony.com>
@MiguelCompany
Copy link
Contributor

@iuhilnehc-ynos On Fast DDS it should work as expected. See the test cases here

RTI Connext, according to this comment, does not support like

@iuhilnehc-ynos
Copy link
Contributor Author

@MiguelCompany

RTI Connext, according to this comment, does not support like

Thanks for your information. Sorry, I didn't notice it before.

On Fast DDS it should work as expected.

After confirming, it works fine with rmw_fastrtps_cpp.

Chen Lihui added 2 commits April 7, 2022 22:24
and comment that rmw_connextdds not supported currently

Signed-off-by: Chen Lihui <lihui.chen@sony.com>
Signed-off-by: Chen Lihui <lihui.chen@sony.com>
Copy link
Member

@ivanpauno ivanpauno left a comment

Choose a reason for hiding this comment

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

LGTM!

Could you add a test here?

@ivanpauno
Copy link
Member

@wjwwood @clalancette any objection to merge this now?
We're past the API break, but nothing depends on the demos and it seems worthwile to have a demo of a new feature.

@fujitatomoya
Copy link
Collaborator

Once this demo is merged, i will link this demo to Humble Release Note. (see ros2/ros2_documentation#2396)

@wjwwood
Copy link
Member

wjwwood commented Apr 12, 2022

I don't mind it getting merged this late, following your logic, but @clalancette should give his thoughts. I didn't review the demo code yet.

@fujitatomoya
Copy link
Collaborator

CI:

  • Linux Build Status
  • Linux-aarch64 Build Status
  • Windows Build Status

@ivanpauno
Copy link
Member

@iuhilnehc-ynos On Fast DDS it should work as expected. See the test cases here

RTI Connext, according to ros2/design#282 (comment), does not support like

Could we modify the example to work with both?

Signed-off-by: Chen Lihui <lihui.chen@sony.com>
@iuhilnehc-ynos
Copy link
Contributor Author

iuhilnehc-ynos commented Apr 13, 2022

@ivanpauno

Could you add a test here?

Sorry, I don't know how to add a test for this listener_content_filter, it seems the current test_executables_tutorial.py.in can't work as I expect.

I expect that running with colcon test --packages-select demo_nodes_cpp --ctest-args -R test_tutorial_talker_listener_content_filter__rmw_cyclonedds_cpp should fail with the patch, but it doesn't.

What I mean is if the test in the above patch can be passed by rmw_cyclonedds_cpp, it seems there is no reason to add it.

demo_nodes_cpp/src/topics/listener_content_filter.cpp Outdated Show resolved Hide resolved
// 'Hello World: 10'.
rclcpp::SubscriptionOptions sub_options;
sub_options.content_filter_options.filter_expression = "data = %0";
sub_options.content_filter_options.expression_parameters = {"'Hello World: 10'"};
Copy link
Member

Choose a reason for hiding this comment

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

Maybe the number (currently 10) could be configurable by the user.
Maybe that makes the demo more interesting (?).
Feel free to ignore the comment though.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I actually agree with this comment. probably string chatter example is interesting enough to show this feature. how about filtering specific range of data? that would be one of the most common case?

@ivanpauno
Copy link
Member

I expect that running with colcon test --packages-select demo_nodes_cpp --ctest-args -R test_tutorial_talker_listener_content_filter__rmw_cyclonedds_cpp should fail with the patch, but it doesn't.

Yes, that's not going to work because the test is waiting for the output in the file to be printed

, and that happens as well if no content filter is applied.
You'll need to adapt the test, or adapt the file so it doesn't match the output if "Content filter is not enabled since it's not supported" was logged before (I'm not sure if that's possible).


Please don't share a patch, they are hard to understand without being applied to the code to have more context.
It's better to push the commit and ask the question, as github gives more context (or if you don't want to push in this branch, you can do that in a new branch/fork and share the link to the github diff).

Signed-off-by: Chen Lihui <lihui.chen@sony.com>
@fujitatomoya
Copy link
Collaborator

@iuhilnehc-ynos all comments are addressed, right? can you confirm? so that we can ask final review to @ivanpauno @wjwwood

Copy link
Member

@wjwwood wjwwood left a comment

Choose a reason for hiding this comment

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

Just curious why not put this kind of thing in ros2/examples instead?

demo_nodes_cpp/src/topics/listener_content_filter.cpp Outdated Show resolved Hide resolved
Signed-off-by: Chen Lihui <lihui.chen@sony.com>
Copy link
Member

@ivanpauno ivanpauno left a comment

Choose a reason for hiding this comment

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

LGTM with @wjwwood approval

@fujitatomoya
Copy link
Collaborator

@wjwwood friendly ping.

} else {
RCLCPP_INFO(
this->get_logger(),
"subscribed to topic \"%s\" with filter expression \"data = 'Hello World: 10'\"",
Copy link
Member

Choose a reason for hiding this comment

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

This is really fragile, since if someone updated the expression and forgot to update this is would be wrong. Violates DRY.

Can we print out the filter expression and parameters from the content_filter_options directly instead?

Comment on lines 40 to 43
// Create a subscription to the topic which can be matched with one or more compatible ROS
// publishers.
// Note that not all publishers on the same topic with the same type will be compatible:
// they must have compatible Quality of Service policies.
Copy link
Member

Choose a reason for hiding this comment

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

Is this comment block needed?

@wjwwood
Copy link
Member

wjwwood commented Apr 19, 2022

w.r.t. putting it in examples. I think having something here in demos is fine so long as we have a corresponding page about it or the executable is used in some documentation or tutorial. For example, the intra-process demos have this page which shows how to run it, what you should expect to see when you run it, and how it demonstrates that the intra-process feature is working:

https://github.com/ros2/ros2_documentation/blob/rolling/source/Tutorials/Intra-Process-Communication.rst

If we had something similar then this executable makes sense to me. Otherwise, I'd still say examples makes more sense. And I don't think you need a talker equivalent if it is put in examples, the purpose there is to show how to use the API, and it's not part of a tutorial or demo document that tells you to run it and observe some effect.

I hope that distinction makes sense.

@fujitatomoya
Copy link
Collaborator

fujitatomoya commented Apr 19, 2022

@wjwwood @ivanpauno
CC: @iuhilnehc-ynos

i just created ros2/examples#341.

how about the following, sounds like a plan?

@wjwwood
Copy link
Member

wjwwood commented Apr 19, 2022

ros2/ros2_documentation#2396 can link this demonstration.
adding tutorial how to use, and that doc links to ros2/examples#341

I'd flip this around so that:

We could set up a new example that uses floats or something like you said, but that would be for the demo/tutorial combo and not the minimal example.

Signed-off-by: Chen Lihui <lihui.chen@sony.com>
@fujitatomoya
Copy link
Collaborator

@iuhilnehc-ynos

We could set up a new example that uses floats or something like you said, but that would be for the demo/tutorial combo and not the minimal example.

can we address this? current code looks good to us, just adjusting data type for using float to simulate the situation to filtering the sensing data. for doing that, we need to add publisher as well.

how about following?

  • emergency temperature demonstration
    • say publisher is publishing temperature data with std_msgs/msg/Float64. make a loop to publish data -100 to +150 F in order with certain offset.
    • subscription use content filtering (if it is supported), and only receives data with “data < %0 OR data > %1” with {"-30.0", "100.0"}, then print emergency temperature.

i believe demonstrating with expected common use case would be much easier to get the picture of this feature for user.

Signed-off-by: Chen Lihui <lihui.chen@sony.com>
@iuhilnehc-ynos
Copy link
Contributor Author

@ros-pull-request-builder retest this please

Copy link
Collaborator

@fujitatomoya fujitatomoya left a comment

Choose a reason for hiding this comment

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

implementation looks good to me.

Comment on lines 74 to 75
src/topics/temperature_publisher.cpp
src/topics/temperature_subscriber.cpp
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
src/topics/temperature_publisher.cpp
src/topics/temperature_subscriber.cpp
src/topics/content_filtering_publisher.cpp
src/topics/content_filtering_subscriber.cpp

sorry i was not clear on this, i think files, classes and components can be general names for content filtering, so that user can tell these are related to content filtering.

Copy link
Member

@ivanpauno ivanpauno left a comment

Choose a reason for hiding this comment

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

Example looks really nice!
Thanks for the work!

@wjwwood
Copy link
Member

wjwwood commented Apr 25, 2022

Do you guys have demo documentation to go with this? Something along the lines of this document: https://docs.ros.org/en/rolling/Tutorials/Intra-Process-Communication.html

@fujitatomoya
Copy link
Collaborator

@wjwwood i will be back with PR for that, let me have a couple of days.

@wjwwood
Copy link
Member

wjwwood commented Apr 25, 2022

Sure, no problem, I would just hold this until that is ready.

Signed-off-by: Chen Lihui <lihui.chen@sony.com>
@fujitatomoya
Copy link
Collaborator

@wjwwood @ivanpauno @iuhilnehc-ynos
CC: @clalancette

i just opened ros2/ros2_documentation#2441, could you guys take a look at to give me some feedback?

@fujitatomoya
Copy link
Collaborator

either @wjwwood or @clalancette

can you merge this with ros2/ros2_documentation#2441 at the same time?

@ivanpauno
Copy link
Member

ivanpauno commented Apr 29, 2022

can you merge this with ros2/ros2_documentation#2441 at the same time?

It seems that CI wasn't run after the last changes, running it:

  • Linux Build Status
  • Linux-aarch64 Build Status
  • Windows Build Status

@fujitatomoya
Copy link
Collaborator

@ivanpauno thanks! all green, can you merge this?

@fujitatomoya
Copy link
Collaborator

@clalancette can you merge this? i already did ros2/ros2_documentation#2441

@fujitatomoya
Copy link
Collaborator

this is only required to backport humble package.

@wjwwood wjwwood merged commit a1bc6dc into ros2:master May 2, 2022
@wjwwood
Copy link
Member

wjwwood commented May 2, 2022

@Mergifyio backport humble

mergify bot pushed a commit that referenced this pull request May 2, 2022
* add a demo of content filter listener

Signed-off-by: Chen Lihui <lihui.chen@sony.com>

* add warn message if content filter is not supported by DDS

Signed-off-by: Chen Lihui <lihui.chen@sony.com>

* keep `like` to make the demo simple

and comment that rmw_connextdds not supported currently

Signed-off-by: Chen Lihui <lihui.chen@sony.com>

* remove the macro as it will be removed in the rclcpp

Signed-off-by: Chen Lihui <lihui.chen@sony.com>

* use = instead of like

Signed-off-by: Chen Lihui <lihui.chen@sony.com>

* address reviews

Signed-off-by: Chen Lihui <lihui.chen@sony.com>

* not make this configurable from the cli

Signed-off-by: Chen Lihui <lihui.chen@sony.com>

* remove comment and update log output

Signed-off-by: Chen Lihui <lihui.chen@sony.com>

* use temperature instead of chatter

Signed-off-by: Chen Lihui <lihui.chen@sony.com>

* rename

Signed-off-by: Chen Lihui <lihui.chen@sony.com>
(cherry picked from commit a1bc6dc)
@mergify
Copy link

mergify bot commented May 2, 2022

backport humble

✅ Backports have been created

wjwwood pushed a commit that referenced this pull request May 2, 2022
* add a demo of content filter listener

Signed-off-by: Chen Lihui <lihui.chen@sony.com>

* add warn message if content filter is not supported by DDS

Signed-off-by: Chen Lihui <lihui.chen@sony.com>

* keep `like` to make the demo simple

and comment that rmw_connextdds not supported currently

Signed-off-by: Chen Lihui <lihui.chen@sony.com>

* remove the macro as it will be removed in the rclcpp

Signed-off-by: Chen Lihui <lihui.chen@sony.com>

* use = instead of like

Signed-off-by: Chen Lihui <lihui.chen@sony.com>

* address reviews

Signed-off-by: Chen Lihui <lihui.chen@sony.com>

* not make this configurable from the cli

Signed-off-by: Chen Lihui <lihui.chen@sony.com>

* remove comment and update log output

Signed-off-by: Chen Lihui <lihui.chen@sony.com>

* use temperature instead of chatter

Signed-off-by: Chen Lihui <lihui.chen@sony.com>

* rename

Signed-off-by: Chen Lihui <lihui.chen@sony.com>
(cherry picked from commit a1bc6dc)

Co-authored-by: Chen Lihui <lihui.chen@sony.com>
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.

None yet

5 participants