Go to the documentation of this file.
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"
mutable ::boost::recursive_mutex configMutex
Mutex protecting the dynamic reconfigure options, maxAge and publishFilters.
Helpers for working with filter chains based on filters::FilterChain.
virtual void connectCb(const ::ros::SingleSubscriberPublisher &)
Callback called when a new subscriber of the output topic appears.
void setMaxAge(const ::ros::Duration &maxAge)
Set the maximum age of messages that are accepted and filtered.
Utilities for working with diagnostics-related tools.
void enableFilterPublishers()
Enable publishers of single filter results.
::std::unique_ptr<::cras::FilterChainDiagnostics< F > > chainDiag
Diagnostic task for overall chain performance.
::ros::Time getStamp(const typename T::ConstPtr &data)
Get timestamp from a message with header.
virtual void dataCallback(const typename F::ConstPtr &data)
Callback called when a new message arrives on the input topic.
Diagnostic task for duration of some task.
::std::mutex filterPublishersMutex
Mutex that protects filterPublishers.
::std::unique_ptr<::dynamic_reconfigure::Server<::cras_cpp_common::FilterChainConfig > > dynreconfServer
Dynamic reconfigure server.
::std::unique_ptr<::cras::DiagnosedPublisher< F > > publisherDiag
Publisher diagnostics.
size_t publisherQueueSize
Queue size for publishers.
::std::unordered_map<::std::string, size_t > numSuccesses
The number of successful filter runs since last update.
::std::string configNamespace
ROS parameter namespace from which filter configuration will be read.
bool publishTopicDiagnostics
Whether topic frequency/delay statistics should be published to diagnostics.
::std::unordered_map<::std::string, ::ros::Publisher > filterPublishers
Publishers for individual filter results.
::ros::NodeHandle nodeHandle
Public NodeHandle.
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....
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.
void addReport(const ::std::string &filterName, bool success)
Call this function every time a filter finished callback is called.
::std::unordered_map<::std::string, size_t > numCallbacks
The overall number of callbacks since last update.
::std::mutex mutex
Mutex protecting numCallbacks, numSuccesses and numFailures.
A versatile nodelet that can load and run a filter chain.
ROS message publisher and subscriber with automatic rate and delay diagnostics.
bool publishDurationDiagnostics
Whether callback duration statistics should be published to diagnostics.
::std::unique_ptr<::cras::impl::NodeletWithDiagnosticsPrivate > data
PIMPL.
void disableFilterPublishers()
Disable publishers of single filter results.
bool lazySubscription
Whether to use the lazy subscription model (subscribe to input only when someone subscribes to output...
size_t subscriberQueueSize
Queue size for subscriber.
virtual void disconnectCb(const ::ros::SingleSubscriberPublisher &)
Callback called when a subscriber of the output topic disappears.
::cras::FilterChain< F > filterChain
The chain of filters to apply to the incoming messages.
::ros::Publisher filteredPublisher
Publisher for the filtered data.
::std::unique_ptr<::cras::DiagnosedSubscriber< F > > subscriberDiag
Subscriber diagnostics.
FilterChainDiagnostics(const ::std::string &name, const ::cras::FilterChain< F > &chain)
::ros::NodeHandle privateNodeHandle
Private NodeHandle.
void subscribe()
Subscribe to the input topic.
::std::unordered_map<::std::string, size_t > numFailures
The number of failed filter runs since last update.
This file contains a set of classes that make work with nodelets easier.
::std::mutex connectMutex
Mutex that protects subscriber, subscriberDiag.
bool publishFilters
Whether to create a publisher for each filter. Can be changed during runtime via enableFilterPublishe...
F DataType
Type of the filtered data.
~FilterChainNodelet() override
const ::cras::FilterChain< F > & chain
The diagnosed chain.
::std::string topicFiltered
Topic for outgoing (filtered) messages.
void run(::diagnostic_updater::DiagnosticStatusWrapper &stat) override
::std::unique_ptr<::cras::DurationStatus > callbackDurationDiag
Diagnostic task for overall callback duration.
::std::unordered_map<::std::string, ::std::unique_ptr<::cras::DurationStatus > > filterCallbackDurationDiags
Diagnostic tasks for duration of each filter callback.
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.
Diagnostics of performance of a filter chain.
::ros::Subscriber subscriber
Subscriber to data.
::ros::message_traits::DataType< F > MsgDataType
Accessor to DataType field of the filtered message type.
bool publishChainDiagnostics
Whether overall chain diagnostics should be published to diagnostics.
void setDisabledFilters(::std::unordered_set<::std::string > filters)
Set which filters are temporarily disabled.
void updateDynamicParams() const
Update dynamic parameters on the server to correspond to current settings of this nodelet.
::ros::Duration maxAge
Maximum age of a message for it to be considered. Older messages are thrown away when received.
::std::string topicIn
Topic for incoming messages.
cras_cpp_common
Author(s): Martin Pecka
autogenerated on Wed Apr 23 2025 02:48:42