15 #include <type_traits> 16 #include <unordered_map> 17 #include <unordered_set> 19 #include <boost/thread/recursive_mutex.hpp> 23 #include <dynamic_reconfigure/server.h> 32 #include <cras_cpp_common/FilterChainConfig.h> 184 virtual void connectCb(const ::ros::SingleSubscriberPublisher&);
189 virtual void disconnectCb(const ::ros::SingleSubscriberPublisher&);
197 template <typename T, ::std::enable_if_t<::ros::message_traits::HasHeader<T>::value,
bool> =
true>
206 template <typename T, ::std::enable_if_t<!::ros::message_traits::HasHeader<T>::value,
bool> =
true>
225 const ::std::string& type);
236 const ::std::string& type,
bool success);
305 ::std::unique_ptr<::dynamic_reconfigure::Server<::cras_cpp_common::FilterChainConfig>>
dynreconfServer;
314 ::std::unique_ptr<::cras::FilterChainDiagnostics<F>>
chainDiag;
321 template <
typename F>
336 void addReport(const ::std::string& filterName,
bool success);
342 const ::cras::FilterChain<F>&
chain;
359 #include "impl/filter_chain_nodelet.hpp" ::cras::FilterChain< F > filterChain
The chain of filters to apply to the incoming messages.
::std::unordered_map<::std::string, size_t > numSuccesses
The number of successful filter runs since last update.
::std::unique_ptr<::cras::DiagnosedPublisher< F > > publisherDiag
Publisher diagnostics.
void disableFilterPublishers()
Disable publishers of single filter results.
::ros::Publisher filteredPublisher
Publisher for the filtered data.
void run(class_loader::ClassLoader *loader)
bool publishFilters
Whether to create a publisher for each filter. Can be changed during runtime via enableFilterPublishe...
::std::unique_ptr<::cras::impl::NodeletWithDiagnosticsPrivate > data
PIMPL.
virtual void filterStartCallback(const F &data, size_t filterNum, const ::std::string &name, const ::std::string &type)
Callback called before each filter starts working on a message.
void updateDynamicParams() const
Update dynamic parameters on the server to correspond to current settings of this nodelet...
size_t subscriberQueueSize
Queue size for subscriber.
::std::unique_ptr<::dynamic_reconfigure::Server<::cras_cpp_common::FilterChainConfig > > dynreconfServer
Dynamic reconfigure server.
::std::mutex mutex
Mutex protecting numCallbacks, numSuccesses and numFailures.
::std::unique_ptr<::cras::DiagnosedSubscriber< F > > subscriberDiag
Subscriber diagnostics.
::ros::NodeHandle nodeHandle
Public NodeHandle.
::ros::message_traits::DataType< F > MsgDataType
Accessor to DataType field of the filtered message type.
::std::unordered_map<::std::string, ::std::unique_ptr<::cras::DurationStatus > > filterCallbackDurationDiags
Diagnostic tasks for duration of each filter callback.
bool lazySubscription
Whether to use the lazy subscription model (subscribe to input only when someone subscribes to output...
virtual void dataCallback(const typename F::ConstPtr &data)
Callback called when a new message arrives on the input topic.
ROS message publisher and subscriber with automatic rate and delay diagnostics.
::std::mutex filterPublishersMutex
Mutex that protects filterPublishers.
::std::string topicFiltered
Topic for outgoing (filtered) messages.
::std::unique_ptr<::cras::FilterChainDiagnostics< F > > chainDiag
Diagnostic task for overall chain performance.
::ros::NodeHandle privateNodeHandle
Private NodeHandle.
void subscribe()
Subscribe to the input topic.
::ros::Subscriber subscriber
Subscriber to data.
Utilities for working with diagnostics-related tools.
::std::string configNamespace
ROS parameter namespace from which filter configuration will be read.
::ros::Duration maxAge
Maximum age of a message for it to be considered. Older messages are thrown away when received...
virtual void filterFinishedCallback(const F &data, size_t filterNum, const ::std::string &name, const ::std::string &type, bool success)
Callback called after each filter finishes working on a message.
::std::unordered_map<::std::string, ::ros::Publisher > filterPublishers
Publishers for individual filter results.
::std::unordered_map<::std::string, size_t > numCallbacks
The overall number of callbacks since last update.
void setMaxAge(const ::ros::Duration &maxAge)
Set the maximum age of messages that are accepted and filtered.
size_t publisherQueueSize
Queue size for publishers.
~FilterChainNodelet() override
virtual void connectCb(const ::ros::SingleSubscriberPublisher &)
Callback called when a new subscriber of the output topic appears.
::std::string topicIn
Topic for incoming messages.
::ros::Time getStamp(const typename T::ConstPtr &data)
Get timestamp from a message with header.
mutable ::boost::recursive_mutex configMutex
Mutex protecting the dynamic reconfigure options, maxAge and publishFilters.
Diagnostic task for duration of some task.
bool publishDurationDiagnostics
Whether callback duration statistics should be published to diagnostics.
This file contains a set of classes that make work with nodelets easier.
void setDisabledFilters(::std::unordered_set<::std::string > filters)
Set which filters are temporarily disabled.
bool publishChainDiagnostics
Whether overall chain diagnostics should be published to diagnostics.
::std::unordered_map<::std::string, size_t > numFailures
The number of failed filter runs since last update.
bool publishTopicDiagnostics
Whether topic frequency/delay statistics should be published to diagnostics.
Diagnostics of performance of a filter chain.
void enableFilterPublishers()
Enable publishers of single filter results.
Helpers for working with filter chains based on filters::FilterChain.
const ::cras::FilterChain< F > & chain
The diagnosed chain.
A versatile nodelet that can load and run a filter chain.
F DataType
Type of the filtered data.
::std::unique_ptr<::cras::DurationStatus > callbackDurationDiag
Diagnostic task for overall callback duration.
virtual void disconnectCb(const ::ros::SingleSubscriberPublisher &)
Callback called when a subscriber of the output topic disappears.
void dynreconfCallback(::cras_cpp_common::FilterChainConfig &config, uint32_t)
Dynamic reconfiguration of parameters.
FilterChainNodelet(const ::std::string &dataType, const ::std::string &topicIn, const ::std::string &topicFiltered, const ::std::string &configNamespace)
Read ROS parameters, initialize publishers/subscribers, initialize other class members. ROS::init() is assumed to have been called before.
::std::mutex connectMutex
Mutex that protects subscriber, subscriberDiag.