g2o
Loading...
Searching...
No Matches
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

◆ convertToMotion()

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

Definition at line 69 of file odometry_measurement.cpp.

70 {
71 double x, y, theta;
72 if (fabs(v.vr() - v.vl()) > 1e-7) {
73 double R = l * 0.5 * ((v.vl() + v.vr()) / (v.vr() - v.vl()));
74 double w = (v.vr() - v.vl()) / l;
75
76 theta = w * v.dt();
77 Rotation2D rot(theta);
78 Vector2 icc(0, R);
79 Vector2 motion = (rot * (Vector2(-1. * icc))) + icc;
80 x = motion.x();
81 y = motion.y();
82 } else {
83 double tv = 0.5 * (v.vr() + v.vl());
84 theta = 0.;
85 x = tv * v.dt();
86 y = 0.;
87 }
88
89 return MotionMeasurement(x, y, theta, v.dt());
90}
Eigen::Rotation2D< double > Rotation2D
Definition eigen_types.h:80
VectorN< 2 > Vector2
Definition eigen_types.h:50

References g2o::VelocityMeasurement::dt(), g2o::VelocityMeasurement::vl(), and g2o::VelocityMeasurement::vr().

Referenced by g2o::EdgeSE2PureCalib::computeError(), EdgeCalib::computeError(), and main().

◆ convertToVelocity()

VelocityMeasurement g2o::OdomConvert::convertToVelocity ( const MotionMeasurement m)
static

Definition at line 48 of file odometry_measurement.cpp.

48 {
49 if (fabs(m.theta()) > 1e-7) {
50 const double translation = std::hypot(m.x(), m.y());
51 const double R = translation / (2 * sin(m.theta() / 2));
52 double w = 0.;
53 if (fabs(m.dt()) > 1e-7) w = m.theta() / m.dt();
54
55 const double vl = (2. * R * w - w) / 2.;
56 const double vr = w + vl;
57
58 return VelocityMeasurement(vl, vr, m.dt());
59 } else {
60 double vl, vr;
61 if (fabs(m.dt()) > 1e-7)
62 vl = vr = std::hypot(m.x(), m.y()) / m.dt();
63 else
64 vl = vr = 0.;
65 return VelocityMeasurement(vl, vr, m.dt());
66 }
67}
Jet< T, N > sin(const Jet< T, N > &f)
Definition jet.h:465

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

Referenced by g2o::addOdometryCalibLinksDifferential(), g2o::ClosedFormCalibration::calibrate(), and main().


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