Setting parameters for mean filter
I am trying to use the ROS filters to low-pass filter data from a joysitck using the mean filter. I have a node that accepts the commands from the joystick on the "/joy" topic, filters the data, and publishes on another topic. When I try to setup the filters, they always fail with the error :
MultiChannelMeanFilter did not find param number_of_observations
I tried to load the YAML file with the filter configurations (as shown here) in the global namespace, as well as in the namespace of the node using roslaunch, but neither seems to work.
The code I am using to configure the filters:
class JoystickRelay{
public:
JoystickRelay();
private:
ros::NodeHandle nh_;
ros::NodeHandle pnh_;
ros::Publisher cmd_pub_;
ros::Subscriber vel_sub_;
bool enable_filter_;
void velCallback(const sensor_msgs::Joy::ConstPtr& joy);
filters::MultiChannelMeanFilter<double> filter_;
};
JoystickRelay::JoystickRelay(): pnh_(ros::NodeHandle("~")), enable_filter_(false) {
cmd_pub_ = nh_.advertise<std_msgs::Float64MultiArray>("command", 100);
vel_sub_ = nh_.subscribe("/joy", 1, &JoystickRelay::velCallback, this);
// Check if filtering is enabled
if(pnh_.getParam("filter", enable_filter_)){
if(enable_filter_){
filter_.configure(); // Configure the filter
}
}
}
Am I missing something while configuring the filters?
If you post your launch file & .yaml file it might be easier to troubleshoot. You could also try running some of the test filters in this repo.
Thanks stevejp for pointing me in the right direction. I was able to get this working. I have noted the details in the answer to this question.