• R/O
  • SSH
  • HTTPS

particle-filter: 提交


Commit MetaInfo

修订版10 (tree)
时间2010-04-20 20:59:53
作者(del#42041)

Log Message

(empty log message)

更改概述

差异

--- test/test_filter.cc (revision 9)
+++ test/test_filter.cc (revision 10)
@@ -4,10 +4,17 @@
44 #include <filter.h>
55 using namespace std;
66
7-Particles<int> func(Particles<int> &p)
7+Particles<int> func(Particles<int> &p, Particles<double> &v)
88 {
99 // Particles a(5,3);
1010 // Particles a;
11+ for(int i=0;i<p.size();++i)
12+ {
13+ for(int j=0;j<p[i].size();++j)
14+ {
15+ p[i][j]= (int)((double)p[i][j]+v[i][j]);
16+ }
17+ }
1118 cout<<"state function"<<endl;
1219 return(p);
1320 }
@@ -29,9 +36,19 @@
2936 a.setDimension(3);
3037 a.createInitialParticles();
3138 a.dump_predict_particles();
39+ }
40+ void test_manipulation(void)
41+ {
42+ Filter a;
43+ a.setNumber(5);
44+ a.setDimension(3);
45+ a.createInitialParticles();
46+ a.createSystemNoise();
47+ a.dump_predict_particles();
48+ a.dump_System_Noise();
3249 a.set_state_func(&func);
33- Particles<int> b(5,3);
34- a.get_next_state(b);
50+ a.get_next_state();
51+ a.dump_predict_particles();
3552 }
3653 }
3754 int main()
--- src/Makefile.in (revision 9)
+++ src/Makefile.in (revision 10)
@@ -3,12 +3,12 @@
33 SRCS=particle.cc particles.cc filter.cc
44 OBJS=$(SRCS:.cc=.o)
55 HEADS=$(SRCS:.cc=.h)
6-TARGETS=libparticle.so
6+TARGETS=libparticle.a
77 AR=@AR@
88 CFLAGS=-I. -g -Wall
99 all: $(TARGETS)
1010
11-libparticle.so: $(OBJS)
11+libparticle.a: $(OBJS)
1212 $(AR) rv $@ $(OBJS)
1313 #libparticle.so: $(OBJS)
1414 # libtool --mode=link $(CXX) -o $(@:.so=.la) $(OBJS:.o=.lo) $(LDFLAGS) -shared
--- src/particle.cc (revision 9)
+++ src/particle.cc (revision 10)
@@ -80,3 +80,4 @@
8080 }
8181
8282 template class Particle<int>;
83+template class Particle<double>;
--- src/filter.cc (revision 9)
+++ src/filter.cc (revision 10)
@@ -40,10 +40,10 @@
4040 {
4141 for(int j=0;j<v[i].size();++j)
4242 {
43-// v[i][j] =
43+ v[i][j] = mtrand.randNorm();
4444 }
4545 }
46-
46+ return(true);
4747 }
4848 int Filter::dump_predict_particles()
4949 {
@@ -50,15 +50,18 @@
5050 x.dump_particles();
5151 return(0);
5252 }
53-bool Filter::set_state_func(Particles<int> (*func)(Particles<int> &p))
53+int Filter::dump_System_Noise()
5454 {
55+ v.dump_particles();
56+ return(0);
57+}
58+bool Filter::set_state_func(Particles<int> (*func)(Particles<int> &p, Particles<double> &v))
59+{
5560 state_func = func;
5661 return(true);
5762 }
58-Filter & Filter::get_next_state(Particles<int> &p)
63+Filter & Filter::get_next_state()
5964 {
60-cout<<"go..."<<endl;
61- (*state_func)(p);
62-cout<<"ok..."<<endl;
65+ (*state_func)(x, v);
6366 return(*this);
6467 }
--- src/particles.cc (revision 9)
+++ src/particles.cc (revision 10)
@@ -56,3 +56,6 @@
5656 }
5757 return(0);
5858 }
59+
60+template class Particles<int>;
61+template class Particles<double>;
\ No newline at end of file
--- src/filter.h (revision 9)
+++ src/filter.h (revision 10)
@@ -9,12 +9,13 @@
99
1010 class Filter
1111 {
12- Particles<int> x, v;
12+ Particles<int> x;
13+ Particles<double> v;
1314 double w;
1415 MTRand mtrand;
1516 vector<int> y;
1617 int number, dimension;
17- Particles<int> (*state_func)(Particles<int> &p);
18+ Particles<int> (*state_func)(Particles<int> &p, Particles<double> &v);
1819 public:
1920 Filter();
2021 ~Filter();
@@ -23,8 +24,9 @@
2324 bool createInitialParticles();
2425 bool createSystemNoise();
2526 int dump_predict_particles();
26- bool set_state_func(Particles<int> (*func)(Particles<int> &p));
27- Filter & get_next_state(Particles<int> &p);
27+ bool set_state_func(Particles<int> (*func)(Particles<int> &p, Particles<double> &v));
28+ Filter & get_next_state();
29+ int dump_System_Noise();
2830 };
2931
3032 #endif
--- src/Makefile (revision 9)
+++ src/Makefile (revision 10)
@@ -3,12 +3,12 @@
33 SRCS=particle.cc particles.cc filter.cc
44 OBJS=$(SRCS:.cc=.o)
55 HEADS=$(SRCS:.cc=.h)
6-TARGETS=libparticle.so
6+TARGETS=libparticle.a
77 AR=ar
88 CFLAGS=-I. -g -Wall
99 all: $(TARGETS)
1010
11-libparticle.so: $(OBJS)
11+libparticle.a: $(OBJS)
1212 $(AR) rv $@ $(OBJS)
1313 #libparticle.so: $(OBJS)
1414 # libtool --mode=link $(CXX) -o $(@:.so=.la) $(OBJS:.o=.lo) $(LDFLAGS) -shared
Show on old repository browser