g2o
Static Public Member Functions | List of all members
g2o::OdomConvert Class Reference

convert between the different types of odometry measurements More...

#include <odometry_measurement.h>

Static Public Member Functions

static VelocityMeasurement convertToVelocity (const MotionMeasurement &m)
 
static MotionMeasurement convertToMotion (const VelocityMeasurement &vi, double l=1.0)
 

Detailed Description

convert between the different types of odometry measurements

Definition at line 94 of file odometry_measurement.h.

Member Function Documentation

MotionMeasurement g2o::OdomConvert::convertToMotion ( const VelocityMeasurement vi,
double  l = 1.0 
)
static

Definition at line 95 of file odometry_measurement.cpp.

References g2o::VelocityMeasurement::dt(), g2o::MotionMeasurement::MotionMeasurement(), g2o::MotionMeasurement::theta(), g2o::VelocityMeasurement::vl(), g2o::VelocityMeasurement::vr(), g2o::MotionMeasurement::x(), and g2o::MotionMeasurement::y().

Referenced by g2o::EdgeSE2OdomDifferentialCalib::computeError(), and g2o::EdgeSE2PureCalib::computeError().

96  {
97  double x, y, theta;
98  if (fabs(v.vr() - v.vl()) > 1e-7) {
99  double R = l * 0.5 * ((v.vl() + v.vr()) / (v.vr() - v.vl()));
100  double w = (v.vr() - v.vl()) / l;
101 
102  theta = w * v.dt();
103  Eigen::Rotation2Dd rot(theta);
104  Vector2D icc(0, R);
105  Vector2D motion = (rot * (Vector2D(-1.*icc))) + icc;
106  x = motion.x();
107  y = motion.y();
108  } else {
109  double tv = 0.5 * (v.vr() + v.vl());
110  theta = 0.;
111  x = tv * v.dt();
112  y = 0.;
113  }
114 
115  return MotionMeasurement(x, y, theta, v.dt());
116 
117  }
Eigen::Matrix< double, 2, 1, Eigen::ColMajor > Vector2D
Definition: eigen_types.h:45
VelocityMeasurement g2o::OdomConvert::convertToVelocity ( const MotionMeasurement m)
static

Definition at line 59 of file odometry_measurement.cpp.

References g2o::MotionMeasurement::dt(), g2o::hypot(), g2o::MotionMeasurement::theta(), g2o::MotionMeasurement::x(), and g2o::MotionMeasurement::y().

60  {
61  Vector2D px2(0, 10);
62 
63  if (fabs(m.theta()) > 1e-7) {
64  Eigen::Rotation2Dd rot(m.theta());
65  Vector2D px3(m.x(), m.y());
66  Vector2D px4(rot * px2 + px3);
67 
68  const double& y2 = px2.y();
69  const double& x3 = px3.x();
70  const double& y3 = px3.y();
71  const double& x4 = px4.x();
72  const double& y4 = px4.y();
73 
74  double R = (y2 * (x3*y4 - y3*x4)) / (y2 * (x3 - x4));
75  double w;
76  if (fabs(m.dt()) > 1e-7)
77  w = m.theta() / m.dt();
78  else
79  w = 0.;
80 
81  double vl = (2.*R*w - w) / 2.;
82  double vr = w + vl;
83 
84  return VelocityMeasurement(vl, vr, m.dt());
85  } else {
86  double vl, vr;
87  if (fabs(m.dt()) > 1e-7)
88  vl = vr = hypot(m.x(), m.y()) / m.dt();
89  else
90  vl = vr = 0.;
91  return VelocityMeasurement(vl, vr, m.dt());
92  }
93  }
Eigen::Matrix< double, 2, 1, Eigen::ColMajor > Vector2D
Definition: eigen_types.h:45
T hypot(T x, T y)
Definition: misc.h:61

The documentation for this class was generated from the following files: