message_filters.delta_filter module

class message_filters.delta_filter.CachedComparisonHandler

Bases: ComparisonHandler

Implements cached messages comparison field by field.

Class:

CachedComparisonHandler implements messages comparison field by field.

A successor to this class should implement do_fields_fit method. If any of the fields provided to the do_fields_fit method do satisfy a comparison conditions the message is accepted. That means that the message is stored in the _message_cache and the message_fits method returns True.

do_fields_fit(field_a: Any, field_b: Any) bool
message_fits(message: rclpy.type_support.MsgT) bool
class message_filters.delta_filter.ComparisonFilter(comparison_handler: CachedComparisonHandler, message_filter: SimpleFilter | None = None)

Bases: SimpleFilter

ROS 2 Comparison filter.

Given a stream of messages, the message is passed down to the next filter if comparison_handler message_fits method returns True for that message.

Construct ComparisonFilter.

Parameters:
  • comparison_handler – An instance of the CachedComparisonHandler class. Is expected implement a message_fits method. If message_fits returns True for a provided message, that message is considered valid and is passed to a next filter if any.

  • message_filter – An instance of the SimpleFilter. The input filter to connect to

add(message: rclpy.type_support.MsgT)
connectInput(message_filter)
message_fits(message: rclpy.type_support.MsgT)
class message_filters.delta_filter.ComparisonHandler

Bases: ABC

do_fields_fit(field_a: Any, field_b: Any) bool
message_fits(message: rclpy.type_support.MsgT) bool
class message_filters.delta_filter.DeltaCompare(field_getters: Callable[[rclpy.type_support.MsgT], Any])

Bases: CachedComparisonHandler

Implements delta comparison.

If any of the fields, acquired by any of the field_getters do differ between previously cached and current message, the current message is accepted.

Construct DeltaCompare.

Parameters:

field_getters – A list of callable objects that are expected to retrieve a value of a basic type from a message field for comparison. Any of the field_getters is applied to the cached and to the current message. The returned values are compared. If any of these values differ between cached and current message, the current message is accepted.

do_fields_fit(val_a, val_b) bool
class message_filters.delta_filter.DeltaFilter(field_getters: list[Callable[[rclpy.type_support.MsgT], Any]], message_filter: SimpleFilter | None = None)

Bases: ComparisonFilter

ROS 2 Delta filter.

Given a stream of messages, the message is passed down to the next filter if any of the message fields, that may be acquired by field_getters have changed compared to the previously accepted message.

Construct a DeltaFilter.

Parameters:
  • field_getters – A list of callable objects each of which returns a field value. When message is processed, every field getter is applied to it and to the previously accepted message. If any of the fields have changed between currently processed message and previous value, the message is accepted, stored to the message_cache and passed to a next message filter if any.

  • message_filter – A message filter to connect this filter to as a follow up.

class message_filters.delta_filter.PathDeltaFilter(field_path_list: list[str], message_filter: SimpleFilter | None = None)

Bases: DeltaFilter

ROS 2 Path Delta Filter.

Given a stream of messages, the message is passed down to the next filter if any of the message fields, that may be found at any field_path of the field_path_list have changed compared to the previously accepted message.

Construct a DeltaFilter.

Parameters:
  • field_path_list – A list of field paths to access fields by. A field path is expected to be a dot-separated string. Eg: a.b.c.d where d is a field of c, c is a field of b e.t.c.

  • message_filter – A message filter to connect this filter to as a follow up.

get_field_by_path(message: rclpy.type_support.MsgT, field_path: str)