g2o
Public Member Functions | Static Public Member Functions | Public Attributes | Protected Attributes | List of all members
g2o::SE3Quat Class Reference

#include <se3quat.h>

Inheritance diagram for g2o::SE3Quat:
Inheritance graph
[legend]

Public Member Functions

 SE3Quat ()
 
 SE3Quat (const Matrix3D &R, const Vector3D &t)
 
 SE3Quat (const Eigen::Quaterniond &q, const Vector3D &t)
 
template<typename Derived >
 SE3Quat (const Eigen::MatrixBase< Derived > &v)
 
const Vector3Dtranslation () const
 
void setTranslation (const Vector3D &t_)
 
const Eigen::Quaterniond & rotation () const
 
void setRotation (const Eigen::Quaterniond &r_)
 
SE3Quat operator* (const SE3Quat &tr2) const
 
SE3Quatoperator*= (const SE3Quat &tr2)
 
Vector3D operator* (const Vector3D &v) const
 
SE3Quat inverse () const
 
double operator[] (int i) const
 
Vector7d toVector () const
 
void fromVector (const Vector7d &v)
 
Vector6d toMinimalVector () const
 
void fromMinimalVector (const Vector6d &v)
 
Vector6d log () const
 
Vector3D map (const Vector3D &xyz) const
 
Eigen::Matrix< double, 6, 6, Eigen::ColMajor > adj () const
 
Eigen::Matrix< double, 4, 4, Eigen::ColMajor > to_homogeneous_matrix () const
 
void normalizeRotation ()
 
 operator Isometry3D () const
 

Static Public Member Functions

static SE3Quat exp (const Vector6d &update)
 

Public Attributes

 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
 

Protected Attributes

Eigen::Quaterniond _r
 
Vector3D _t
 

Detailed Description

Definition at line 40 of file se3quat.h.

Constructor & Destructor Documentation

g2o::SE3Quat::SE3Quat ( )
inline

Definition at line 50 of file se3quat.h.

50  {
51  _r.setIdentity();
52  _t.setZero();
53  }
Eigen::Quaterniond _r
Definition: se3quat.h:46
Vector3D _t
Definition: se3quat.h:47
g2o::SE3Quat::SE3Quat ( const Matrix3D R,
const Vector3D t 
)
inline

Definition at line 55 of file se3quat.h.

55  :_r(Eigen::Quaterniond(R)),_t(t){
57  }
void normalizeRotation()
Definition: se3quat.h:277
Eigen::Quaterniond _r
Definition: se3quat.h:46
Vector3D _t
Definition: se3quat.h:47
g2o::SE3Quat::SE3Quat ( const Eigen::Quaterniond &  q,
const Vector3D t 
)
inline

Definition at line 59 of file se3quat.h.

59  :_r(q),_t(t){
61  }
void normalizeRotation()
Definition: se3quat.h:277
Eigen::Quaterniond _r
Definition: se3quat.h:46
Vector3D _t
Definition: se3quat.h:47
template<typename Derived >
g2o::SE3Quat::SE3Quat ( const Eigen::MatrixBase< Derived > &  v)
inlineexplicit

templaized constructor which allows v to be an arbitrary Eigen Vector type, e.g., Vector6d or Map<Vector6d>

Definition at line 67 of file se3quat.h.

68  {
69  assert((v.size() == 6 || v.size() == 7) && "Vector dimension does not match");
70  if (v.size() == 6) {
71  for (int i=0; i<3; i++){
72  _t[i]=v[i];
73  _r.coeffs()(i)=v[i+3];
74  }
75  _r.w() = 0.; // recover the positive w
76  if (_r.norm()>1.){
77  _r.normalize();
78  } else {
79  double w2=1.-_r.squaredNorm();
80  _r.w()= (w2<0.) ? 0. : sqrt(w2);
81  }
82  }
83  else if (v.size() == 7) {
84  int idx = 0;
85  for (int i=0; i<3; ++i, ++idx)
86  _t(i) = v(idx);
87  for (int i=0; i<4; ++i, ++idx)
88  _r.coeffs()(i) = v(idx);
90  }
91  }
void normalizeRotation()
Definition: se3quat.h:277
Eigen::Quaterniond _r
Definition: se3quat.h:46
Vector3D _t
Definition: se3quat.h:47

