FKIE Message Filters
Improved filters for processing ROS messages
Public Types | Public Member Functions | Static Public Attributes | Protected Member Functions | List of all members
fkie_message_filters::Sequencer< Inputs > Class Template Reference

Enforce correct temporal order. More...

#include <fkie_message_filters/sequencer.h>

Inheritance diagram for fkie_message_filters::Sequencer< Inputs >:
Inheritance graph
[legend]
Collaboration diagram for fkie_message_filters::Sequencer< Inputs >:
Collaboration graph
[legend]

Public Types

using Input = IO< Inputs... >
 Grouped input types. More...
 
using Output = IO< Outputs... >
 Grouped output types. More...
 

Public Member Functions

 Sequencer (const ros::Duration &max_delay=ros::Duration(1, 0)) noexcept
 Constructor. More...
 
Connection connect_to_sink (Sink< Outputs... > &dst) noexcept
 Connect this source to a sink. More...
 
Connection connect_to_source (Source< Inputs... > &src) noexcept
 Connect this sink to a source. More...
 
void disconnect_from_all_sinks () noexcept
 Disconnect from all connected sinks. More...
 
void disconnect_from_all_sources () noexcept
 Disconnect from all connected sources. More...
 
void flush ()
 Flush the message queue. More...
 
void reset () noexcept override
 Reset filter state. More...
 
void set_max_delay (const ros::Duration &max_delay) noexcept
 Modify maximum delay. More...
 

Static Public Attributes

static constexpr std::size_t NUM_INPUTS = sizeof...(Inputs)
 Number of input arguments.
 
static constexpr std::size_t NUM_OUTPUTS
 Number of output arguments.
 

Protected Member Functions

void receive (const Inputs &... in) override
 Process incoming data. More...
 
void send (const Outputs &... out)
 Pass data to all connected sinks. More...
 

Detailed Description

template<class... Inputs>
class fkie_message_filters::Sequencer< Inputs >

Enforce correct temporal order.

This filter sorts incoming messages according to their header timestamp, and forwards them in order. It needs the expected maximum delay by which messages might arrive out of order, and forwarded messages will be out of date by at least this delay. However, all forwarded messages will be guaranteed to be in temporal order, and no message will be dropped unless it arrives with a larger delay, compared to the most recently received message.

If the filter input is not unary, only the first argument is examined, which must have an accessible ROS header as determined by the ros::message_traits template.

Member Typedef Documentation

◆ Input

template<typename... Inputs>
using fkie_message_filters::Sink< Inputs >::Input = IO<Inputs...>
inherited

Grouped input types.

This type can be used to define sources with matching types.

◆ Output

using fkie_message_filters::Source< Outputs >::Output = IO<Outputs...>
inherited

Grouped output types.

This type can be used to define sinks with matching types.

Constructor & Destructor Documentation

◆ Sequencer()

template<class... Inputs>
fkie_message_filters::Sequencer< Inputs >::Sequencer ( const ros::Duration &  max_delay = ros::Duration(1, 0))
explicitnoexcept

Constructor.

  • max_delay the maximum delay of any message
Exceptions
Does not throw any exceptions.

Member Function Documentation

◆ connect_to_sink()

Connection fkie_message_filters::Source< Outputs >::connect_to_sink ( Sink< Outputs... > &  dst)
noexceptinherited

Connect this source to a sink.

Can be called multiple times to connect multiple sinks; in that case, the sinks receive data in the same order as they have been connected. This function does basically the same thing as Sink::connect_to_source(), only from the opposite point of view.

  • dst the sink that is to be connected
Returns
a connection object that can be used to monitor or sever the created connection
Exceptions
Does not throw any exceptions.

◆ connect_to_source()

template<typename... Inputs>
Connection fkie_message_filters::Sink< Inputs >::connect_to_source ( Source< Inputs... > &  src)
noexceptinherited

Connect this sink to a source.

Can be called multiple times to connect multiple sources; in that case, the sink receives data from all connected sources. This function does basically the same thing as Source::connect_to_sink(), only from the opposite point of view.

  • src the source that is to be connected
Returns
a connection object that can be used to monitor or sever the created connection
Exceptions
Does not throw any exceptions.

◆ disconnect_from_all_sinks()

void fkie_message_filters::Source< Outputs >::disconnect_from_all_sinks ( )
noexceptinherited

Disconnect from all connected sinks.

Severs the connection to all sinks, turning the send() method into a no-op.

Exceptions
Does not throw any exceptions.

◆ disconnect_from_all_sources()

template<typename... Inputs>
void fkie_message_filters::Sink< Inputs >::disconnect_from_all_sources ( )
noexceptinherited

Disconnect from all connected sources.

Severs the connection to all sources. The receive() method will not be called any more.

Exceptions
Does not throw any exceptions.

◆ flush()

template<class... Inputs>
void fkie_message_filters::Sequencer< Inputs >::flush ( )

Flush the message queue.

This will forward all messages in the queue, regardless of their age. Afterwards, new messages which are older than the most recently forwarded one will be dropped, even if their delay is smaller than the configured threshold. In other words, a call to this method will never violate the temporal order constraint.

Exceptions
Does not throw any exceptions, but will propagate uncaught exceptions from filter callbacks.

◆ receive()

template<class... Inputs>
void fkie_message_filters::Sequencer< Inputs >::receive ( const Inputs &...  in)
overrideprotectedvirtual

Process incoming data.

Derived classes need to override this method to handle all data that is to be consumed by the sink.

Exceptions
Depends on the implementation.

Implements fkie_message_filters::Sink< Inputs >.

◆ reset()

template<class... Inputs>
void fkie_message_filters::Sequencer< Inputs >::reset ( )
overridevirtualnoexcept

Reset filter state.

For stateful filters, this method resets the internal state as if the filter had just been created. Existing connections to sources and sinks are unaffected.

The default implementation does nothing.

Exceptions
Does not throw any exceptions.

Reimplemented from fkie_message_filters::FilterBase.

◆ send()

void fkie_message_filters::Source< Outputs >::send ( const Outputs &...  out)
protectedinherited

Pass data to all connected sinks.

  • out data
Exceptions
Does not throw any exceptions, but will propagate uncaught exceptions from filter callbacks.

◆ set_max_delay()

template<class... Inputs>
void fkie_message_filters::Sequencer< Inputs >::set_max_delay ( const ros::Duration &  max_delay)
noexcept

Modify maximum delay.

New messages older than the most recently forwarded one will continue to be dropped, even if their delay is smaller than max_delay. In other words, a call to this method will never violate the temporal order constraint.

  • max_delay the maximum delay of any message
Exceptions
Does not throw any exceptions.

The documentation for this class was generated from the following file: