17#ifndef IGNITION_MATH_POSE_HH_
18#define IGNITION_MATH_POSE_HH_
22#include <ignition/math/config.hh>
28 inline namespace IGNITION_MATH_VERSION_NAMESPACE
39 public:
Pose3() : p(0, 0, 0), q(1, 0, 0, 0)
58 public:
Pose3(T _x, T _y, T _z, T _roll, T _pitch, T _yaw)
59 : p(_x, _y, _z), q(_roll, _pitch, _yaw)
71 public:
Pose3(T _x, T _y, T _z, T _qw, T _qx, T _qy, T _qz)
72 : p(_x, _y, _z), q(_qw, _qx, _qy, _qz)
79 : p(_pose.p), q(_pose.q)
113 public:
void Set(T _x, T _y, T _z, T _roll, T _pitch, T _yaw)
115 this->p.Set(_x, _y, _z);
122 return this->p.IsFinite() && this->q.IsFinite();
137 return Pose3<T>(inv * (this->p*-1), inv);
204 return this->p == _pose.p && this->q == _pose.q;
212 return this->p != _pose.p || this->q != _pose.q;
240 tmp = this->q * (tmp * this->q.Inverse());
243 this->p.Y() + tmp.
Y(),
244 this->p.Z() + tmp.
Z());
253 this->p.X(), this->p.Y(), this->p.Z());
256 tmp = _pose.q * (tmp * _pose.q.Inverse());
259 _pose.p.Y() + tmp.
Y(),
260 _pose.p.Z() + tmp.
Z());
269 this->p.X() - _pose.p.X(),
270 this->p.Y() - _pose.p.Y(),
271 this->p.Z() - _pose.p.Z());
273 tmp = _pose.q.Inverse() * (tmp * _pose.q);
304 a.q = this->q.Inverse() * _b.q;
305 qt = a.q *
Quaternion<T>(0, this->p.X(), this->p.Y(), this->p.Z());
306 qt = qt * a.q.Inverse();
326 a.p.X((1.0 - 2.0*_q.
Y()*_q.
Y() - 2.0*_q.
Z()*_q.
Z()) * this->p.X()
327 +(2.0*(_q.
X()*_q.
Y()+_q.
W()*_q.
Z())) * this->p.Y()
328 +(2.0*(_q.
X()*_q.
Z()-_q.
W()*_q.
Y())) * this->p.Z());
329 a.p.Y((2.0*(_q.
X()*_q.
Y()-_q.
W()*_q.
Z())) * this->p.X()
330 +(1.0 - 2.0*_q.
X()*_q.
X() - 2.0*_q.
Z()*_q.
Z()) * this->p.Y()
331 +(2.0*(_q.
Y()*_q.
Z()+_q.
W()*_q.
X())) * this->p.Z());
332 a.p.Z((2.0*(_q.
X()*_q.
Z()+_q.
W()*_q.
Y())) * this->p.X()
333 +(2.0*(_q.
Y()*_q.
Z()-_q.
W()*_q.
X())) * this->p.Y()
334 +(1.0 - 2.0*_q.
X()*_q.
X() - 2.0*_q.
Y()*_q.
Y()) * this->p.Z());
342 this->q.Round(_precision);
343 this->p.Round(_precision);
381 _out << _pose.
Pos() <<
" " << _pose.
Rot();
393 _in.setf(std::ios_base::skipws);
Encapsulates a position and rotation in three space.
Definition Pose3.hh:34
void Set(const Vector3< T > &_pos, const Vector3< T > &_rpy)
Set the pose from pos and rpy vectors.
Definition Pose3.hh:100
bool operator!=(const Pose3< T > &_pose) const
Inequality operator.
Definition Pose3.hh:210
Vector3< T > CoordPositionAdd(const Vector3< T > &_pos) const
Add one point to a vector: result = this + pos.
Definition Pose3.hh:235
Quaternion< T > & Rot()
Get a mutuable reference to the rotation.
Definition Pose3.hh:369
Pose3< T > CoordPoseSolve(const Pose3< T > &_b) const
Find the inverse of a pose; i.e., if b = this + a, given b and this, find a.
Definition Pose3.hh:299
void Round(int _precision)
Round all values to _precision decimal places.
Definition Pose3.hh:340
const Pose3< T > & operator-=(const Pose3< T > &_pose)
Subtraction operator.
Definition Pose3.hh:191
Pose3< T > & operator=(const Pose3< T > &_pose)
Equal operator.
Definition Pose3.hh:225
virtual ~Pose3()
Destructor.
Definition Pose3.hh:84
Pose3< T > operator-(const Pose3< T > &_pose) const
Subtraction operator A is the transform from O to P in frame O B is the transform from O to Q in fram...
Definition Pose3.hh:182
void Set(T _x, T _y, T _z, T _roll, T _pitch, T _yaw)
Set the pose from a six tuple.
Definition Pose3.hh:113
const Quaternion< T > & Rot() const
Get the rotation.
Definition Pose3.hh:362
Vector3< T > & Pos()
Get a mutable reference to the position.
Definition Pose3.hh:355
Pose3(T _x, T _y, T _z, T _roll, T _pitch, T _yaw)
Constructor.
Definition Pose3.hh:58
bool operator==(const Pose3< T > &_pose) const
Equality operator.
Definition Pose3.hh:202
Pose3< T > operator+(const Pose3< T > &_pose) const
Addition operator A is the transform from O to P specified in frame O B is the transform from P to Q ...
Definition Pose3.hh:146
Pose3(T _x, T _y, T _z, T _qw, T _qx, T _qy, T _qz)
Constructor.
Definition Pose3.hh:71
void Set(const Vector3< T > &_pos, const Quaternion< T > &_rot)
Set the pose from a Vector3 and a Quaternion<T>
Definition Pose3.hh:91
Pose3< T > operator-() const
Negation operator A is the transform from O to P in frame O then -A is transform from P to O specifie...
Definition Pose3.hh:171
const Vector3< T > & Pos() const
Get the position.
Definition Pose3.hh:348
Vector3< T > CoordPositionSub(const Pose3< T > &_pose) const
Subtract one position from another: result = this - pose.
Definition Pose3.hh:266
const Pose3< T > & operator+=(const Pose3< T > &_pose)
Add-Equals operator.
Definition Pose3.hh:159
Pose3< T > operator*(const Pose3< T > &_pose) const
Multiplication operator.
Definition Pose3.hh:218
friend std::ostream & operator<<(std::ostream &_out, const ignition::math::Pose3< T > &_pose)
Stream insertion operator.
Definition Pose3.hh:378
static const Pose3< T > Zero
math::Pose3<T>(0, 0, 0, 0, 0, 0)
Definition Pose3.hh:36
Pose3(const Vector3< T > &_pos, const Quaternion< T > &_rot)
Constructor.
Definition Pose3.hh:46
bool IsFinite() const
See if a pose is finite (e.g., not nan)
Definition Pose3.hh:120
Quaternion< T > CoordRotationAdd(const Quaternion< T > &_rot) const
Add one rotation to another: result = this->q + rot.
Definition Pose3.hh:280
Pose3< T > Inverse() const
Get the inverse of this pose.
Definition Pose3.hh:134
void Correct()
Fix any nan values.
Definition Pose3.hh:126
Pose3< T > RotatePositionAboutOrigin(const Quaternion< T > &_q) const
Rotate vector part of a pose about the origin.
Definition Pose3.hh:323
friend std::istream & operator>>(std::istream &_in, ignition::math::Pose3< T > &_pose)
Stream extraction operator.
Definition Pose3.hh:389
Pose3()
Default constructors.
Definition Pose3.hh:39
void Reset()
Reset the pose.
Definition Pose3.hh:313
Quaternion< T > CoordRotationSub(const Quaternion< T > &_rot) const
Subtract one rotation from another: result = this->q - rot.
Definition Pose3.hh:288
Vector3< T > CoordPositionAdd(const Pose3< T > &_pose) const
Add one point to another: result = this + pose.
Definition Pose3.hh:250
Pose3(const Pose3< T > &_pose)
Copy constructor.
Definition Pose3.hh:78
A quaternion class.
Definition Quaternion.hh:38
void Normalize()
Normalize the quaternion.
Definition Quaternion.hh:223
const T & X() const
Get the x component.
Definition Quaternion.hh:955
const T & Y() const
Get the y component.
Definition Quaternion.hh:962
Quaternion< T > Inverse() const
Get the inverse of this quaternion.
Definition Quaternion.hh:131
const T & Z() const
Get the z component.
Definition Quaternion.hh:969
static const Quaternion Identity
math::Quaternion(1, 0, 0, 0)
Definition Quaternion.hh:40
const T & W() const
Get the w component.
Definition Quaternion.hh:948
The Vector3 class represents the generic vector containing 3 elements.
Definition Vector3.hh:40
T Z() const
Get the z value.
Definition Vector3.hh:661
T Y() const
Get the y value.
Definition Vector3.hh:654
T X() const
Get the x value.
Definition Vector3.hh:647
Pose3< float > Pose3f
Definition Pose3.hh:411
Pose3< double > Pose3d
Definition Pose3.hh:410
Pose3< int > Pose3i
Definition Pose3.hh:409