Member Function Documentation

Eigen::Matrix<double, 6, 6, Eigen::ColMajor> g2o::SE3Quat::adj ( ) const
inline

Definition at line 256 of file se3quat.h.

References g2o::skew().

Referenced by g2o::EdgeSE3Expmap::linearizeOplus().

257  {
258  Matrix3D R = _r.toRotationMatrix();
259  Eigen::Matrix<double, 6, 6, Eigen::ColMajor> res;
260  res.block(0,0,3,3) = R;
261  res.block(3,3,3,3) = R;
262  res.block(3,0,3,3) = skew(_t)*R;
263  res.block(0,3,3,3) = Matrix3D::Zero(3,3);
264  return res;
265  }
Eigen::Matrix< double, 3, 3, Eigen::ColMajor > Matrix3D
Definition: eigen_types.h:61
Eigen::Quaterniond _r
Definition: se3quat.h:46
Vector3D _t
Definition: se3quat.h:47
G2O_TYPES_SLAM3D_API Matrix3D skew(const Vector3D &v)
Definition: se3_ops.h:28
static SE3Quat g2o::SE3Quat::exp ( const Vector6d update)
inlinestatic

Definition at line 220 of file se3quat.h.

References g2o::skew().

Referenced by g2o::VertexSE3Expmap::oplusImpl().

221  {
222  Vector3D omega;
223  for (int i=0; i<3; i++)
224  omega[i]=update[i];
225  Vector3D upsilon;
226  for (int i=0; i<3; i++)
227  upsilon[i]=update[i+3];
228 
229  double theta = omega.norm();
230  Matrix3D Omega = skew(omega);
231 
232  Matrix3D R;
233  Matrix3D V;
234  if (theta<0.00001)
235  {
236  //TODO: CHECK WHETHER THIS IS CORRECT!!!
237  R = (Matrix3D::Identity() + Omega + Omega*Omega);
238 
239  V = R;
240  }
241  else
242  {
243  Matrix3D Omega2 = Omega*Omega;
244 
245  R = (Matrix3D::Identity()
246  + sin(theta)/theta *Omega
247  + (1-cos(theta))/(theta*theta)*Omega2);
248 
249  V = (Matrix3D::Identity()
250  + (1-cos(theta))/(theta*theta)*Omega
251  + (theta-sin(theta))/(pow(theta,3))*Omega2);
252  }
253  return SE3Quat(Eigen::Quaterniond(R),V*upsilon);
254  }
Eigen::Matrix< double, 3, 1, Eigen::ColMajor > Vector3D
Definition: eigen_types.h:46
Eigen::Matrix< double, 3, 3, Eigen::ColMajor > Matrix3D
Definition: eigen_types.h:61
G2O_TYPES_SLAM3D_API Matrix3D skew(const Vector3D &v)
Definition: se3_ops.h:28
void g2o::SE3Quat::fromMinimalVector ( const Vector6d v)
inline

Definition at line 163 of file se3quat.h.

163  {
164  double w = 1.-v[3]*v[3]-v[4]*v[4]-v[5]*v[5];
165  if (w>0){
166  _r=Eigen::Quaterniond(sqrt(w), v[3], v[4], v[5]);
167  } else {
168  _r=Eigen::Quaterniond(0, -v[3], -v[4], -v[5]);
169  }
170  _t=Vector3D(v[0], v[1], v[2]);
171  }
Eigen::Matrix< double, 3, 1, Eigen::ColMajor > Vector3D
Definition: eigen_types.h:46
Eigen::Quaterniond _r
Definition: se3quat.h:46
Vector3D _t
Definition: se3quat.h:47
void g2o::SE3Quat::fromVector ( const Vector7d v)
inline

Definition at line 147 of file se3quat.h.

Referenced by g2o::VertexSE3Expmap::read(), and g2o::EdgeSE3Expmap::read().

147  {
148  _r=Eigen::Quaterniond(v[6], v[3], v[4], v[5]);
149  _t=Vector3D(v[0], v[1], v[2]);
150  }
Eigen::Matrix< double, 3, 1, Eigen::ColMajor > Vector3D
Definition: eigen_types.h:46
Eigen::Quaterniond _r
Definition: se3quat.h:46
Vector3D _t
Definition: se3quat.h:47
SE3Quat g2o::SE3Quat::inverse ( ) const
inline
Vector6d g2o::SE3Quat::log ( ) const
inline

