Main MRPT website > C++ reference
MRPT logo
sensors.h
Go to the documentation of this file.
1 /* +---------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | http://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2015, Individual contributors, see AUTHORS file |
6  | See: http://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See details in http://www.mrpt.org/License |
8  +---------------------------------------------------------------------------+ */
9 
10 #pragma once
11 
12 #include <mrpt/poses/CPose3DQuat.h>
13 
14 namespace mrpt { namespace srba {
15  /** \defgroup mrpt_srba_models Sensor models: one for each combination of {landmark_parameterization,observation_type}
16  * \ingroup mrpt_srba_grp */
17 
18  /** \addtogroup mrpt_srba_models
19  * @{ */
20 
21 
22  /** Sensor model: 3D landmarks in Euclidean coordinates + Monocular camera observations (no distortion) */
23  template <>
24  struct sensor_model<landmarks::Euclidean3D,observations::MonocularCamera>
25  {
26  // --------------------------------------------------------------------------------
27  // Typedefs for the sake of generality in the signature of methods below:
28  // *DONT FORGET* to change these when writing new sensor models.
29  // --------------------------------------------------------------------------------
32  // --------------------------------------------------------------------------------
33 
34  static const size_t OBS_DIMS = OBS_T::OBS_DIMS;
35  static const size_t LM_DIMS = LANDMARK_T::LM_DIMS;
36 
37  typedef Eigen::Matrix<double,OBS_DIMS,LM_DIMS> TJacobian_dh_dx; //!< A Jacobian of the correct size for each dh_dx
40 
41 
42  /** Executes the (negative) observation-error model: "-( h(lm_pos,pose) - z_obs)"
43  * \param[out] out_obs_err The output of the predicted sensor value
44  * \param[in] z_obs The real observation, to be contrasted to the prediction of this sensor model
45  * \param[in] base_pose_wrt_observer The relative pose of the observed landmark's base KF, wrt to the current sensor pose (which may be different than the observer KF pose if the sensor is not at the "robot origin").
46  * \param[in] lm_pos The relative landmark position wrt its base KF.
47  * \param[in] params The sensor-specific parameters.
48  */
49  template <class POSE_T>
50  static void observe_error(
53  const POSE_T & base_pose_wrt_observer,
55  const OBS_T::TObservationParams & params)
56  {
57  double x,y,z; // wrt cam (local coords)
58  base_pose_wrt_observer.composePoint(lm_pos[0],lm_pos[1],lm_pos[2], x,y,z);
59  ASSERT_(z!=0)
60 
61  // Pinhole model:
62  observation_traits<OBS_T>::array_obs_t pred_obs; // prediction
63  pred_obs[0] = params.camera_calib.cx() + params.camera_calib.fx() * x/z;
64  pred_obs[1] = params.camera_calib.cy() + params.camera_calib.fy() * y/z;
65  out_obs_err = z_obs - pred_obs;
66  }
67 
68  /** Evaluates the partial Jacobian dh_dx:
69  * \code
70  * d h(x')
71  * dh_dx = -------------
72  * d x'
73  *
74  * \endcode
75  * With:
76  * - x' = x^{j,i}_l The relative location of the observed landmark wrt to the robot/camera at the instant of observation. (See notation on papers)
77  * - h(x): Observation model: h(): landmark location --> observation
78  *
79  * \param[out] dh_dx The output matrix Jacobian. Values at input are undefined (i.e. they cannot be asssumed to be zeros by default).
80  * \param[in] xji_l The relative location of the observed landmark wrt to the robot/camera at the instant of observation.
81  * \param[in] sensor_params Sensor-specific parameters, as set by the user.
82  *
83  * \return true if the Jacobian is well-defined, false to mark it as ill-defined and ignore it during this step of the optimization
84  */
85  static bool eval_jacob_dh_dx(
86  TJacobian_dh_dx & dh_dx,
87  const array_landmark_t & xji_l,
88  const TObservationParams & sensor_params)
89  {
90  // xji_l[0:2]=[X Y Z]
91  // If the point is behind us, mark this Jacobian as invalid. This is probably a temporary situation until we get closer to the optimum.
92  if (xji_l[2]<=0)
93  return false;
94 
95  const double pz_inv = 1.0/xji_l[2];
96  const double pz_inv2 = pz_inv*pz_inv;
97 
98  const double cam_fx = sensor_params.camera_calib.fx();
99  const double cam_fy = sensor_params.camera_calib.fy();
100 
101  dh_dx.coeffRef(0,0)= cam_fx * pz_inv;
102  dh_dx.coeffRef(0,1)= 0;
103  dh_dx.coeffRef(0,2)= -cam_fx * xji_l[0] * pz_inv2;
104 
105  dh_dx.coeffRef(1,0)= 0;
106  dh_dx.coeffRef(1,1)= cam_fy * pz_inv;
107  dh_dx.coeffRef(1,2)= -cam_fy * xji_l[1] * pz_inv2;
108 
109  return true;
110  }
111 
112  /** Inverse observation model for first-seen landmarks. Needed to avoid having landmarks at (0,0,0) which
113  * leads to undefined Jacobians. This is invoked only when both "unknown_relative_position_init_val" and "is_fixed" are "false"
114  * in an observation.
115  * The LM location must not be exact at all, just make sure it doesn't have an undefined Jacobian.
116  *
117  * \param[out] out_lm_pos The relative landmark position wrt the current observing KF.
118  * \param[in] obs The observation itself.
119  * \param[in] params The sensor-specific parameters.
120  */
121  static void inverse_sensor_model(
124  const OBS_T::TObservationParams & params)
125  {
126  // ¬ +Z
127  // /
128  // /
129  // +----> +X
130  // |
131  // |
132  // V +Y
133  //
134  const double fx = params.camera_calib.fx();
135  const double fy = params.camera_calib.fy();
136  const double cx = params.camera_calib.cx();
137  const double cy = params.camera_calib.cy();
138  out_lm_pos[0] = (obs.px.x-cx)/fx;
139  out_lm_pos[1] = (obs.px.y-cy)/fy;
140  out_lm_pos[2] = 1; // Depth in Z (undefined for monocular cameras, just use any !=0 value)
141  }
142 
143  }; // end of struct sensor_model<landmarks::Euclidean3D,observations::MonocularCamera>
144 
145  // -------------------------------------------------------------------------------------------------------------
146 
147  /** Sensor model: 3D landmarks in Euclidean coordinates + Stereo camera observations (no distortion) */
148  template <>
149  struct sensor_model<landmarks::Euclidean3D,observations::StereoCamera>
150  {
151  // --------------------------------------------------------------------------------
152  // Typedefs for the sake of generality in the signature of methods below:
153  // *DONT FORGET* to change these when writing new sensor models.
154  // --------------------------------------------------------------------------------
157  // --------------------------------------------------------------------------------
158 
159  static const size_t OBS_DIMS = OBS_T::OBS_DIMS;
160  static const size_t LM_DIMS = LANDMARK_T::LM_DIMS;
161 
162  typedef Eigen::Matrix<double,OBS_DIMS,LM_DIMS> TJacobian_dh_dx; //!< A Jacobian of the correct size for each dh_dx
165 
166 
167  /** Executes the (negative) observation-error model: "-( h(lm_pos,pose) - z_obs)"
168  * \param[out] out_obs_err The output of the predicted sensor value
169  * \param[in] z_obs The real observation, to be contrasted to the prediction of this sensor model
170  * \param[in] base_pose_wrt_observer The relative pose of the observed landmark's base KF, wrt to the current sensor pose (which may be different than the observer KF pose if the sensor is not at the "robot origin").
171  * \param[in] lm_pos The relative landmark position wrt its base KF.
172  * \param[in] params The sensor-specific parameters.
173  */
174  template <class POSE_T>
175  static void observe_error(
178  const POSE_T & base_pose_wrt_observer,
180  const OBS_T::TObservationParams & params)
181  {
182  double lx,ly,lz; // wrt cam (local coords)
183  base_pose_wrt_observer.composePoint(lm_pos[0],lm_pos[1],lm_pos[2], lx,ly,lz);
184  ASSERT_(lz!=0)
185 
186  observation_traits<OBS_T>::array_obs_t pred_obs; // prediction
187  // Pinhole model: Left camera.
188  const mrpt::utils::TCamera &lc = params.camera_calib.leftCamera;
189  pred_obs[0] = lc.cx() + lc.fx() * lx/lz;
190  pred_obs[1] = lc.cy() + lc.fy() * ly/lz;
191 
192  // Project point relative to right-camera:
193  const mrpt::poses::CPose3DQuat R2L = -params.camera_calib.rightCameraPose; // R2L = (-) Left-to-right_camera_pose
194 
195  // base_wrt_right_cam = ( (-)L2R ) (+) L2Base
196  //mrpt::poses::CPose3DQuat base_wrt_right_cam(mrpt::poses::UNINITIALIZED_POSE);
197  //base_wrt_right_cam.composeFrom(R2L,mrpt::poses::CPose3DQuat(base_pose_wrt_observer));
198 
199  double rx,ry,rz; // wrt cam (local coords)
200  //base_wrt_right_cam.composePoint(lx,ly,lz, rx,ry,rz);
201 
202  // xji_l_right = R2L (+) Xji_l
203  R2L.composePoint(lx,ly,lz, rx,ry,rz);
204  ASSERT_(rz!=0)
205 
206  // Pinhole model: Right camera.
207  const mrpt::utils::TCamera &rc = params.camera_calib.rightCamera;
208  pred_obs[2] = rc.cx() + rc.fx() * rx/rz;
209  pred_obs[3] = rc.cy() + rc.fy() * ry/rz;
210  out_obs_err = z_obs - pred_obs;
211  }
212 
213  /** Evaluates the partial Jacobian dh_dx:
214  * \code
215  * d h(x')
216  * dh_dx = -------------
217  * d x'
218  *
219  * \endcode
220  * With:
221  * - x' = x^{j,i}_l The relative location of the observed landmark wrt to the robot/camera at the instant of observation. (See notation on papers)
222  * - h(x): Observation model: h(): landmark location --> observation
223  *
224  * \param[out] dh_dx The output matrix Jacobian. Values at input are undefined (i.e. they cannot be asssumed to be zeros by default).
225  * \param[in] xji_l The relative location of the observed landmark wrt to the robot/camera at the instant of observation.
226  * \param[in] sensor_params Sensor-specific parameters, as set by the user.
227  *
228  * \return true if the Jacobian is well-defined, false to mark it as ill-defined and ignore it during this step of the optimization
229  */
230  static bool eval_jacob_dh_dx(
231  TJacobian_dh_dx & dh_dx,
232  const array_landmark_t & xji_l,
233  const TObservationParams & sensor_params)
234  {
235  // xji_l[0:2]=[X Y Z]
236  // If the point is behind us, mark this Jacobian as invalid. This is probably a temporary situation until we get closer to the optimum.
237  if (xji_l[2]<=0)
238  return false;
239 
240  // Left camera:
241  {
242  const double pz_inv = 1.0/xji_l[2];
243  const double pz_inv2 = pz_inv*pz_inv;
244 
245  const double cam_fx = sensor_params.camera_calib.leftCamera.fx();
246  const double cam_fy = sensor_params.camera_calib.leftCamera.fy();
247 
248  dh_dx.coeffRef(0,0)= cam_fx * pz_inv;
249  dh_dx.coeffRef(0,1)= 0;
250  dh_dx.coeffRef(0,2)= -cam_fx * xji_l[0] * pz_inv2;
251 
252  dh_dx.coeffRef(1,0)= 0;
253  dh_dx.coeffRef(1,1)= cam_fy * pz_inv;
254  dh_dx.coeffRef(1,2)= -cam_fy * xji_l[1] * pz_inv2;
255  }
256 
257  // Right camera:
258  array_landmark_t xji_l_right; // xji_l_right = R2L (+) Xji_l
259  const mrpt::poses::CPose3DQuat R2L = -sensor_params.camera_calib.rightCameraPose; // R2L = (-) Left-to-right_camera_pose
260  R2L.composePoint(
261  xji_l[0],xji_l[1],xji_l[2],
262  xji_l_right[0],xji_l_right[1],xji_l_right[2]);
263  {
264  const double pz_inv = 1.0/xji_l_right[2];
265  const double pz_inv2 = pz_inv*pz_inv;
266 
267  const double cam_fx = sensor_params.camera_calib.rightCamera.fx();
268  const double cam_fy = sensor_params.camera_calib.rightCamera.fy();
269 
270  dh_dx.coeffRef(2,0)= cam_fx * pz_inv;
271  dh_dx.coeffRef(2,1)= 0;
272  dh_dx.coeffRef(2,2)= -cam_fx * xji_l_right[0] * pz_inv2;
273 
274  dh_dx.coeffRef(3,0)= 0;
275  dh_dx.coeffRef(3,1)= cam_fy * pz_inv;
276  dh_dx.coeffRef(3,2)= -cam_fy * xji_l_right[1] * pz_inv2;
277  }
278 
279  return true;
280  }
281 
282  /** Inverse observation model for first-seen landmarks. Needed to avoid having landmarks at (0,0,0) which
283  * leads to undefined Jacobians. This is invoked only when both "unknown_relative_position_init_val" and "is_fixed" are "false"
284  * in an observation.
285  * The LM location must not be exact at all, just make sure it doesn't have an undefined Jacobian.
286  *
287  * \param[out] out_lm_pos The relative landmark position wrt the current observing KF.
288  * \param[in] obs The observation itself.
289  * \param[in] params The sensor-specific parameters.
290  */
291  static void inverse_sensor_model(
294  const OBS_T::TObservationParams & params)
295  {
296  // ¬ +Z
297  // /
298  // /
299  // +----> +X
300  // |
301  // |
302  // V +Y
303  //
304  const double fxl = params.camera_calib.leftCamera.fx();
305  const double fyl = params.camera_calib.leftCamera.fy();
306  const double cxl = params.camera_calib.leftCamera.cx();
307  const double cyl = params.camera_calib.leftCamera.cy();
308  const double disparity = std::max(0.001f, obs.left_px.x - obs.right_px.x);
309  const double baseline = params.camera_calib.rightCameraPose.x();
310  ASSERT_(baseline!=0)
311  const double Z = fxl*baseline/disparity;
312  out_lm_pos[0] = (obs.left_px.x - cxl)*Z/fxl;
313  out_lm_pos[1] = (obs.left_px.y - cyl)*Z/fyl;
314  out_lm_pos[2] = Z;
315  }
316 
317  }; // end of struct sensor_model<landmarks::Euclidean3D,observations::StereoCamera>
318 
319  // -------------------------------------------------------------------------------------------------------------
320 
321  /** Sensor model: 3D landmarks in Euclidean coordinates + Cartesian 3D observations */
322  template <>
323  struct sensor_model<landmarks::Euclidean3D,observations::Cartesian_3D>
324  {
325  // --------------------------------------------------------------------------------
326  // Typedefs for the sake of generality in the signature of methods below:
327  // *DONT FORGET* to change these when writing new sensor models.
328  // --------------------------------------------------------------------------------
331  // --------------------------------------------------------------------------------
332 
333  static const size_t OBS_DIMS = OBS_T::OBS_DIMS;
334  static const size_t LM_DIMS = LANDMARK_T::LM_DIMS;
335 
336  typedef Eigen::Matrix<double,OBS_DIMS,LM_DIMS> TJacobian_dh_dx; //!< A Jacobian of the correct size for each dh_dx
339 
340 
341  /** Executes the (negative) observation-error model: "-( h(lm_pos,pose) - z_obs)"
342  * \param[out] out_obs_err The output of the predicted sensor value
343  * \param[in] z_obs The real observation, to be contrasted to the prediction of this sensor model
344  * \param[in] base_pose_wrt_observer The relative pose of the observed landmark's base KF, wrt to the current sensor pose (which may be different than the observer KF pose if the sensor is not at the "robot origin").
345  * \param[in] lm_pos The relative landmark position wrt its base KF.
346  * \param[in] params The sensor-specific parameters.
347  */
348  template <class POSE_T>
349  static void observe_error(
352  const POSE_T & base_pose_wrt_observer,
354  const OBS_T::TObservationParams & params)
355  {
356  MRPT_UNUSED_PARAM(params);
357  double x,y,z; // wrt cam (local coords)
358  base_pose_wrt_observer.composePoint(lm_pos[0],lm_pos[1],lm_pos[2], x,y,z);
359 
360  observation_traits<OBS_T>::array_obs_t pred_obs; // prediction
361  // Observations are simply the "local coords":
362  pred_obs[0] = x; pred_obs[1] = y; pred_obs[2] = z;
363  out_obs_err = z_obs - pred_obs;
364  }
365 
366  /** Evaluates the partial Jacobian dh_dx:
367  * \code
368  * d h(x')
369  * dh_dx = -------------
370  * d x'
371  *
372  * \endcode
373  * With:
374  * - x' = x^{j,i}_l The relative location of the observed landmark wrt to the robot/camera at the instant of observation. (See notation on papers)
375  * - h(x): Observation model: h(): landmark location --> observation
376  *
377  * \param[out] dh_dx The output matrix Jacobian. Values at input are undefined (i.e. they cannot be asssumed to be zeros by default).
378  * \param[in] xji_l The relative location of the observed landmark wrt to the robot/camera at the instant of observation.
379  * \param[in] sensor_params Sensor-specific parameters, as set by the user.
380  *
381  * \return true if the Jacobian is well-defined, false to mark it as ill-defined and ignore it during this step of the optimization
382  */
383  static bool eval_jacob_dh_dx(
384  TJacobian_dh_dx & dh_dx,
385  const array_landmark_t & xji_l,
386  const TObservationParams & sensor_params)
387  {
388  MRPT_UNUSED_PARAM(xji_l); MRPT_UNUSED_PARAM(sensor_params);
389  // xji_l[0:2]=[X Y Z]
390  // This is probably the simplest Jacobian ever:
391  dh_dx.setIdentity();
392  return true;
393  }
394 
395  /** Inverse observation model for first-seen landmarks. Needed to avoid having landmarks at (0,0,0) which
396  * leads to undefined Jacobians. This is invoked only when both "unknown_relative_position_init_val" and "is_fixed" are "false"
397  * in an observation.
398  * The LM location must not be exact at all, just make sure it doesn't have an undefined Jacobian.
399  *
400  * \param[out] out_lm_pos The relative landmark position wrt the current observing KF.
401  * \param[in] obs The observation itself.
402  * \param[in] params The sensor-specific parameters.
403  */
404  static void inverse_sensor_model(
407  const OBS_T::TObservationParams & params)
408  {
409  MRPT_UNUSED_PARAM(params);
410  out_lm_pos[0] = obs.pt.x;
411  out_lm_pos[1] = obs.pt.y;
412  out_lm_pos[2] = obs.pt.z;
413  }
414 
415  }; // end of struct sensor_model<landmarks::Euclidean3D,observations::Cartesian_3D>
416 
417  // -------------------------------------------------------------------------------------------------------------
418 
419  /** Sensor model: 2D landmarks in Euclidean coordinates + Cartesian 2D observations */
420  template <>
421  struct sensor_model<landmarks::Euclidean2D,observations::Cartesian_2D>
422  {
423  // --------------------------------------------------------------------------------
424  // Typedefs for the sake of generality in the signature of methods below:
425  // *DONT FORGET* to change these when writing new sensor models.
426  // --------------------------------------------------------------------------------
429  // --------------------------------------------------------------------------------
430 
431  static const size_t OBS_DIMS = OBS_T::OBS_DIMS;
432  static const size_t LM_DIMS = LANDMARK_T::LM_DIMS;
433 
434  typedef Eigen::Matrix<double,OBS_DIMS,LM_DIMS> TJacobian_dh_dx; //!< A Jacobian of the correct size for each dh_dx
437 
438 
439  /** Executes the (negative) observation-error model: "-( h(lm_pos,pose) - z_obs)"
440  * \param[out] out_obs_err The output of the predicted sensor value
441  * \param[in] z_obs The real observation, to be contrasted to the prediction of this sensor model
442  * \param[in] base_pose_wrt_observer The relative pose of the observed landmark's base KF, wrt to the current sensor pose (which may be different than the observer KF pose if the sensor is not at the "robot origin").
443  * \param[in] lm_pos The relative landmark position wrt its base KF.
444  * \param[in] params The sensor-specific parameters.
445  */
446  template <class POSE_T>
447  static void observe_error(
450  const POSE_T & base_pose_wrt_observer,
452  const OBS_T::TObservationParams & params)
453  {
454  double x,y; // wrt cam (local coords)
455  base_pose_wrt_observer.composePoint(lm_pos[0],lm_pos[1], x,y);
456 
457  observation_traits<OBS_T>::array_obs_t pred_obs; // prediction
458  // Observations are simply the "local coords":
459  pred_obs[0] = x; pred_obs[1] = y;
460  out_obs_err = z_obs - pred_obs;
461  }
462 
463  /** Evaluates the partial Jacobian dh_dx:
464  * \code
465  * d h(x')
466  * dh_dx = -------------
467  * d x'
468  *
469  * \endcode
470  * With:
471  * - x' = x^{j,i}_l The relative location of the observed landmark wrt to the robot/camera at the instant of observation. (See notation on papers)
472  * - h(x): Observation model: h(): landmark location --> observation
473  *
474  * \param[out] dh_dx The output matrix Jacobian. Values at input are undefined (i.e. they cannot be asssumed to be zeros by default).
475  * \param[in] xji_l The relative location of the observed landmark wrt to the robot/camera at the instant of observation.
476  * \param[in] sensor_params Sensor-specific parameters, as set by the user.
477  *
478  * \return true if the Jacobian is well-defined, false to mark it as ill-defined and ignore it during this step of the optimization
479  */
480  static bool eval_jacob_dh_dx(
481  TJacobian_dh_dx & dh_dx,
482  const array_landmark_t & xji_l,
483  const TObservationParams & sensor_params)
484  {
485  MRPT_UNUSED_PARAM(xji_l); MRPT_UNUSED_PARAM(sensor_params);
486  // xji_l[0:1]=[X Y]
487  // This is probably the simplest Jacobian ever:
488  dh_dx.setIdentity();
489  return true;
490  }
491 
492  /** Inverse observation model for first-seen landmarks. Needed to avoid having landmarks at (0,0,0) which
493  * leads to undefined Jacobians. This is invoked only when both "unknown_relative_position_init_val" and "is_fixed" are "false"
494  * in an observation.
495  * The LM location must not be exact at all, just make sure it doesn't have an undefined Jacobian.
496  *
497  * \param[out] out_lm_pos The relative landmark position wrt the current observing KF.
498  * \param[in] obs The observation itself.
499  * \param[in] params The sensor-specific parameters.
500  */
501  static void inverse_sensor_model(
504  const OBS_T::TObservationParams & params)
505  {
506  MRPT_UNUSED_PARAM(params);
507  out_lm_pos[0] = obs.pt.x;
508  out_lm_pos[1] = obs.pt.y;
509  }
510 
511  }; // end of struct sensor_model<landmarks::Euclidean2D,observations::Cartesian_2D>
512 
513  // -------------------------------------------------------------------------------------------------------------
514 
515  /** Sensor model: 3D landmarks in Euclidean coordinates + 3D Range-Bearing observations */
516  template <>
517  struct sensor_model<landmarks::Euclidean3D,observations::RangeBearing_3D>
518  {
519  // --------------------------------------------------------------------------------
520  // Typedefs for the sake of generality in the signature of methods below:
521  // *DONT FORGET* to change these when writing new sensor models.
522  // --------------------------------------------------------------------------------
525  // --------------------------------------------------------------------------------
526 
527  static const size_t OBS_DIMS = OBS_T::OBS_DIMS;
528  static const size_t LM_DIMS = LANDMARK_T::LM_DIMS;
529 
530  typedef Eigen::Matrix<double,OBS_DIMS,LM_DIMS> TJacobian_dh_dx; //!< A Jacobian of the correct size for each dh_dx
533 
534 
535  /** Executes the (negative) observation-error model: "-( h(lm_pos,pose) - z_obs)"
536  * \param[out] out_obs_err The output of the predicted sensor value
537  * \param[in] z_obs The real observation, to be contrasted to the prediction of this sensor model
538  * \param[in] base_pose_wrt_observer The relative pose of the observed landmark's base KF, wrt to the current sensor pose (which may be different than the observer KF pose if the sensor is not at the "robot origin").
539  * \param[in] lm_pos The relative landmark position wrt its base KF.
540  * \param[in] params The sensor-specific parameters.
541  */
542  template <class POSE_T>
543  static void observe_error(
546  const POSE_T & base_pose_wrt_observer,
548  const OBS_T::TObservationParams & params)
549  {
550  mrpt::math::TPoint3D l; // wrt sensor (local coords)
551  base_pose_wrt_observer.composePoint(lm_pos[0],lm_pos[1],lm_pos[2], l.x,l.y,l.z);
552 
553  static const mrpt::poses::CPose3D origin;
554  double range,yaw,pitch;
555  origin.sphericalCoordinates(
556  l, // In: point
557  range,yaw,pitch // Out: spherical coords
558  );
559 
560  observation_traits<OBS_T>::array_obs_t pred_obs; // prediction
561  pred_obs[0] = range;
562  pred_obs[1] = yaw;
563  pred_obs[2] = pitch;
564  out_obs_err = z_obs - pred_obs;
565  }
566 
567  /** Evaluates the partial Jacobian dh_dx:
568  * \code
569  * d h(x')
570  * dh_dx = -------------
571  * d x'
572  *
573  * \endcode
574  * With:
575  * - x' = x^{j,i}_l The relative location of the observed landmark wrt to the robot/camera at the instant of observation. (See notation on papers)
576  * - h(x): Observation model: h(): landmark location --> observation
577  *
578  * \param[out] dh_dx The output matrix Jacobian. Values at input are undefined (i.e. they cannot be asssumed to be zeros by default).
579  * \param[in] xji_l The relative location of the observed landmark wrt to the robot/camera at the instant of observation.
580  * \param[in] sensor_params Sensor-specific parameters, as set by the user.
581  *
582  * \return true if the Jacobian is well-defined, false to mark it as ill-defined and ignore it during this step of the optimization
583  */
584  static bool eval_jacob_dh_dx(
585  TJacobian_dh_dx & dh_dx,
586  const array_landmark_t & xji_l,
587  const TObservationParams & sensor_params)
588  {
589  MRPT_UNUSED_PARAM(sensor_params);
590  // xji_l[0:2]=[X Y Z]
592 
593  static const mrpt::poses::CPose3DQuat origin;
594  double range,yaw,pitch;
595  origin.sphericalCoordinates(
596  mrpt::math::TPoint3D(xji_l[0],xji_l[1],xji_l[2]), // In: point
597  range,yaw,pitch, // Out: spherical coords
598  &dh_dx_, // dh_dx
599  NULL // dh_dp (not needed)
600  );
601 
602  dh_dx = dh_dx_;
603  return true;
604  }
605 
606  /** Inverse observation model for first-seen landmarks. Needed to avoid having landmarks at (0,0,0) which
607  * leads to undefined Jacobians. This is invoked only when both "unknown_relative_position_init_val" and "is_fixed" are "false"
608  * in an observation.
609  * The LM location must not be exact at all, just make sure it doesn't have an undefined Jacobian.
610  *
611  * \param[out] out_lm_pos The relative landmark position wrt the current observing KF.
612  * \param[in] obs The observation itself.
613  * \param[in] params The sensor-specific parameters.
614  */
615  static void inverse_sensor_model(
618  const OBS_T::TObservationParams & params)
619  {
620  MRPT_UNUSED_PARAM(params);
621  const double chn_y = cos(obs.yaw), shn_y = sin(obs.yaw);
622  const double chn_p = cos(obs.pitch), shn_p = sin(obs.pitch);
623  // The new point, relative to the sensor:
624  out_lm_pos[0] = obs.range * chn_y * chn_p;
625  out_lm_pos[1] = obs.range * shn_y * chn_p;
626  out_lm_pos[2] = -obs.range * shn_p;
627  }
628 
629  }; // end of struct sensor_model<landmarks::Euclidean3D,observations::RangeBearing_3D>
630 
631  // -------------------------------------------------------------------------------------------------------------
632 
633  /** Sensor model: 2D landmarks in Euclidean coordinates + 2D Range-Bearing observations */
634  template <>
635  struct sensor_model<landmarks::Euclidean2D,observations::RangeBearing_2D>
636  {
637  // --------------------------------------------------------------------------------
638  // Typedefs for the sake of generality in the signature of methods below:
639  // *DONT FORGET* to change these when writing new sensor models.
640  // --------------------------------------------------------------------------------
643  // --------------------------------------------------------------------------------
644 
645  static const size_t OBS_DIMS = OBS_T::OBS_DIMS;
646  static const size_t LM_DIMS = LANDMARK_T::LM_DIMS;
647 
648  typedef Eigen::Matrix<double,OBS_DIMS,LM_DIMS> TJacobian_dh_dx; //!< A Jacobian of the correct size for each dh_dx
651 
652 
653  /** Executes the (negative) observation-error model: "-( h(lm_pos,pose) - z_obs)"
654  * \param[out] out_obs_err The output of the predicted sensor value
655  * \param[in] z_obs The real observation, to be contrasted to the prediction of this sensor model
656  * \param[in] base_pose_wrt_observer The relative pose of the observed landmark's base KF, wrt to the current sensor pose (which may be different than the observer KF pose if the sensor is not at the "robot origin").
657  * \param[in] lm_pos The relative landmark position wrt its base KF.
658  * \param[in] params The sensor-specific parameters.
659  */
660  template <class POSE_T>
661  static void observe_error(
664  const POSE_T & base_pose_wrt_observer,
666  const OBS_T::TObservationParams & params)
667  {
668  MRPT_UNUSED_PARAM(params);
669  mrpt::math::TPoint2D l; // wrt sensor (local coords)
670  base_pose_wrt_observer.composePoint(lm_pos[0],lm_pos[1], l.x,l.y);
671 
672  const double range = hypot(l.x,l.y);
673  const double yaw = atan2(l.y,l.x);
674 
675  observation_traits<OBS_T>::array_obs_t pred_obs; // prediction
676  pred_obs[0] = range;
677  pred_obs[1] = yaw;
678  out_obs_err = z_obs - pred_obs;
679  }
680 
681  /** Evaluates the partial Jacobian dh_dx:
682  * \code
683  * d h(x')
684  * dh_dx = -------------
685  * d x'
686  *
687  * \endcode
688  * With:
689  * - x' = x^{j,i}_l The relative location of the observed landmark wrt to the robot/camera at the instant of observation. (See notation on papers)
690  * - h(x): Observation model: h(): landmark location --> observation
691  *
692  * \param[out] dh_dx The output matrix Jacobian. Values at input are undefined (i.e. they cannot be asssumed to be zeros by default).
693  * \param[in] xji_l The relative location of the observed landmark wrt to the robot/camera at the instant of observation.
694  * \param[in] sensor_params Sensor-specific parameters, as set by the user.
695  *
696  * \return true if the Jacobian is well-defined, false to mark it as ill-defined and ignore it during this step of the optimization
697  */
698  static bool eval_jacob_dh_dx(
699  TJacobian_dh_dx & dh_dx,
700  const array_landmark_t & xji_l,
701  const TObservationParams & sensor_params)
702  {
703  MRPT_UNUSED_PARAM(sensor_params);
704  // xji_l[0:1]=[X Y]
705  const double r = hypot(xji_l[0], xji_l[1]);
706  if (r==0) return false;
707 
708  const double r_inv = 1.0/r;
709  const double r_inv2 = r_inv*r_inv;
710  dh_dx(0,0) = xji_l[0] * r_inv;
711  dh_dx(0,1) = xji_l[1] * r_inv;
712  dh_dx(1,0) = -xji_l[1] * r_inv2;
713  dh_dx(1,1) = xji_l[0] * r_inv2;
714  return true;
715  }
716 
717  /** Inverse observation model for first-seen landmarks. Needed to avoid having landmarks at (0,0,0) which
718  * leads to undefined Jacobians. This is invoked only when both "unknown_relative_position_init_val" and "is_fixed" are "false"
719  * in an observation.
720  * The LM location must not be exact at all, just make sure it doesn't have an undefined Jacobian.
721  *
722  * \param[out] out_lm_pos The relative landmark position wrt the current observing KF.
723  * \param[in] obs The observation itself.
724  * \param[in] params The sensor-specific parameters.
725  */
726  static void inverse_sensor_model(
729  const OBS_T::TObservationParams & params)
730  {
731  MRPT_UNUSED_PARAM(params);
732  const double chn_y = cos(obs.yaw), shn_y = sin(obs.yaw);
733  // The new point, relative to the sensor:
734  out_lm_pos[0] = obs.range * chn_y;
735  out_lm_pos[1] = obs.range * shn_y;
736  }
737 
738  }; // end of sensor_model<landmarks::Euclidean2D,observations::RangeBearing_2D>
739 
740  // -------------------------------------------------------------------------------------------------------------
741 
742  /** Sensor model: 2D relative poses landmarks and observations (relative 2D-graph SLAM) */
743  template <>
744  struct sensor_model<landmarks::RelativePoses2D,observations::RelativePoses_2D>
745  {
746  // --------------------------------------------------------------------------------
747  // Typedefs for the sake of generality in the signature of methods below:
748  // *DONT FORGET* to change these when writing new sensor models.
749  // --------------------------------------------------------------------------------
752  // --------------------------------------------------------------------------------
753 
754  static const size_t OBS_DIMS = OBS_T::OBS_DIMS;
755  static const size_t LM_DIMS = LANDMARK_T::LM_DIMS;
756 
757  typedef Eigen::Matrix<double,OBS_DIMS,LM_DIMS> TJacobian_dh_dx; //!< A Jacobian of the correct size for each dh_dx
760 
761 
762  /** Executes the (negative) observation-error model: "-( h(lm_pos,pose) - z_obs)"
763  * \param[out] out_obs_err The output of the predicted sensor value
764  * \param[in] z_obs The real observation, to be contrasted to the prediction of this sensor model
765  * \param[in] base_pose_wrt_observer The relative pose of the observed landmark's base KF, wrt to the current sensor pose (which may be different than the observer KF pose if the sensor is not at the "robot origin").
766  * \param[in] lm_pos The relative landmark position wrt its base KF.
767  * \param[in] params The sensor-specific parameters.
768  */
769  template <class POSE_T>
770  static void observe_error(
773  const POSE_T & base_pose_wrt_observer,
775  const OBS_T::TObservationParams & params)
776  {
777  MRPT_UNUSED_PARAM(lm_pos); MRPT_UNUSED_PARAM(params);
778  // Relative pose observation:
779  // OUT_OBS_ERR = - pseudo-log( PREDICTED_REL_POSE \ominus Z_OBS )
780  const POSE_T h = POSE_T(z_obs[0],z_obs[1],z_obs[2]) - base_pose_wrt_observer;
781 
782  out_obs_err[0] = h.x();
783  out_obs_err[1] = h.y();
784  out_obs_err[2] = h.phi();
785  }
786 
787  /** Evaluates the partial Jacobian dh_dx:
788  * \code
789  * d h(x')
790  * dh_dx = -------------
791  * d x'
792  *
793  * \endcode
794  * With:
795  * - x' = x^{j,i}_l The relative location of the observed landmark wrt to the robot/camera at the instant of observation. (See notation on papers)
796  * - h(x): Observation model: h(): landmark location --> observation
797  *
798  * \param[out] dh_dx The output matrix Jacobian. Values at input are undefined (i.e. they cannot be asssumed to be zeros by default).
799  * \param[in] xji_l The relative location of the observed landmark wrt to the robot/camera at the instant of observation.
800  * \param[in] sensor_params Sensor-specific parameters, as set by the user.
801  *
802  * \return true if the Jacobian is well-defined, false to mark it as ill-defined and ignore it during this step of the optimization
803  */
804  static bool eval_jacob_dh_dx(
805  TJacobian_dh_dx & dh_dx,
806  const array_landmark_t & xji_l,
807  const TObservationParams & sensor_params)
808  {
809  MRPT_UNUSED_PARAM(xji_l); MRPT_UNUSED_PARAM(sensor_params);
810  // h(z_obs \ominus p) = pseudo-log(z_obs \ominus p)
811  // with p: relative pose in SE(2)
812  dh_dx.setIdentity();
813  return true;
814  }
815 
816  /** Inverse observation model for first-seen landmarks. Needed to avoid having landmarks at (0,0,0) which
817  * leads to undefined Jacobians. This is invoked only when both "unknown_relative_position_init_val" and "is_fixed" are "false"
818  * in an observation.
819  * The LM location must not be exact at all, just make sure it doesn't have an undefined Jacobian.
820  *
821  * \param[out] out_lm_pos The relative landmark position wrt the current observing KF.
822  * \param[in] obs The observation itself.
823  * \param[in] params The sensor-specific parameters.
824  */
825  static void inverse_sensor_model(
828  const OBS_T::TObservationParams & params)
829  {
830  MRPT_UNUSED_PARAM(params);
831  out_lm_pos[0] = obs.x;
832  out_lm_pos[1] = obs.y;
833  out_lm_pos[2] = obs.yaw;
834  }
835 
836  }; // end of sensor_model<landmarks::RelativePoses2D,observations::RelativePoses_2D>
837 
838  // -------------------------------------------------------------------------------------------------------------
839 
840  /** Sensor model: 3D relative poses landmarks and observations (relative 3D-graph SLAM) */
841  template <>
842  struct sensor_model<landmarks::RelativePoses3D,observations::RelativePoses_3D>
843  {
844  // --------------------------------------------------------------------------------
845  // Typedefs for the sake of generality in the signature of methods below:
846  // *DONT FORGET* to change these when writing new sensor models.
847  // --------------------------------------------------------------------------------
850  // --------------------------------------------------------------------------------
851 
852  static const size_t OBS_DIMS = OBS_T::OBS_DIMS;
853  static const size_t LM_DIMS = LANDMARK_T::LM_DIMS;
854 
855  typedef Eigen::Matrix<double,OBS_DIMS,LM_DIMS> TJacobian_dh_dx; //!< A Jacobian of the correct size for each dh_dx
858 
859 
860  /** Executes the (negative) observation-error model: "-( h(lm_pos,pose) - z_obs)"
861  * \param[out] out_obs_err The output of the predicted sensor value
862  * \param[in] z_obs The real observation, to be contrasted to the prediction of this sensor model
863  * \param[in] base_pose_wrt_observer The relative pose of the observed landmark's base KF, wrt to the current sensor pose (which may be different than the observer KF pose if the sensor is not at the "robot origin").
864  * \param[in] lm_pos The relative landmark position wrt its base KF.
865  * \param[in] params The sensor-specific parameters.
866  */
867  template <class POSE_T>
868  static void observe_error(
871  const POSE_T & base_pose_wrt_observer,
873  const OBS_T::TObservationParams & params)
874  {
875  // Relative pose observation:
876  // OUT_OBS_ERR = - pseudo-log( PREDICTED_REL_POSE \ominus Z_OBS )
877  const POSE_T h = POSE_T(z_obs[0],z_obs[1],z_obs[2],z_obs[3],z_obs[4],z_obs[5]) - base_pose_wrt_observer;
878 
880  }
881 
882  /** Evaluates the partial Jacobian dh_dx:
883  * \code
884  * d h(x')
885  * dh_dx = -------------
886  * d x'
887  *
888  * \endcode
889  * With:
890  * - x' = x^{j,i}_l The relative location of the observed landmark wrt to the robot/camera at the instant of observation. (See notation on papers)
891  * - h(x): Observation model: h(): landmark location --> observation
892  *
893  * \param[out] dh_dx The output matrix Jacobian. Values at input are undefined (i.e. they cannot be asssumed to be zeros by default).
894  * \param[in] xji_l The relative location of the observed landmark wrt to the robot/camera at the instant of observation.
895  * \param[in] sensor_params Sensor-specific parameters, as set by the user.
896  *
897  * \return true if the Jacobian is well-defined, false to mark it as ill-defined and ignore it during this step of the optimization
898  */
899  static bool eval_jacob_dh_dx(
900  TJacobian_dh_dx & dh_dx,
901  const array_landmark_t & xji_l,
902  const TObservationParams & sensor_params)
903  {
904  MRPT_UNUSED_PARAM(xji_l); MRPT_UNUSED_PARAM(sensor_params);
905  // h(z_obs \ominus p) = xji_l (the relative pose in SE(3))
906  dh_dx.setIdentity();
907  return true;
908  }
909 
910  /** Inverse observation model for first-seen landmarks. Needed to avoid having landmarks at (0,0,0) which
911  * leads to undefined Jacobians. This is invoked only when both "unknown_relative_position_init_val" and "is_fixed" are "false"
912  * in an observation.
913  * The LM location must not be exact at all, just make sure it doesn't have an undefined Jacobian.
914  *
915  * \param[out] out_lm_pos The relative landmark position wrt the current observing KF.
916  * \param[in] obs The observation itself.
917  * \param[in] params The sensor-specific parameters.
918  */
919  static void inverse_sensor_model(
922  const OBS_T::TObservationParams & params)
923  {
924  MRPT_UNUSED_PARAM(params);
925  out_lm_pos[0] = obs.x; out_lm_pos[1] = obs.y; out_lm_pos[2] = obs.z;
926  out_lm_pos[3] = obs.yaw; out_lm_pos[4] = obs.pitch; out_lm_pos[5] = obs.roll;
927  }
928 
929  }; // end of struct sensor_model<landmarks::RelativePoses3D,observations::RelativePoses_3D>
930 
931  // -------------------------------------------------------------------------------------------------------------
932 
933  /** @} */
934 
935 } } // end NS
landmark_traits< LANDMARK_T >::array_landmark_t array_landmark_t
a 2D or 3D point
Definition: sensors.h:531
A parameterization of SE(3) relative poses ("fake landmarks" to emulate graph-SLAM) ...
Definition: landmarks.h:124
A parameterization of SE(2) relative poses ("fake landmarks" to emulate graph-SLAM) ...
Definition: landmarks.h:94
landmark_traits< LANDMARK_T >::array_landmark_t array_landmark_t
a 2D or 3D point
Definition: sensors.h:758
Observation = one monocular camera feature (the coordinates of one pixel)
Definition: observations.h:25
double y
X,Y coordinates.
landmark_traits< LANDMARK_T >::array_landmark_t array_landmark_t
a 2D or 3D point
Definition: sensors.h:337
Eigen::Matrix< double, OBS_DIMS, LM_DIMS > TJacobian_dh_dx
A Jacobian of the correct size for each dh_dx.
Definition: sensors.h:530
The type "TObservationParams" must be declared in each "observations::TYPE" to hold sensor-specific p...
Definition: observations.h:183
landmark_traits< LANDMARK_T >::array_landmark_t array_landmark_t
a 2D or 3D point
Definition: sensors.h:649
void sphericalCoordinates(const mrpt::math::TPoint3D &point, double &out_range, double &out_yaw, double &out_pitch) const
Computes the spherical coordinates of a 3D point as seen from the 6D pose specified by this object...
The type "TObservationParams" must be declared in each "observations::TYPE" to hold sensor-specific p...
Definition: observations.h:126
static void observe_error(observation_traits< OBS_T >::array_obs_t &out_obs_err, const observation_traits< OBS_T >::array_obs_t &z_obs, const POSE_T &base_pose_wrt_observer, const landmark_traits< LANDMARK_T >::array_landmark_t &lm_pos, const OBS_T::TObservationParams &params)
Executes the (negative) observation-error model: "-( h(lm_pos,pose) - z_obs)".
Definition: sensors.h:770
static void observe_error(observation_traits< OBS_T >::array_obs_t &out_obs_err, const observation_traits< OBS_T >::array_obs_t &z_obs, const POSE_T &base_pose_wrt_observer, const landmark_traits< LANDMARK_T >::array_landmark_t &lm_pos, const OBS_T::TObservationParams &params)
Executes the (negative) observation-error model: "-( h(lm_pos,pose) - z_obs)".
Definition: sensors.h:50
static bool eval_jacob_dh_dx(TJacobian_dh_dx &dh_dx, const array_landmark_t &xji_l, const TObservationParams &sensor_params)
Evaluates the partial Jacobian dh_dx:
Definition: sensors.h:383
static void inverse_sensor_model(landmark_traits< LANDMARK_T >::array_landmark_t &out_lm_pos, const observation_traits< OBS_T >::obs_data_t &obs, const OBS_T::TObservationParams &params)
Inverse observation model for first-seen landmarks.
Definition: sensors.h:121
static void inverse_sensor_model(landmark_traits< LANDMARK_T >::array_landmark_t &out_lm_pos, const observation_traits< OBS_T >::obs_data_t &obs, const OBS_T::TObservationParams &params)
Inverse observation model for first-seen landmarks.
Definition: sensors.h:825
static void inverse_sensor_model(landmark_traits< LANDMARK_T >::array_landmark_t &out_lm_pos, const observation_traits< OBS_T >::obs_data_t &obs, const OBS_T::TObservationParams &params)
Inverse observation model for first-seen landmarks.
Definition: sensors.h:726
Eigen::Matrix< double, OBS_DIMS, LM_DIMS > TJacobian_dh_dx
A Jacobian of the correct size for each dh_dx.
Definition: sensors.h:855
Eigen::Matrix< double, OBS_DIMS, LM_DIMS > TJacobian_dh_dx
A Jacobian of the correct size for each dh_dx.
Definition: sensors.h:434
static void inverse_sensor_model(landmark_traits< LANDMARK_T >::array_landmark_t &out_lm_pos, const observation_traits< OBS_T >::obs_data_t &obs, const OBS_T::TObservationParams &params)
Inverse observation model for first-seen landmarks.
Definition: sensors.h:501
double z
X,Y,Z coordinates.
static void inverse_sensor_model(landmark_traits< LANDMARK_T >::array_landmark_t &out_lm_pos, const observation_traits< OBS_T >::obs_data_t &obs, const OBS_T::TObservationParams &params)
Inverse observation model for first-seen landmarks.
Definition: sensors.h:919
static void inverse_sensor_model(landmark_traits< LANDMARK_T >::array_landmark_t &out_lm_pos, const observation_traits< OBS_T >::obs_data_t &obs, const OBS_T::TObservationParams &params)
Inverse observation model for first-seen landmarks.
Definition: sensors.h:404
The type "TObservationParams" must be declared in each "observations::TYPE" to hold sensor-specific p...
Definition: observations.h:99
The type "TObservationParams" must be declared in each "observations::TYPE" to hold sensor-specific p...
Definition: observations.h:240
landmark_traits< LANDMARK_T >::array_landmark_t array_landmark_t
a 2D or 3D point
Definition: sensors.h:856
double fy() const
Get the value of the focal length y-value (in pixels).
Definition: TCamera.h:155
A numeric matrix of compile-time fixed size.
double x() const
Common members of all points & poses classes.
Definition: CPoseOrPoint.h:113
Generic declaration, of which specializations are defined for each combination of LM+OBS type...
Definition: srba_types.h:44
static void observe_error(observation_traits< OBS_T >::array_obs_t &out_obs_err, const observation_traits< OBS_T >::array_obs_t &z_obs, const POSE_T &base_pose_wrt_observer, const landmark_traits< LANDMARK_T >::array_landmark_t &lm_pos, const OBS_T::TObservationParams &params)
Executes the (negative) observation-error model: "-( h(lm_pos,pose) - z_obs)".
Definition: sensors.h:349
#define MRPT_UNUSED_PARAM(a)
Can be used to avoid "not used parameters" warnings from the compiler.
landmark_traits< LANDMARK_T >::array_landmark_t array_landmark_t
a 2D or 3D point
Definition: sensors.h:435
void sphericalCoordinates(const mrpt::math::TPoint3D &point, double &out_range, double &out_yaw, double &out_pitch, mrpt::math::CMatrixFixedNumeric< double, 3, 3 > *out_jacob_dryp_dpoint=NULL, mrpt::math::CMatrixFixedNumeric< double, 3, 7 > *out_jacob_dryp_dpose=NULL) const
Computes the spherical coordinates of a 3D point as seen from the 6D pose specified by this object...
Observation = XY coordinates of landmarks relative to the sensor.
Definition: observations.h:108
TCamera rightCamera
Intrinsic and distortion parameters of the left and right cameras.
Definition: TStereoCamera.h:29
Observation = XYZ coordinates of landmarks relative to the sensor.
Definition: observations.h:81
static void observe_error(observation_traits< OBS_T >::array_obs_t &out_obs_err, const observation_traits< OBS_T >::array_obs_t &z_obs, const POSE_T &base_pose_wrt_observer, const landmark_traits< LANDMARK_T >::array_landmark_t &lm_pos, const OBS_T::TObservationParams &params)
Executes the (negative) observation-error model: "-( h(lm_pos,pose) - z_obs)".
Definition: sensors.h:175
The type "TObservationParams" must be declared in each "observations::TYPE" to hold sensor-specific p...
Definition: observations.h:211
Eigen::Matrix< double, OBS_DIMS, LM_DIMS > TJacobian_dh_dx
A Jacobian of the correct size for each dh_dx.
Definition: sensors.h:162
static void observe_error(observation_traits< OBS_T >::array_obs_t &out_obs_err, const observation_traits< OBS_T >::array_obs_t &z_obs, const POSE_T &base_pose_wrt_observer, const landmark_traits< LANDMARK_T >::array_landmark_t &lm_pos, const OBS_T::TObservationParams &params)
Executes the (negative) observation-error model: "-( h(lm_pos,pose) - z_obs)".
Definition: sensors.h:447
static bool eval_jacob_dh_dx(TJacobian_dh_dx &dh_dx, const array_landmark_t &xji_l, const TObservationParams &sensor_params)
Evaluates the partial Jacobian dh_dx:
Definition: sensors.h:584
A class used to store a 3D pose as a translation (x,y,z) and a quaternion (qr,qx,qy,qz).
Definition: CPose3DQuat.h:41
static bool eval_jacob_dh_dx(TJacobian_dh_dx &dh_dx, const array_landmark_t &xji_l, const TObservationParams &sensor_params)
Evaluates the partial Jacobian dh_dx:
Definition: sensors.h:804
void composePoint(const double lx, const double ly, const double lz, double &gx, double &gy, double &gz, mrpt::math::CMatrixFixedNumeric< double, 3, 3 > *out_jacobian_df_dpoint=NULL, mrpt::math::CMatrixFixedNumeric< double, 3, 7 > *out_jacobian_df_dpose=NULL) const
Computes the 3D point G such as .
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
Eigen::Matrix< double, OBS_DIMS, LM_DIMS > TJacobian_dh_dx
A Jacobian of the correct size for each dh_dx.
Definition: sensors.h:336
Eigen::Matrix< double, OBS_DIMS, LM_DIMS > TJacobian_dh_dx
A Jacobian of the correct size for each dh_dx.
Definition: sensors.h:757
static void inverse_sensor_model(landmark_traits< LANDMARK_T >::array_landmark_t &out_lm_pos, const observation_traits< OBS_T >::obs_data_t &obs, const OBS_T::TObservationParams &params)
Inverse observation model for first-seen landmarks.
Definition: sensors.h:291
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
Definition: CPose3D.h:69
static void observe_error(observation_traits< OBS_T >::array_obs_t &out_obs_err, const observation_traits< OBS_T >::array_obs_t &z_obs, const POSE_T &base_pose_wrt_observer, const landmark_traits< LANDMARK_T >::array_landmark_t &lm_pos, const OBS_T::TObservationParams &params)
Executes the (negative) observation-error model: "-( h(lm_pos,pose) - z_obs)".
Definition: sensors.h:868
Observation = Relative SE(3) poses (x,y,z,yaw,pitch,roll)
Definition: observations.h:220
A parameterization of landmark positions in Euclidean coordinates (2D)
Definition: landmarks.h:58
Observation = Relative SE(2) poses (x,y,yaw)
Definition: observations.h:192
A parameterization of landmark positions in Euclidean coordinates (3D)
Definition: landmarks.h:25
#define ASSERT_(f)
static bool eval_jacob_dh_dx(TJacobian_dh_dx &dh_dx, const array_landmark_t &xji_l, const TObservationParams &sensor_params)
Evaluates the partial Jacobian dh_dx:
Definition: sensors.h:85
Eigen::Matrix< double, OBS_DIMS, LM_DIMS > TJacobian_dh_dx
A Jacobian of the correct size for each dh_dx.
Definition: sensors.h:648
static bool eval_jacob_dh_dx(TJacobian_dh_dx &dh_dx, const array_landmark_t &xji_l, const TObservationParams &sensor_params)
Evaluates the partial Jacobian dh_dx:
Definition: sensors.h:230
double fx() const
Get the value of the focal length x-value (in pixels).
Definition: TCamera.h:153
static void inverse_sensor_model(landmark_traits< LANDMARK_T >::array_landmark_t &out_lm_pos, const observation_traits< OBS_T >::obs_data_t &obs, const OBS_T::TObservationParams &params)
Inverse observation model for first-seen landmarks.
Definition: sensors.h:615
static void pseudo_ln(const CPose3D &P, array_t &x)
A pseudo-Logarithm map in SE(3), where the output = [X,Y,Z, Ln(ROT)], that is, the normal SO(3) logar...
static bool eval_jacob_dh_dx(TJacobian_dh_dx &dh_dx, const array_landmark_t &xji_l, const TObservationParams &sensor_params)
Evaluates the partial Jacobian dh_dx:
Definition: sensors.h:899
static bool eval_jacob_dh_dx(TJacobian_dh_dx &dh_dx, const array_landmark_t &xji_l, const TObservationParams &sensor_params)
Evaluates the partial Jacobian dh_dx:
Definition: sensors.h:480
Lightweight 3D point.
Observation = one stereo camera feature (the coordinates of two pixels)
Definition: observations.h:53
Lightweight 2D point.
double cx() const
Get the value of the principal point x-coordinate (in pixels).
Definition: TCamera.h:149
The type "TObservationParams" must be declared in each "observations::TYPE" to hold sensor-specific p...
Definition: observations.h:155
The type "TObservationParams" must be declared in each "observations::TYPE" to hold sensor-specific p...
Definition: observations.h:44
static void observe_error(observation_traits< OBS_T >::array_obs_t &out_obs_err, const observation_traits< OBS_T >::array_obs_t &z_obs, const POSE_T &base_pose_wrt_observer, const landmark_traits< LANDMARK_T >::array_landmark_t &lm_pos, const OBS_T::TObservationParams &params)
Executes the (negative) observation-error model: "-( h(lm_pos,pose) - z_obs)".
Definition: sensors.h:543
static void observe_error(observation_traits< OBS_T >::array_obs_t &out_obs_err, const observation_traits< OBS_T >::array_obs_t &z_obs, const POSE_T &base_pose_wrt_observer, const landmark_traits< LANDMARK_T >::array_landmark_t &lm_pos, const OBS_T::TObservationParams &params)
Executes the (negative) observation-error model: "-( h(lm_pos,pose) - z_obs)".
Definition: sensors.h:661
static bool eval_jacob_dh_dx(TJacobian_dh_dx &dh_dx, const array_landmark_t &xji_l, const TObservationParams &sensor_params)
Evaluates the partial Jacobian dh_dx:
Definition: sensors.h:698
mrpt::poses::CPose3DQuat rightCameraPose
Pose of the right camera with respect to the coordinate origin of the left camera.
Definition: TStereoCamera.h:30
Structure to hold the parameters of a pinhole camera model.
Definition: TCamera.h:31
landmark_traits< LANDMARK_T >::array_landmark_t array_landmark_t
a 2D or 3D point
Definition: sensors.h:163
Observation = Range+Bearing (yaw & pitch) of landmarks relative to the sensor.
Definition: observations.h:135
landmark_traits< LANDMARK_T >::array_landmark_t array_landmark_t
a 2D or 3D point
Definition: sensors.h:38
Observation = Range+Bearing (yaw) of landmarks relative to the sensor, for planar environments only...
Definition: observations.h:164
The type "TObservationParams" must be declared in each "observations::TYPE" to hold sensor-specific p...
Definition: observations.h:72
double cy() const
Get the value of the principal point y-coordinate (in pixels).
Definition: TCamera.h:151
Eigen::Matrix< double, OBS_DIMS, LM_DIMS > TJacobian_dh_dx
A Jacobian of the correct size for each dh_dx.
Definition: sensors.h:37



Page generated by Doxygen 1.8.9.1 for MRPT 1.3.0 SVN: at Sun Sep 13 03:55:12 UTC 2015