motion_model.cpp
Go to the documentation of this file.
1 /**************************************************************************************************
2  Software License Agreement (BSD License)
3 
4  Copyright (c) 2011-2013, LAR toolkit developers - University of Aveiro - http://lars.mec.ua.pt
5  All rights reserved.
6 
7  Redistribution and use in source and binary forms, with or without modification, are permitted
8  provided that the following conditions are met:
9 
10  *Redistributions of source code must retain the above copyright notice, this list of
11  conditions and the following disclaimer.
12  *Redistributions in binary form must reproduce the above copyright notice, this list of
13  conditions and the following disclaimer in the documentation and/or other materials provided
14  with the distribution.
15  *Neither the name of the University of Aveiro nor the names of its contributors may be used to
16  endorse or promote products derived from this software without specific prior written permission.
17 
18  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
19  IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
20  FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
21  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22  DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
24  IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
25  OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 ***************************************************************************************************/
32 #include "motion_model.h"
33 
35 {
36  setDim(6, 0, 6, 2, 2);
37 
38  l=_l;
39  dt=_dt;
40  method=_method;
41 
42  static Vector x(6);
43  double _P0[36];
44 
45  memset(_P0,0,sizeof(_P0));
46 
47  _P0[0]=100*100;
48  _P0[7]=100*100;
49  _P0[14]=100*100;
50  _P0[21]=100*100;
51  _P0[28]=100*100;
52  _P0[35]=100*100;
53 
54  static Matrix P0(6,6,_P0);
55 
56  x(1)=0.;
57  x(2)=0;
58  x(3)=0;
59  x(4)=0;
60  x(5)=0;
61  x(6)=0;
62 
63  init(x,P0);
64 }
65 
67 {
68  dt=_dt;
69 }
70 
72 {
73  double v1=x(3);
74  double t=x(4);
75  double f=x(5);
76 
77 // printf("Make A dt %f\n",dt);
78 
79  //dF1
80  A(1,1)=1.0;
81  A(1,2)=0.0;
82  A(1,3)=cos(t)*cos(f)*dt;
83  A(1,4)=-sin(t)*cos(f)*v1*dt;
84  A(1,5)=cos(t)*(-sin(f))*v1*dt;
85  A(1,6)=0.0;
86 
87  A(2,1)=0.0;
88  A(2,2)=1.0;
89  A(2,3)=sin(t)*cos(f)*dt;
90  A(2,4)=cos(t)*cos(f)*v1*dt;
91  A(2,5)=sin(t)*(-sin(f))*v1*dt;
92  A(2,6)=0.0;
93 
94  A(3,1)=0.0;
95  A(3,2)=0.0;
96  A(3,3)=1.0;
97  A(3,4)=0.0;
98  A(3,5)=0.0;
99  A(3,6)=0.0;
100 
101  A(4,1)=0.0;
102  A(4,2)=0.0;
103  A(4,3)=sin(f/l)*dt;
104  A(4,4)=1.0;
105  A(4,5)=cos(f/l)/l*v1*dt;
106  A(4,6)=0.0;
107 
108  A(5,1)=0.0;
109  A(5,2)=0.0;
110  A(5,3)=0.0;
111  A(5,4)=0.0;
112  A(5,5)=1.0;
113  A(5,6)=dt;
114 
115  A(6,1)=0.0;
116  A(6,2)=0.0;
117  A(6,3)=0.0;
118  A(6,4)=0.0;
119  A(6,5)=0.0;
120  A(6,6)=1.0;
121 }
122 
124 {
125  H(1,1) = 0.0;
126  H(1,2) = 0.0;
127  H(1,3) = 1.0;
128  H(1,4) = 0.0;
129  H(1,5) = 0.0;
130  H(1,6) = 0.0;
131 
132  H(2,1) = 0.0;
133  H(2,2) = 0.0;
134  H(2,3) = 0.0;
135  H(2,4) = 0.0;
136  H(2,5) = 1.0;
137  H(2,6) = 0.0;
138 }
139 
141 {
142  W(1,1) = 1.0;
143  W(1,2) = 0.0;
144  W(1,3) = 0.0;
145  W(1,4) = 0.0;
146  W(1,5) = 0.0;
147  W(1,6) = 0.0;
148 
149  W(2,1) = 0.0;
150  W(2,2) = 1.0;
151  W(2,3) = 0.0;
152  W(2,4) = 0.0;
153  W(2,5) = 0.0;
154  W(2,6) = 0.0;
155 
156  W(3,1) = 0.0;
157  W(3,2) = 0.0;
158  W(3,3) = 1.0;
159  W(3,4) = 0.0;
160  W(3,5) = 0.0;
161  W(3,6) = 0.0;
162 
163  W(4,1) = 0.0;
164  W(4,2) = 0.0;
165  W(4,3) = 0.0;
166  W(4,4) = 1.0;
167  W(4,5) = 0.0;
168  W(4,6) = 0.0;
169 
170  W(5,1) = 0.0;
171  W(5,2) = 0.0;
172  W(5,3) = 0.0;
173  W(5,4) = 0.0;
174  W(5,5) = 1.0;
175  W(5,6) = 0.0;
176 
177  W(6,1) = 0.0;
178  W(6,2) = 0.0;
179  W(6,3) = 0.0;
180  W(6,4) = 0.0;
181  W(6,5) = 0.0;
182  W(6,6) = 1.0;
183 }
184 
186 {
187 // x(1) -> x
188 // x(2) -> y
189 // x(3) -> v1
190 // x(4) -> t
191 // x(5) -> f
192 // x(6) -> v2
193 
194  Vector x_(x.size());
195 
196  x_(1) = x(1) + cos(x(4))*cos(x(5))*x(3)*dt;
197  x_(2) = x(2) + sin(x(4))*cos(x(5))*x(3)*dt;
198  x_(3) = x(3);
199  x_(4) = x(4) + sin(x(5)/l)*x(3)*dt;
200 // printf("L %f Dt %f V1 %f\n",l,dt,x(3));
201 // printf("X(4) %f\n",x_(4));
202 
203  x_(5) = x(5) + x(6)*dt*0.1;
204  x_(6) = x(6);
205 
206  x.swap(x_);
207 }
208 
210 {
211  z(1)=x(3);
212  z(2)=x(5);
213 }
214 
216 {
217  V(1,1) = 1.0;
218  V(1,2) = 0.0;
219  V(2,1) = 0.0;
220  V(2,2) = 1.0;
221 }
222 
224 {
225 // double r=100*100;
226 // double r=10*10;
227 
228 // double vmin=0.1;
229 // double vmax=5.;
230 //
231 // double f=(-1/vmax)*x(3)+1;
232 // f=f>0?f:0;
233 //
234 // printf(">>F %f\n",f);
235 // double f;
236 //
237 // f=10./grxy;
238 //
239 // if(isnan(f))
240 // f=100;
241 //
242 // if(f>100)
243 // f=100;
244 //
245 // if(f<1)
246 // f=1;
247 
248 // printf("F %f\n",f);
249  /*
250  if(grxy<4)
251  {
252  f=100;
253  }else if(grxy<10)
254  {
255  f=1;
256  }else
257  f=1;*/
258 
259 // 0.0013
260 // 0.0680
261 
262 
263 // R(1,1) = 0.0680;//vel
264 // R(1,2) = 0;
265 
266 // R(2,1) = 0;//dir
267 // R(2,2) = 0.0013;
268 
269  switch(method)
270  {
271  case MBICP:
272 // R(1,1) = 0.2221;//vel
273 // R(1,2) = -0.0056;
274 
275 // R(2,1) = -0.0056;//dir
276 // R(2,2) = 0.0036;
277 
278  R(1,1) = 0.0600;//vel
279  R(1,2) = 0.0010;
280 
281  R(2,1) = 0.0010;//dir
282  R(2,2) = 0.0400;
283 
284  break;
285 
286  case PSM:
287 
288  R(1,1) = 0.0600;//vel
289  R(1,2) = 0.0010;
290 
291  R(2,1) = 0.0010;//dir
292  R(2,2) = 0.0400;
293 
294  break;
295 
296  case PLICP:
297  R(1,1) = 0.0662;//vel
298  R(1,2) = 0.0010;
299 
300  R(2,1) = 0.0010;//dir
301  R(2,2) = 0.0217;
302  break;
303  }
304 
305 
306 // R(1,1) = r*5.;//vel
307 // R(1,2) = 0;
308 
309 // R(2,1) = 0;//dir
310 // R(2,2) = r;
311 }
312 
314 {
315  double q=0;
316 // double q=2*2;
317  switch(method)
318  {
319  case MBICP:
320 // q=0.015;
321  q=0.0015;
322  break;
323 
324  case PSM:
325  q=0.0015;
326  break;
327 
328  case PLICP:
329  q=0.0005;
330  break;
331  }
332 
333 
334 
335  //X
336  Q(1,1) = q;
337  Q(1,2) = 0.0;
338  Q(1,3) = 0.0;
339  Q(1,4) = 0.0;
340  Q(1,5) = 0.0;
341  Q(1,6) = 0.0;
342 
343  //Y
344  Q(2,1) = 0.0;
345  Q(2,2) = q;
346  Q(2,3) = 0.0;
347  Q(2,4) = 0.0;
348  Q(2,5) = 0.0;
349  Q(2,6) = 0.0;
350 
351  //Vl
352  Q(3,1) = 0.0;
353  Q(3,2) = 0.0;
354  Q(3,3) = q*1.;
355  Q(3,4) = 0.0;
356  Q(3,5) = 0.0;
357  Q(3,6) = 0.0;
358 
359  //Theta
360  Q(4,1) = 0.0;
361  Q(4,2) = 0.0;
362  Q(4,3) = 0.0;
363  Q(4,4) = q;
364  Q(4,5) = 0.0;
365  Q(4,6) = 0.0;
366 
367  //Fi
368  Q(5,1) = 0.0;
369  Q(5,2) = 0.0;
370  Q(5,3) = 0.0;
371  Q(5,4) = 0.0;
372  Q(5,5) = q*1.;
373  Q(5,6) = 0.0;
374 
375  //Df
376  Q(6,1) = 0.0;
377  Q(6,2) = 0.0;
378  Q(6,3) = 0.0;
379  Q(6,4) = 0.0;
380  Q(6,5) = 0.0;
381  Q(6,6) = q*1.;
382 
383 }
double z[2]
constant_velocity_nh(double _l, double _dt, scan_matching_method _method)
Constructor.
double dt
Iteration interval.
Definition: motion_model.h:58
void makeA()
Make the process Jacobian matrix.
void updateDt(double _dt)
Update the iteration interval.
Nonholonomic motion model declaration.
void makeMeasure()
Make measurement, used when measurement is not possible (i'm not using it now)
double l
Wheel base of the nonholonomic vehicle.
Definition: motion_model.h:56
void makeQ()
Make process noise covariance matrix.
void makeH()
Make measurement sensitivity matrix.
void makeR()
Make measurement noise covariance matrix.
constant_velocity_nh::Vector Vector
Definition: motion_model.h:111
constant_velocity_nh::Matrix Matrix
Definition: motion_model.h:112
scan_matching_method
Definition: motion_model.h:39
void makeProcess()
Make process, model iteration.
void makeW()
Make process noise sensitivity matrix.
scan_matching_method method
Scan matching method used, this will influence the errors.
Definition: motion_model.h:108
void makeV()
Make measurement noise sensitivity matrix.


lidar_egomotion
Author(s): Jorge Almeida
autogenerated on Mon Mar 2 2015 01:32:10