Definition at line 175 of file se3quat.h.

References g2o::deltaR(), and g2o::skew().

Referenced by g2o::EdgeSE3Expmap::computeError().

175  {
176  Vector6d res;
177  Matrix3D _R = _r.toRotationMatrix();
178  double d = 0.5*(_R(0,0)+_R(1,1)+_R(2,2)-1);
179  Vector3D omega;
180  Vector3D upsilon;
181 
182 
183  Vector3D dR = deltaR(_R);
184  Matrix3D V_inv;
185 
186  if (d>0.99999)
187  {
188 
189  omega=0.5*dR;
190  Matrix3D Omega = skew(omega);
191  V_inv = Matrix3D::Identity()- 0.5*Omega + (1./12.)*(Omega*Omega);
192  }
193  else
194  {
195  double theta = acos(d);
196  omega = theta/(2*sqrt(1-d*d))*dR;
197  Matrix3D Omega = skew(omega);
198  V_inv = ( Matrix3D::Identity() - 0.5*Omega
199  + ( 1-theta/(2*tan(theta/2)))/(theta*theta)*(Omega*Omega) );
200  }
201 
202  upsilon = V_inv*_t;
203  for (int i=0; i<3;i++){
204  res[i]=omega[i];
205  }
206  for (int i=0; i<3;i++){
207  res[i+3]=upsilon[i];
208  }
209 
210  return res;
211 
212  }
Eigen::Matrix< double, 3, 1, Eigen::ColMajor > Vector3D
Definition: eigen_types.h:46
Eigen::Matrix< double, 3, 3, Eigen::ColMajor > Matrix3D
Definition: eigen_types.h:61
Eigen::Quaterniond _r
Definition: se3quat.h:46
Vector3D _t
Definition: se3quat.h:47
Eigen::Matrix< double, 6, 1 > Vector6d
G2O_TYPES_SLAM3D_API Vector3D deltaR(const Matrix3D &R)
Definition: se3_ops.h:41
G2O_TYPES_SLAM3D_API Matrix3D skew(const Vector3D &v)
Definition: se3_ops.h:28
Vector3D g2o::SE3Quat::map ( const Vector3D xyz) const
inline

Definition at line 214 of file se3quat.h.

Referenced by g2o::EdgeProjectXYZ2UV::computeError(), and g2o::EdgeProjectXYZ2UVU::computeError().

215  {
216  return _r*xyz + _t;
217  }
Eigen::Quaterniond _r
Definition: se3quat.h:46
Vector3D _t
Definition: se3quat.h:47
void g2o::SE3Quat::normalizeRotation ( )
inline

Definition at line 277 of file se3quat.h.

Referenced by operator*().

277  {
278  if (_r.w()<0){
279  _r.coeffs() *= -1;
280  }
281  _r.normalize();
282  }
Eigen::Quaterniond _r
Definition: se3quat.h:46
g2o::SE3Quat::operator Isometry3D ( ) const
inline

cast SE3Quat into an Isometry3D

Definition at line 287 of file se3quat.h.

288  {
289  Isometry3D result = (Isometry3D) rotation();
290  result.translation() = translation();
291  return result;
292  }
Eigen::Transform< double, 3, Eigen::Isometry, Eigen::ColMajor > Isometry3D
Definition: eigen_types.h:66
const Eigen::Quaterniond & rotation() const
Definition: se3quat.h:97
const Vector3D & translation() const
Definition: se3quat.h:93
SE3Quat g2o::SE3Quat::operator* ( const SE3Quat tr2) const
inline

Definition at line 101 of file se3quat.h.

References _r, _t, and normalizeRotation().

101  {
102  SE3Quat result(*this);
103  result._t += _r*tr2._t;
104  result._r*=tr2._r;
105  result.normalizeRotation();
106  return result;
107  }
Eigen::Quaterniond _r
Definition: se3quat.h:46
Vector3D g2o::SE3Quat::operator* ( const Vector3D v) const
inline

Definition at line 116 of file se3quat.h.

