|
From: <ei...@us...> - 2009-08-25 18:22:47
|
Revision: 22863
http://personalrobots.svn.sourceforge.net/personalrobots/?rev=22863&view=rev
Author: eitanme
Date: 2009-08-25 18:22:41 +0000 (Tue, 25 Aug 2009)
Log Message:
-----------
Fixing filter chains that are pushed to the parameter server using xml. Also, adding a test for a transfer_function chain to the filters package
Modified Paths:
--------------
pkg/trunk/demos/plug_in/make_lowpass.m
pkg/trunk/highlevel/plugs/plugs_core/scripts/make_lowpass.m
pkg/trunk/stacks/common/filters/default_plugins.xml
pkg/trunk/stacks/common/filters/include/filters/filter_chain.h
pkg/trunk/stacks/common/filters/src/transfer_function.cpp
pkg/trunk/stacks/common/filters/test/test_chain.cpp
pkg/trunk/stacks/common/filters/test/test_chain.yaml
Modified: pkg/trunk/demos/plug_in/make_lowpass.m
===================================================================
--- pkg/trunk/demos/plug_in/make_lowpass.m 2009-08-25 17:58:14 UTC (rev 22862)
+++ pkg/trunk/demos/plug_in/make_lowpass.m 2009-08-25 18:22:41 UTC (rev 22863)
@@ -13,20 +13,16 @@
#printf(' <params a="%f %f" b="%f %f" />\n', a(1), a(2), b(1), b(2));
#printf('</filter>\n');
-printf('<filter>');
printf('<value>');
printf('<array>');
printf('<data>');
+printf('<value>');
printf('<struct>');
printf('<member>');
-printf('<name>%s</name>', filter_name);
-printf('<value>d_error_filter</value>');
+printf('<name>name</name>');
+printf('<value>%s</value>', filter_name);
printf('</member>');
printf('<member>');
-printf('<name>type</name>');
-printf('<value>TransferFunctionFilter</value>');
-printf('</member>');
-printf('<member>');
printf('<name>params</name>');
printf('<value>');
printf('<struct>');
@@ -55,8 +51,12 @@
printf('</struct>');
printf('</value>');
printf('</member>');
+printf('<member>');
+printf('<name>type</name>');
+printf('<value>MultiChannelTransferFunctionFilterDouble</value>');
+printf('</member>');
printf('</struct>');
+printf('</value>');
printf('</data>');
printf('</array>');
printf('</value>');
-printf('</filter>');
Modified: pkg/trunk/highlevel/plugs/plugs_core/scripts/make_lowpass.m
===================================================================
--- pkg/trunk/highlevel/plugs/plugs_core/scripts/make_lowpass.m 2009-08-25 17:58:14 UTC (rev 22862)
+++ pkg/trunk/highlevel/plugs/plugs_core/scripts/make_lowpass.m 2009-08-25 18:22:41 UTC (rev 22863)
@@ -13,20 +13,16 @@
#printf(' <params a="%f %f" b="%f %f" />\n', a(1), a(2), b(1), b(2));
#printf('</filter>\n');
-printf('<filter>');
printf('<value>');
printf('<array>');
printf('<data>');
+printf('<value>');
printf('<struct>');
printf('<member>');
-printf('<name>%s</name>', filter_name);
-printf('<value>d_error_filter</value>');
+printf('<name>name</name>');
+printf('<value>%s</value>', filter_name);
printf('</member>');
printf('<member>');
-printf('<name>type</name>');
-printf('<value>TransferFunctionFilter</value>');
-printf('</member>');
-printf('<member>');
printf('<name>params</name>');
printf('<value>');
printf('<struct>');
@@ -55,8 +51,12 @@
printf('</struct>');
printf('</value>');
printf('</member>');
+printf('<member>');
+printf('<name>type</name>');
+printf('<value>MultiChannelTransferFunctionFilterDouble</value>');
+printf('</member>');
printf('</struct>');
+printf('</value>');
printf('</data>');
printf('</array>');
printf('</value>');
-printf('</filter>');
Modified: pkg/trunk/stacks/common/filters/default_plugins.xml
===================================================================
--- pkg/trunk/stacks/common/filters/default_plugins.xml 2009-08-25 17:58:14 UTC (rev 22862)
+++ pkg/trunk/stacks/common/filters/default_plugins.xml 2009-08-25 18:22:41 UTC (rev 22863)
@@ -52,7 +52,7 @@
</class>
</library>
<library path="lib/libtransfer_function">
- <class name="transferFunctionMultiDouble" type="filters::TransferFunctionDoubleFilter"
+ <class name="MultiChannelTransferFunctionFilterDouble" type="filters::TransferFunctionFilter<double>"
base_class_type="filters::MultiChannelFilterBase<double>">
<description>
THis is a transfer filter which works on a stream of doubles.
Modified: pkg/trunk/stacks/common/filters/include/filters/filter_chain.h
===================================================================
--- pkg/trunk/stacks/common/filters/include/filters/filter_chain.h 2009-08-25 17:58:14 UTC (rev 22862)
+++ pkg/trunk/stacks/common/filters/include/filters/filter_chain.h 2009-08-25 18:22:41 UTC (rev 22863)
@@ -138,11 +138,12 @@
bool configure(XmlRpc::XmlRpcValue& config)
{
/*************************** Parse the XmlRpcValue ***********************************/
-
//Verify proper naming and structure
if (config.getType() != XmlRpc::XmlRpcValue::TypeArray)
{
ROS_ERROR("The filter chain specification must be a list. but is of of XmlRpcType %d", config.getType());
+ ROS_ERROR("The xml passed in is formatted as follows:\n %s", config.toXml().c_str());
+
return false;
}
@@ -333,11 +334,12 @@
bool configure(unsigned int size, XmlRpc::XmlRpcValue& config)
{
/*************************** Parse the XmlRpcValue ***********************************/
-
//Verify proper naming and structure
if (config.getType() != XmlRpc::XmlRpcValue::TypeArray)
{
ROS_ERROR("The filter chain specification must be a list. but is of of XmlRpcType %d", config.getType());
+ ROS_ERROR("The xml passed in is formatted as follows:\n %s", config.toXml().c_str());
+
return false;
}
Modified: pkg/trunk/stacks/common/filters/src/transfer_function.cpp
===================================================================
--- pkg/trunk/stacks/common/filters/src/transfer_function.cpp 2009-08-25 17:58:14 UTC (rev 22862)
+++ pkg/trunk/stacks/common/filters/src/transfer_function.cpp 2009-08-25 18:22:41 UTC (rev 22863)
@@ -30,4 +30,4 @@
#include "filters/transfer_function.h"
#include "pluginlib/class_list_macros.h"
-PLUGINLIB_REGISTER_CLASS(TransferFunctionMultiDouble, filters::TransferFunctionFilter<double>, filters::MultiChannelFilterBase<double>)
+PLUGINLIB_REGISTER_CLASS(MultiChannelTransferFunctionFilterDouble, filters::TransferFunctionFilter<double>, filters::MultiChannelFilterBase<double>)
Modified: pkg/trunk/stacks/common/filters/test/test_chain.cpp
===================================================================
--- pkg/trunk/stacks/common/filters/test/test_chain.cpp 2009-08-25 17:58:14 UTC (rev 22862)
+++ pkg/trunk/stacks/common/filters/test/test_chain.cpp 2009-08-25 18:22:41 UTC (rev 22863)
@@ -142,6 +142,63 @@
EXPECT_NEAR(input1[i], v1a[i], epsilon);
}
}
+
+TEST(MultiChannelFilterChain, TransferFunction){
+ double epsilon = 1e-4;
+
+ filters::MultiChannelFilterChain<double> chain("double");
+ EXPECT_TRUE(chain.configure(3, "TransferFunction" ));
+
+ std::vector<double> in1,in2,in3,in4,in5,in6,in7;
+ std::vector<double> out1;
+
+ in1.push_back(10.0);
+ in1.push_back(10.0);
+ in1.push_back(10.0);
+ //
+ in2.push_back(70.0);
+ in2.push_back(30.0);
+ in2.push_back(8.0);
+ //
+ in3.push_back(-1.0);
+ in3.push_back(5.0);
+ in3.push_back(22.0);
+ //
+ in4.push_back(44.0);
+ in4.push_back(23.0);
+ in4.push_back(8.0);
+ //
+ in5.push_back(10.0);
+ in5.push_back(10.0);
+ in5.push_back(10.0);
+ //
+ in6.push_back(5.0);
+ in6.push_back(-1.0);
+ in6.push_back(5.0);
+ //
+ in7.push_back(6.0);
+ in7.push_back(-30.0);
+ in7.push_back(2.0);
+ //
+ out1.push_back(17.1112);
+ out1.push_back(9.0285);
+ out1.push_back(8.3102);
+ EXPECT_TRUE(chain.update(in1, in1));
+ EXPECT_TRUE(chain.update(in2, in2));
+ EXPECT_TRUE(chain.update(in3, in3));
+ EXPECT_TRUE(chain.update(in4, in4));
+ EXPECT_TRUE(chain.update(in5, in5));
+ EXPECT_TRUE(chain.update(in6, in6));
+ EXPECT_TRUE(chain.update(in7, in7));
+
+ chain.clear();
+
+ for(unsigned int i=0; i<out1.size(); i++)
+ {
+ EXPECT_NEAR(out1[i], in7[i], epsilon);
+ }
+}
+
/*
TEST(MultiChannelFilterChain, OverlappingNames){
filters::MultiChannelFilterChain<double> chain("double");
Modified: pkg/trunk/stacks/common/filters/test/test_chain.yaml
===================================================================
--- pkg/trunk/stacks/common/filters/test/test_chain.yaml 2009-08-25 17:58:14 UTC (rev 22862)
+++ pkg/trunk/stacks/common/filters/test/test_chain.yaml 2009-08-25 18:22:41 UTC (rev 22863)
@@ -29,6 +29,15 @@
name: median_test2
type: MultiChannelMedianFilterDouble
params: {number_of_observations: 5}
+
+TransferFunction:
+ filter_chain:
+ -
+ name: transfer_function
+ type: MultiChannelTransferFunctionFilterDouble
+ params:
+ a: [1.0, -1.760041880343169, 1.182893262037831]
+ b: [0.018098933007514, 0.054296799022543, 0.054296799022543, 0.018098933007514]
MeanFilterFloat5:
filter_chain:
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|