Go to the documentation of this file.
30 #ifndef FILTERS_FILTER_BASE_HPP_
31 #define FILTERS_FILTER_BASE_HPP_
65 if (!node_handle.getParam(param_name, config))
67 ROS_ERROR(
"Could not find parameter %s on the server, are you sure that it was pushed up correctly?", param_name.c_str());
97 virtual bool update(
const T& data_in, T& data_out)=0;
118 bool getParam(
const std::string& name, std::string& value)
const
120 string_map_t::const_iterator it =
params_.find(name);
131 auto tmp = it->second;
132 value = std::string(tmp);
140 bool getParam(
const std::string& name,
bool& value)
const
142 string_map_t::const_iterator it =
params_.find(name);
153 auto tmp = it->second;
162 bool getParam(
const std::string&name,
double& value)
const
164 string_map_t::const_iterator it =
params_.find(name);
175 auto tmp = it->second;
184 bool getParam(
const std::string&name,
int& value)
const
186 string_map_t::const_iterator it =
params_.find(name);
197 auto tmp = it->second;
206 bool getParam(
const std::string&name,
unsigned int& value)
const
211 if (signed_value < 0)
213 value = signed_value;
221 bool getParam(
const std::string&name, std::vector<double>& value)
const
223 string_map_t::const_iterator it =
params_.find(name);
238 for (
int i = 0; i < double_array.
size(); ++i){
245 value.push_back(double_value);
255 bool getParam(
const std::string&name, std::vector<std::string>& value)
const
257 string_map_t::const_iterator it =
params_.find(name);
272 for (
unsigned int i = 0; i < string_array.
size(); ++i){
278 value.push_back(string_array[i]);
290 string_map_t::const_iterator it =
params_.find(name);
296 auto tmp = it->second;
319 ROS_ERROR(
"Filter didn't have name defined, other strings are not allowed");
323 std::string name = config[
"name"];
327 ROS_ERROR(
"Filter %s didn't have type defined, other strings are not allowed", name.c_str());
331 std::string type = config[
"type"];
335 ROS_DEBUG(
"Configuring Filter of Type: %s with name %s", type.c_str(), name.c_str());
344 ROS_ERROR(
"A filter configuration must be a map with fields name, type, and params");
368 ROS_DEBUG(
"Loading param %s\n", it->first.c_str());
369 params_[it->first] = it->second;
379 template <
typename T>
393 if (!node_handle.getParam(param_name, config))
395 ROS_ERROR(
"Could not find parameter %s on the server, are you sure that it was pushed up correctly?", param_name.c_str());
398 return configure(number_of_channels, config);
409 ROS_DEBUG(
"FilterBase being configured with XmlRpc xml: %s type: %d", config.
toXml().c_str(), config.
getType());
429 ROS_ERROR(
"MultiChannelFilterBase configure should be called with a number of channels argument, assuming 1");
441 virtual bool update(
const std::vector<T>& data_in, std::vector<T>& data_out)=0;
445 ROS_ERROR(
"THIS IS A MULTI FILTER DON'T CALL SINGLE FORM OF UPDATE");
462 #endif //#ifndef FILTERS_FILTER_BASE_HPP_
A Base filter class to provide a standard interface for all filters.
virtual ~FilterBase()
Virtual Destructor.
std::string toXml() const
bool setNameAndType(XmlRpc::XmlRpcValue &config)
Set the name and type of the filter from the parameter server.
bool configure(unsigned int number_of_channels, XmlRpc::XmlRpcValue &config)
The public method to configure a filter from XML.
bool configure(const std::string ¶m_name, ros::NodeHandle node_handle=ros::NodeHandle())
Configure the filter from the parameter server.
bool configure(unsigned int number_of_channels, const std::string ¶m_name, ros::NodeHandle node_handle=ros::NodeHandle())
Configure the filter from the parameter server.
std::map< std::string, XmlRpc::XmlRpcValue > string_map_t
virtual bool update(const T &, T &)
Update the filter and return the data seperately This is an inefficient way to do this and can be ove...
virtual bool update(const std::vector< T > &data_in, std::vector< T > &data_out)=0
Update the filter and return the data seperately.
std::string filter_name_
The name of the filter.
bool getParam(const std::string &name, std::vector< std::string > &value) const
Get a filter parameter as a std::vector<string>
bool getParam(const std::string &name, double &value) const
Get a filter parameter as a double.
bool getParam(const std::string &name, XmlRpc::XmlRpcValue &value) const
Get a filter parameter as a XmlRpcValue.
std::string getType()
Get the type of the filter as a string.
bool getParam(const std::string &name, bool &value) const
Get a filter parameter as a boolean.
bool loadConfiguration(XmlRpc::XmlRpcValue &config)
virtual bool configure()=0
Pure virtual function for the sub class to configure the filter This function must be implemented in ...
bool getParam(const std::string &name, int &value) const
Get a filter parameter as a int.
virtual bool update(const T &data_in, T &data_out)=0
Update the filter and return the data seperately This is an inefficient way to do this and can be ove...
unsigned int number_of_channels_
How many parallel inputs for which the filter is to be configured.
bool getParam(const std::string &name, std::string &value) const
Get a filter parameter as a string.
bool getParam(const std::string &name, std::vector< double > &value) const
Get a filter parameter as a std::vector<double>
ValueStruct::iterator iterator
const Type & getType() const
bool hasMember(const std::string &name) const
const std::string & getName() const
Get the name of the filter as a string.
FilterBase()
Default constructor used by Filter Factories.
bool configured_
Whether the filter has been configured.
bool getParam(const std::string &name, unsigned int &value) const
Get a filter parameter as an unsigned int.
string_map_t params_
Storage of the parsed xml parameters.
virtual bool configure()=0
Pure virtual function for the sub class to configure the filter This function must be implemented in ...
bool configure(XmlRpc::XmlRpcValue &config)
The public method to configure a filter from XML.
std::string filter_type_
The type of the filter (Used by FilterChain for Factory construction)
bool configure(XmlRpc::XmlRpcValue &config)
A method to hide the base class method and warn if improperly called.
filters
Author(s):
autogenerated on Fri Nov 11 2022 03:09:05