15 #include <unordered_set> 18 #include <ros/common.h> 19 #if ROS_VERSION_MINIMUM(1, 15, 0) 20 #include <filters/filter_base.hpp> 21 #include <filters/filter_chain.hpp> 53 typedef ::std::function<
54 void(
const F&
data,
const size_t filterNum, const ::std::string& name, const ::std::string& type)>
66 typedef ::std::function<
67 void(
const F& data,
const size_t filterNum, const ::std::string& name, const ::std::string& type,
bool success)>
108 bool update(
const F& data_in, F& data_out);
146 ::std::vector<::std::shared_ptr<::filters::FilterBase<F>>>
getActiveFilters()
const;
198 #include "impl/filter_chain.hpp" void disableFilter(const ::std::string &name)
Temporarily disable the filter with the given name.
::std::unordered_set<::std::string > getDisabledFilters() const
Get which filters are temporarily disabled.
void setDisabledFilters(::std::unordered_set<::std::string > filters)
Set which filters are temporarily disabled. This overrides any previous calls to disableFilter() and ...
Log helper redirecting the logging calls to ROS_ macros.
FilterFinishedCallback filterFinishedCallback
The optional callback to call when a filter finishes its work.
::std::vector<::std::shared_ptr<::filters::FilterBase< F > > > activeFilters
A list of filters that should be treated as active and should act on the input data.
void callFinishedCallback(const F &data, size_t filterNum, bool succeeded)
If filterFinishedCallback is set, call it.
void setNodelet(const ::nodelet::Nodelet *nodelet)
Inform this chain that it is running in the given nodelet, so that it can do appropriate optimization...
::std::function< void(const F &data, const size_t filterNum, const ::std::string &name, const ::std::string &type)> FilterStartCallback
Callback to be called before each filter processes the data.
::std::unordered_set<::std::string > disabledFilters
A set of filters that have been temporarily disabled.
void updateActiveFilters()
Update the contents of activeFilters with just the filters that have not been disabled.
void enableFilter(const ::std::string &name)
Enable the temporarily disabled filter with the given name.
::std::function< void(const F &data, const size_t filterNum, const ::std::string &name, const ::std::string &type, bool success)> FilterFinishedCallback
Callback to be called after each filter processes the data.
::std::vector<::std::shared_ptr<::filters::FilterBase< F > > > getActiveFilters() const
Get a copy of the list of active filters.
void callStartCallback(const F &data, size_t filterNum)
If filterStartCallback is set, call it.
F buffer1
A temporary intermediate buffer.
FilterChain(const ::std::string &dataType, const FilterFinishedCallback &filterFinishedCallback={}, const FilterStartCallback &filterStartCallback={}, const ::cras::LogHelperPtr &logHelper=::std::make_shared<::cras::NodeLogHelper >())
Construct a filter chain.
void setFilterStartCallback(const FilterStartCallback &callback)
Set the filter start callback.
mutable ::std::mutex activeFiltersMutex
Mutex protecting activeFilters access.
void setFilterFinishedCallback(const FilterFinishedCallback &callback)
Set the filter finished callback.
bool clear()
Clear all filters from this chain. This function intentionally shadows filters::FilterChain::clear() ...
Convenience base class for providing this->log and getCrasLogger(). Just add it as a base to your cla...
F buffer0
A temporary intermediate buffer.
FilterStartCallback filterStartCallback
The optional callback to call when a filter starts its work.
bool update(const F &data_in, F &data_out)
Do the filtering. This function intentionally shadows filters::FilterChain::update() which is non-vir...
::cras::LogHelper::Ptr LogHelperPtr
Pointer to LogHelper.
bool initialized
Whether this filter chain has been initialized (gets set by first update() and cleared by clear())...