14 namespace mrpt {
namespace srba {
34 static const size_t OBS_DIMS = OBS_T::OBS_DIMS;
35 static const size_t LM_DIMS = LANDMARK_T::LM_DIMS;
49 template <
class POSE_T>
53 const POSE_T & base_pose_wrt_observer,
58 base_pose_wrt_observer.composePoint(lm_pos[0],lm_pos[1],lm_pos[2], x,y,z);
65 out_obs_err = z_obs - pred_obs;
86 TJacobian_dh_dx & dh_dx,
87 const array_landmark_t & xji_l,
88 const TObservationParams & sensor_params)
95 const double pz_inv = 1.0/xji_l[2];
96 const double pz_inv2 = pz_inv*pz_inv;
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;
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;
138 out_lm_pos[0] = (obs.px.x-cx)/fx;
139 out_lm_pos[1] = (obs.px.y-cy)/fy;
159 static const size_t OBS_DIMS = OBS_T::OBS_DIMS;
160 static const size_t LM_DIMS = LANDMARK_T::LM_DIMS;
174 template <
class POSE_T>
178 const POSE_T & base_pose_wrt_observer,
183 base_pose_wrt_observer.composePoint(lm_pos[0],lm_pos[1],lm_pos[2], lx,ly,lz);
189 pred_obs[0] = lc.
cx() + lc.
fx() * lx/lz;
190 pred_obs[1] = lc.
cy() + lc.
fy() * ly/lz;
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;
231 TJacobian_dh_dx & dh_dx,
232 const array_landmark_t & xji_l,
233 const TObservationParams & sensor_params)
242 const double pz_inv = 1.0/xji_l[2];
243 const double pz_inv2 = pz_inv*pz_inv;
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;
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;
258 array_landmark_t xji_l_right;
261 xji_l[0],xji_l[1],xji_l[2],
262 xji_l_right[0],xji_l_right[1],xji_l_right[2]);
264 const double pz_inv = 1.0/xji_l_right[2];
265 const double pz_inv2 = pz_inv*pz_inv;
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;
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;
308 const double disparity = std::max(0.001f, obs.left_px.x - obs.right_px.x);
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;
333 static const size_t OBS_DIMS = OBS_T::OBS_DIMS;
334 static const size_t LM_DIMS = LANDMARK_T::LM_DIMS;
348 template <
class POSE_T>
352 const POSE_T & base_pose_wrt_observer,
358 base_pose_wrt_observer.composePoint(lm_pos[0],lm_pos[1],lm_pos[2], x,y,z);
362 pred_obs[0] = x; pred_obs[1] = y; pred_obs[2] = z;
363 out_obs_err = z_obs - pred_obs;
384 TJacobian_dh_dx & dh_dx,
385 const array_landmark_t & xji_l,
386 const TObservationParams & sensor_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;
431 static const size_t OBS_DIMS = OBS_T::OBS_DIMS;
432 static const size_t LM_DIMS = LANDMARK_T::LM_DIMS;
446 template <
class POSE_T>
450 const POSE_T & base_pose_wrt_observer,
455 base_pose_wrt_observer.composePoint(lm_pos[0],lm_pos[1], x,y);
459 pred_obs[0] = x; pred_obs[1] = y;
460 out_obs_err = z_obs - pred_obs;
481 TJacobian_dh_dx & dh_dx,
482 const array_landmark_t & xji_l,
483 const TObservationParams & sensor_params)
507 out_lm_pos[0] = obs.pt.x;
508 out_lm_pos[1] = obs.pt.y;
527 static const size_t OBS_DIMS = OBS_T::OBS_DIMS;
528 static const size_t LM_DIMS = LANDMARK_T::LM_DIMS;
542 template <
class POSE_T>
546 const POSE_T & base_pose_wrt_observer,
551 base_pose_wrt_observer.composePoint(lm_pos[0],lm_pos[1],lm_pos[2], l.
x,l.
y,l.
z);
554 double range,yaw,pitch;
564 out_obs_err = z_obs - pred_obs;
585 TJacobian_dh_dx & dh_dx,
586 const array_landmark_t & xji_l,
587 const TObservationParams & sensor_params)
594 double range,yaw,pitch;
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);
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;
645 static const size_t OBS_DIMS = OBS_T::OBS_DIMS;
646 static const size_t LM_DIMS = LANDMARK_T::LM_DIMS;
660 template <
class POSE_T>
664 const POSE_T & base_pose_wrt_observer,
670 base_pose_wrt_observer.composePoint(lm_pos[0],lm_pos[1], l.
x,l.
y);
672 const double range = hypot(l.
x,l.
y);
673 const double yaw = atan2(l.
y,l.
x);
678 out_obs_err = z_obs - pred_obs;
699 TJacobian_dh_dx & dh_dx,
700 const array_landmark_t & xji_l,
701 const TObservationParams & sensor_params)
705 const double r = hypot(xji_l[0], xji_l[1]);
706 if (r==0)
return false;
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;
732 const double chn_y = cos(obs.yaw), shn_y = sin(obs.yaw);
734 out_lm_pos[0] = obs.range * chn_y;
735 out_lm_pos[1] = obs.range * shn_y;
754 static const size_t OBS_DIMS = OBS_T::OBS_DIMS;
755 static const size_t LM_DIMS = LANDMARK_T::LM_DIMS;
769 template <
class POSE_T>
773 const POSE_T & base_pose_wrt_observer,
780 const POSE_T h = POSE_T(z_obs[0],z_obs[1],z_obs[2]) - base_pose_wrt_observer;
782 out_obs_err[0] = h.x();
783 out_obs_err[1] = h.y();
784 out_obs_err[2] = h.phi();
805 TJacobian_dh_dx & dh_dx,
806 const array_landmark_t & xji_l,
807 const TObservationParams & sensor_params)
831 out_lm_pos[0] = obs.x;
832 out_lm_pos[1] = obs.y;
833 out_lm_pos[2] = obs.yaw;
852 static const size_t OBS_DIMS = OBS_T::OBS_DIMS;
853 static const size_t LM_DIMS = LANDMARK_T::LM_DIMS;
867 template <
class POSE_T>
871 const POSE_T & base_pose_wrt_observer,
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;
900 TJacobian_dh_dx & dh_dx,
901 const array_landmark_t & xji_l,
902 const TObservationParams & sensor_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;
landmark_traits< LANDMARK_T >::array_landmark_t array_landmark_t
a 2D or 3D point
A parameterization of SE(3) relative poses ("fake landmarks" to emulate graph-SLAM) ...
A parameterization of SE(2) relative poses ("fake landmarks" to emulate graph-SLAM) ...
landmark_traits< LANDMARK_T >::array_landmark_t array_landmark_t
a 2D or 3D point
Observation = one monocular camera feature (the coordinates of one pixel)
landmark_traits< LANDMARK_T >::array_landmark_t array_landmark_t
a 2D or 3D point
Eigen::Matrix< double, OBS_DIMS, LM_DIMS > TJacobian_dh_dx
A Jacobian of the correct size for each dh_dx.
The type "TObservationParams" must be declared in each "observations::TYPE" to hold sensor-specific p...
landmark_traits< LANDMARK_T >::array_landmark_t array_landmark_t
a 2D or 3D point
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...
OBS_T::TObservationParams TObservationParams
The type "TObservationParams" must be declared in each "observations::TYPE" to hold sensor-specific p...
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 ¶ms)
Executes the (negative) observation-error model: "-( h(lm_pos,pose) - z_obs)".
OBS_T::TObservationParams TObservationParams
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 ¶ms)
Executes the (negative) observation-error model: "-( h(lm_pos,pose) - z_obs)".
OBS_T::TObservationParams TObservationParams
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:
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 ¶ms)
Inverse observation model for first-seen landmarks.
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 ¶ms)
Inverse observation model for first-seen landmarks.
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 ¶ms)
Inverse observation model for first-seen landmarks.
Eigen::Matrix< double, OBS_DIMS, LM_DIMS > TJacobian_dh_dx
A Jacobian of the correct size for each dh_dx.
OBS_T::TObservationParams TObservationParams
Eigen::Matrix< double, OBS_DIMS, LM_DIMS > TJacobian_dh_dx
A Jacobian of the correct size for each dh_dx.
OBS_T::TObservationParams TObservationParams
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 ¶ms)
Inverse observation model for first-seen landmarks.
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 ¶ms)
Inverse observation model for first-seen landmarks.
observations::MonocularCamera OBS_T
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 ¶ms)
Inverse observation model for first-seen landmarks.
The type "TObservationParams" must be declared in each "observations::TYPE" to hold sensor-specific p...
The type "TObservationParams" must be declared in each "observations::TYPE" to hold sensor-specific p...
landmark_traits< LANDMARK_T >::array_landmark_t array_landmark_t
a 2D or 3D point
landmarks::Euclidean3D LANDMARK_T
observations::RelativePoses_3D OBS_T
mrpt::utils::TStereoCamera camera_calib
double fy() const
Get the value of the focal length y-value (in pixels).
A numeric matrix of compile-time fixed size.
double x() const
Common members of all points & poses classes.
Generic declaration, of which specializations are defined for each combination of LM+OBS type...
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 ¶ms)
Executes the (negative) observation-error model: "-( h(lm_pos,pose) - z_obs)".
observations::RelativePoses_2D OBS_T
#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
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.
observations::Cartesian_2D OBS_T
TCamera rightCamera
Intrinsic and distortion parameters of the left and right cameras.
Observation = XYZ coordinates of landmarks relative to the sensor.
landmarks::Euclidean3D LANDMARK_T
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 ¶ms)
Executes the (negative) observation-error model: "-( h(lm_pos,pose) - z_obs)".
The type "TObservationParams" must be declared in each "observations::TYPE" to hold sensor-specific p...
landmarks::Euclidean2D LANDMARK_T
Eigen::Matrix< double, OBS_DIMS, LM_DIMS > TJacobian_dh_dx
A Jacobian of the correct size for each dh_dx.
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 ¶ms)
Executes the (negative) observation-error model: "-( h(lm_pos,pose) - z_obs)".
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:
A class used to store a 3D pose as a translation (x,y,z) and a quaternion (qr,qx,qy,qz).
landmarks::Euclidean2D LANDMARK_T
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:
observations::RangeBearing_2D OBS_T
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 .
OBS_T::TObservationParams TObservationParams
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.
Eigen::Matrix< double, OBS_DIMS, LM_DIMS > TJacobian_dh_dx
A Jacobian of the correct size for each dh_dx.
mrpt::utils::TCamera camera_calib
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 ¶ms)
Inverse observation model for first-seen landmarks.
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
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 ¶ms)
Executes the (negative) observation-error model: "-( h(lm_pos,pose) - z_obs)".
Observation = Relative SE(3) poses (x,y,z,yaw,pitch,roll)
A parameterization of landmark positions in Euclidean coordinates (2D)
Observation = Relative SE(2) poses (x,y,yaw)
A parameterization of landmark positions in Euclidean coordinates (3D)
observations::RangeBearing_3D OBS_T
OBS_T::TObservationParams TObservationParams
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:
landmarks::Euclidean3D LANDMARK_T
Eigen::Matrix< double, OBS_DIMS, LM_DIMS > TJacobian_dh_dx
A Jacobian of the correct size for each dh_dx.
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:
observations::Cartesian_3D OBS_T
double fx() const
Get the value of the focal length x-value (in pixels).
observations::StereoCamera OBS_T
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 ¶ms)
Inverse observation model for first-seen landmarks.
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...
OBS_T::TObservationParams TObservationParams
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:
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:
Observation = one stereo camera feature (the coordinates of two pixels)
double cx() const
Get the value of the principal point x-coordinate (in pixels).
landmarks::Euclidean3D LANDMARK_T
The type "TObservationParams" must be declared in each "observations::TYPE" to hold sensor-specific p...
landmarks::RelativePoses3D LANDMARK_T
The type "TObservationParams" must be declared in each "observations::TYPE" to hold sensor-specific p...
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 ¶ms)
Executes the (negative) observation-error model: "-( h(lm_pos,pose) - z_obs)".
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 ¶ms)
Executes the (negative) observation-error model: "-( h(lm_pos,pose) - z_obs)".
landmarks::RelativePoses2D LANDMARK_T
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:
mrpt::poses::CPose3DQuat rightCameraPose
Pose of the right camera with respect to the coordinate origin of the left camera.
Structure to hold the parameters of a pinhole camera model.
landmark_traits< LANDMARK_T >::array_landmark_t array_landmark_t
a 2D or 3D point
Observation = Range+Bearing (yaw & pitch) of landmarks relative to the sensor.
landmark_traits< LANDMARK_T >::array_landmark_t array_landmark_t
a 2D or 3D point
Observation = Range+Bearing (yaw) of landmarks relative to the sensor, for planar environments only...
The type "TObservationParams" must be declared in each "observations::TYPE" to hold sensor-specific p...
double cy() const
Get the value of the principal point y-coordinate (in pixels).
Eigen::Matrix< double, OBS_DIMS, LM_DIMS > TJacobian_dh_dx
A Jacobian of the correct size for each dh_dx.