116  {
117  return _t+_r*v;
118  }
Eigen::Quaterniond _r
Definition: se3quat.h:46
Vector3D _t
Definition: se3quat.h:47
SE3Quat& g2o::SE3Quat::operator*= ( const SE3Quat tr2)
inline

Definition at line 109 of file se3quat.h.

References _r, and _t.

109  {
110  _t+=_r*tr2._t;
111  _r*=tr2._r;
113  return *this;
114  }
void normalizeRotation()
Definition: se3quat.h:277
Eigen::Quaterniond _r
Definition: se3quat.h:46
Vector3D _t
Definition: se3quat.h:47
double g2o::SE3Quat::operator[] ( int  i) const
inline

Definition at line 127 of file se3quat.h.

127  {
128  assert(i<7);
129  if (i<3)
130  return _t[i];
131  return _r.coeffs()[i-3];
132  }
Eigen::Quaterniond _r
Definition: se3quat.h:46
Vector3D _t
Definition: se3quat.h:47
const Eigen::Quaterniond& g2o::SE3Quat::rotation ( ) const
inline
void g2o::SE3Quat::setRotation ( const Eigen::Quaterniond &  r_)
inline

Definition at line 99 of file se3quat.h.

Referenced by g2o::deprecated::EdgeSE3Prior::initialEstimate().

99 {_r=r_;}
Eigen::Quaterniond _r
Definition: se3quat.h:46
void g2o::SE3Quat::setTranslation ( const Vector3D t_)
inline

Definition at line 95 of file se3quat.h.

Referenced by g2o::deprecated::EdgeSE3Prior::initialEstimate(), and g2o::EdgeSBAScale::initialEstimate().

95 {_t = t_;}
Vector3D _t
Definition: se3quat.h:47
Eigen::Matrix<double,4,4,Eigen::ColMajor> g2o::SE3Quat::to_homogeneous_matrix ( ) const
inline

Definition at line 267 of file se3quat.h.

Referenced by g2o::operator<<().

268  {
269  Eigen::Matrix<double,4,4,Eigen::ColMajor> homogeneous_matrix;
270  homogeneous_matrix.setIdentity();
271  homogeneous_matrix.block(0,0,3,3) = _r.toRotationMatrix();
272  homogeneous_matrix.col(3).head(3) = translation();
273 
274  return homogeneous_matrix;
275  }
Eigen::Quaterniond _r
Definition: se3quat.h:46
const Vector3D & translation() const
Definition: se3quat.h:93
Vector6d g2o::SE3Quat::toMinimalVector ( ) const
inline

Definition at line 152 of file se3quat.h.

152  {
153  Vector6d v;
154  v[0]=_t(0);
155  v[1]=_t(1);
156  v[2]=_t(2);
157  v[3]=_r.x();
158  v[4]=_r.y();
159  v[5]=_r.z();
160  return v;
161  }
Eigen::Quaterniond _r
Definition: se3quat.h:46
Vector3D _t
Definition: se3quat.h:47
Eigen::Matrix< double, 6, 1 > Vector6d
Vector7d g2o::SE3Quat::toVector ( ) const
inline

Definition at line 135 of file se3quat.h.

135  {
136  Vector7d v;
137  v[0]=_t(0);
138  v[1]=_t(1);
139  v[2]=_t(2);
140  v[3]=_r.x();
141  v[4]=_r.y();
142  v[5]=_r.z();
143  v[6]=_r.w();
144  return v;
145  }
Eigen::Matrix< double, 7, 1 > Vector7d
Definition: sim3.h:35
Eigen::Quaterniond _r
Definition: se3quat.h:46
Vector3D _t
Definition: se3quat.h:47
const Vector3D& g2o::SE3Quat::translation ( ) const
inline

Member Data Documentation

Eigen::Quaterniond g2o::SE3Quat::_r
protected

Definition at line 46 of file se3quat.h.

Referenced by inverse(), operator*(), and operator*=().

Vector3D g2o::SE3Quat::_t
protected

Definition at line 47 of file se3quat.h.

Referenced by inverse(), operator*(), and operator*=().

g2o::SE3Quat::EIGEN_MAKE_ALIGNED_OPERATOR_NEW

Definition at line 42 of file se3quat.h.


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