Template Class InputAligner
Defined in File input_aligner.hpp
Nested Relationships
Nested Types
Inheritance Relationships
Base Type
public message_filters::noncopyable(Class noncopyable)
Class Documentation
-
template<typename ...Ms>
class InputAligner : public message_filters::noncopyable Aligns multiple inputs in time and passing them through in order. For N inputs this filter provides N outputs. Often sensors or pre-processing chains might introduce delays to messages until they arrive at a target node. The input aligner ensures that the messages are forwarded in order.
If the input messages are periodic a hint about their frequency can be set via
setInputPeriodfor each input. This allows the filter to look ahead for the given time and reduces delays. The period should be selected optimistically at the lower bound.If for an input no messages arrive the input will timeout and will be ignored until new messages arrive.
Forwarding messages can be either triggered by calling
dispatchMessagesperiodically or by setting up a timer withsetupDispatchTimer.This implementation was inspired by ROCK’s stream aligner. https://www.rock-robotics.org/documentation/data_processing/stream_aligner.html
Public Types
-
typedef std::tuple<MessageEvent<Ms const>...> Events
Public Functions
-
template<class F0, class F1, class ...Fs>
inline InputAligner(const rclcpp::Duration &timeout, F0 &f0, F1 &f1, Fs&... fs)
-
inline virtual ~InputAligner()
-
template<class ...Fs>
inline void connectInput(Fs&... fs) Connects |Fs| inputs. Disconnects existing inputs.
-
template<std::size_t I, typename P>
inline Connection registerCallback(const std::function<void(P)> &callback) Register a callback for the I-th input.
- Parameters:
callback – The callback to call
-
template<std::size_t I, typename P>
inline Connection registerCallback(void (*callback)(P)) Register a callback for the I-th input.
- Parameters:
callback – The callback to call
-
template<std::size_t I, typename T, typename P>
inline Connection registerCallback(void (T::* callback)(P), T *t) Register a callback for the I-th input.
- Parameters:
callback – The callback to call
-
inline void setName(const std::string &name)
Set the name of this filter. For debugging use.
-
inline const std::string &getName()
Get the name of this filter. For debugging use.
Adds a message to the I-th input queue. With this function this filter can also be used without the use of other filter classes.
-
template<std::size_t I>
inline void setInputPeriod(const rclcpp::Duration &period) Sets the input period for the I-th input. This allows the filter to look ahead for the given time and reduces delays. The period should be selected optimistically at the lower bound. The default value is 0, which means there is no look ahead for this input.
-
template<std::size_t I>
inline QueueStatus getQueueStatus() const
Sets up a timer calling the
dispatchMessagesfunction.- Parameters:
node – The ROS node.
update_rate – The rate in which
dispatchMessagesis triggered.
-
inline void dispatchMessages()
Forwards all messages that can be aligned. This function should be called periodically.
Protected Types
-
typedef std::tuple<EventQueue<Ms>...> EventQueues
Protected Functions
-
template<class FTuple, std::size_t... Is>
inline void connectInputImpl(FTuple &ftuple, std::index_sequence<Is...>)
-
inline void disconnectAll()
-
template<std::size_t I>
inline bool dispatchFirstMessage(std::size_t idx)
Protected Attributes
-
EventQueues event_queues_
-
Connection input_connections_[N_INPUTS]
-
std::string name_
-
std::mutex mutex_
-
template<typename MsgType>
class EventQueue : public std::multiset<MessageEvent<MsgType const>, EventSort<MsgType>>
-
template<typename MsgType>
struct EventSort Public Functions
-
inline bool operator()(const MessageEvent<MsgType const> &lhs, const MessageEvent<MsgType const> &rhs) const
-
inline bool operator()(const MessageEvent<MsgType const> &lhs, const MessageEvent<MsgType const> &rhs) const
-
struct QueueStatus
Status information of a input queue.
-
typedef std::tuple<MessageEvent<Ms const>...> Events