Content Filtering in ROS 2
ROSCon 2022

Speaker:● Eduardo Ponz Segrelles, Project Manager @ eProsima

eduardoponz@eprosima.com

October 21st, 2022

Agenda01

Motivation

03

Usage in ROS 2● What is the problem we aretrying to solve● How is now tackled● Available APIs and how touse them
● Writer side filtering in ROS
2 with Fast DDS

02Content Filtering

04

Bandwidth savings● Reader & Writer side
● Fast DDS optimizations● Implementation in ROS 2
when middleware does notoffer support● Benchmark results● Comparison with current“solutions”2MotivationSubscribe to a subset of the topic data

Filter by data source

Load balancing

With tagged data, a subscriber may
only want data from specificsourcesIf computation is expensive on thereceiver side, several subscribers
may be set to process data in turns

TopicAlarms
A monitoring application may firean alarm y a certain field within a
topic samples goes above/below athreshold3

Motivation
Current solutions

Application level filtering

Splitting the topic

1

Bandwidth utilization

1

Resource utilization

2

Subscriber-side computation2

Logic management

3

Memory and latency overhead3Possible duplicities

4CPU usage

4

Subscriber side businesslogic in the publisher

5

Maintainability

5

Maintainability

4Motivation
Real ROS 2 problem* Borrowed from ROS 2 CFT design by Mr. Tomoya Fujita

5Content FilteredTopics
A Topic extension to let ROS 2filter messages based on an
SQL-like expression

Main features
Content Filtered Topic main features

Configured at subscriber side
SQL-like syntax for expression withparameters
Expresion: ‘node = %0’
Parameters: [‘my_node’]

Each subscriber may set a different filter

Possibility of filter on the publication side

Dynamically configurable

DDS native support

7

ROS 2 filtering with Fast DDS
How does CFT work

Publisher applicationrclcpprclpy

rcljavarcl
rmw
rmw_fastrtps
DataWriter History
FAST DDS

8

ROS 2 filtering with Fast DDS
How does CFT work

Publisher applicationrclcpprclpy

rcljavarcl
rmw
rmw_fastrtps
DataWriter History
FAST DDS

9ROS 2 filtering with Fast DDS
How does CFT work

Publisher applicationrclcpprclpy

rcljavarcl
rmw
rmw_fastrtps

Filtering before
serialization

DataWriter History
FAST DDS

10ROS 2 filtering with Fast DDS
How does CFT work

Publisher applicationrclcpprclpy

rcljavarcl
rmw
rmw_fastrtps
DataWriter History
FAST DDS
Transport layer

11

ROS 2 filtering with Fast DDS
How does CFT work

Publisher applicationrclcpprclpy

Subscriber application

rcljavarcl
rmw
rmw_fastrtps

rclcpp

Filtering before
deserialization

rclpy

rcljavarcl
rmw
rmw_fastrtps

DataWriter History

DataWriter History

FAST DDS

FAST DDS
Transport layer

12

ROS 2 filtering with Fast DDS
How does CFT work

Publisher applicationrclcpprclpy

Subscriber application

rcljava

rclcpprclpy

rcljava

rcl

rcl

rmw

rmw

rmw_fastrtps

rmw_fastrtps

DataWriter History

DataWriter History

FAST DDS

FAST DDS
Transport layer

13

ROS 2 filtering without middleware support
How does CFT work

Publisher applicationrclcpprclpy

rcljavarcl
rmw
rmw_connector
Middleware implementation

14

ROS 2 filtering without middleware support
How does CFT work

Publisher applicationrclcpprclpy

rcljavarcl
rmw
rmw_connector
Middleware implementation

Transport layer

15

ROS 2 filtering without middleware supportHow does CFT work

Publisher applicationrclcpprclpy

Publisher application

rcljava

rclcpprclpy

rcljava

rcl

rcl

rmw

rmw

rmw_connector

rmw_connector

Middleware implementation

Filtering after
deserialization

Transport layer

Middleware implementation

16

ROS 2 filtering without middleware support
How does CFT work

Publisher applicationrclcpprclpy

Publisher application

rcljava

rclcpprclpy

rcljava

rcl

rcl

rmw

rmw

rmw_connector

rmw_connector

Middleware implementation

Middleware implementation

Transport layer

17

Usage in ROS 2Howtoconfigure

filtering in ROS 2contentROS 2 APIs for Content filtering
Code snippet within the context of a constructor of a class inheriting from Noderclcpp::QoS qos(10);rmw_time_t lease_duration({0, 0});qos.liveliness(RMW_QOS_POLICY_LIVELINESS_AUTOMATIC);
qos.liveliness_lease_duration(lease_duration);
rclcpp::SubscriptionOptions sub_options;

sub_options.content_filter_options.filter_expression = "data = %0";

sub_options.content_filter_options.expression_parameters = {"'Hello!'"};
subscription_ = this->create_subscription<std_msgs::msg::String>("topic",qos,std::bind(&MinimalContentFilteringSubscriber::topic_callback, this, _1),
sub_options);

if (!subscription_->is_cft_enabled()) {RCLCPP_WARN(this->get_logger(), "Content filter is not enabled since it's not supported");} else {}RCLCPP_INFO(this->get_logger(), "Subscribed to topic with content filtering");19

Bandwidthsavings
Only sending what you needBenchmark of different filtering strategies
Writer-side filtering savings using Fast DDS●1 Reliable pub●

10 Reliable subs eachfiltering 9 out of every
10 samples.

●~60 KiB data samples●Pub rate: 1 Hz

●Duration: 60 s21

www.eProsima.com

Linkedin.com/company/eProsima

Twitter.com/EProsima