Ravelin
Pose3.h
1 /****************************************************************************
2  * Copyright 2013 Evan Drumwright
3  * This library is distributed under the terms of the Apache V2.0
4  * License (obtainable from http://www.apache.org/licenses/LICENSE-2.0).
5  ****************************************************************************/
6 
7 #ifndef POSE3
8 #error This class is not to be included by the user directly. Use Pose3d.h or Pose3f.h instead.
9 #endif
10 
11 class AANGLE;
12 class MATRIX3;
13 
15 class POSE3 : public boost::enable_shared_from_this<POSE3>
16 {
17  friend class MOVINGTRANSFORM3;
18 
19  public:
20  POSE3();
21  POSE3(const POSE3& source) { operator=(source); }
22  POSE3(const AANGLE& a, boost::shared_ptr<const POSE3> relative_pose = boost::shared_ptr<const POSE3>());
23  POSE3(const MATRIX3& m, boost::shared_ptr<const POSE3> relative_pose = boost::shared_ptr<const POSE3>());
24  POSE3(const QUAT& q, boost::shared_ptr<const POSE3> relative_pose = boost::shared_ptr<const POSE3>());
25  POSE3(const AANGLE& a, const ORIGIN3& v, boost::shared_ptr<const POSE3> relative_pose = boost::shared_ptr<const POSE3>());
26  POSE3(const MATRIX3& m, const ORIGIN3& v, boost::shared_ptr<const POSE3> relative_pose = boost::shared_ptr<const POSE3>());
27  POSE3(const QUAT& q, const ORIGIN3& v, boost::shared_ptr<const POSE3> relative_pose = boost::shared_ptr<const POSE3>());
28  POSE3(const ORIGIN3& v, boost::shared_ptr<const POSE3> relative_pose = boost::shared_ptr<const POSE3>());
29  static POSE3 identity() { POSE3 T; T.set_identity(); return T; }
30  static VECTOR3 interpolate_vector(const POSE3& m1, const POSE3& m2, REAL t, const ORIGIN3& o);
31  static VECTOR3 interpolate_point(const POSE3& m1, const POSE3& m2, REAL t, const ORIGIN3& o);
32  static bool rel_equal(const POSE3& p1, const POSE3& p2, REAL tol = EPS);
33  VECTOR3 transform_point(const VECTOR3& p) const { return transform_point(rpose, p); }
34  VECTOR3 transform_vector(const VECTOR3& p) const { return transform_vector(rpose, p); }
35  VECTOR3 inverse_transform_point(const VECTOR3& p) const;
37  static VECTOR3 transform_point(boost::shared_ptr<const POSE3> target, const VECTOR3& v);
38  static VECTOR3 transform_vector(boost::shared_ptr<const POSE3> target, const VECTOR3& v);
39  SFORCE transform(const SFORCE& w) const;
40  SFORCE inverse_transform(const SFORCE& w) const;
41  static SFORCE transform(boost::shared_ptr<const POSE3> target, const SFORCE& w);
42  static std::vector<SFORCE>& transform(boost::shared_ptr<const POSE3> target, const std::vector<SFORCE>& w, std::vector<SFORCE>& result);
43  SMOMENTUM transform(const SMOMENTUM& t) const;
44  SMOMENTUM inverse_transform(const SMOMENTUM& t) const;
45  SVELOCITY transform(const SVELOCITY& t) const;
46  SVELOCITY inverse_transform(const SVELOCITY& t) const;
47  static SMOMENTUM transform(boost::shared_ptr<const POSE3> target, const SMOMENTUM& t);
48  static SVELOCITY transform(boost::shared_ptr<const POSE3> target, const SVELOCITY& t);
49  static std::vector<SVELOCITY>& transform(boost::shared_ptr<const POSE3> target, const std::vector<SVELOCITY>& t, std::vector<SVELOCITY>& result);
50  static std::vector<SMOMENTUM>& transform(boost::shared_ptr<const POSE3> target, const std::vector<SMOMENTUM>& t, std::vector<SMOMENTUM>& result);
51  SACCEL transform(const SACCEL& t) const;
52  SACCEL inverse_transform(const SACCEL& t) const;
53  static SACCEL transform(boost::shared_ptr<const POSE3> target, const SACCEL& t);
54  static std::vector<SACCEL>& transform(boost::shared_ptr<const POSE3> target, const std::vector<SACCEL>& t, std::vector<SACCEL>& result);
55  SPATIAL_RB_INERTIA transform(const SPATIAL_RB_INERTIA& j) const { return transform(rpose, j); }
57  static SPATIAL_RB_INERTIA transform(boost::shared_ptr<const POSE3> target, const SPATIAL_RB_INERTIA& j);
58  SPATIAL_AB_INERTIA transform(const SPATIAL_AB_INERTIA& j) const { return transform(rpose, j); }
60  static SPATIAL_AB_INERTIA transform(boost::shared_ptr<const POSE3> target, const SPATIAL_AB_INERTIA& j);
61  static TRANSFORM3 calc_relative_pose(boost::shared_ptr<const POSE3> source, boost::shared_ptr<const POSE3> target) { return calc_transform(source, target); }
62  VECTOR3 qG_mult(REAL qdw, REAL qdx, REAL qdy, REAL qdz) const;
63  QUAT qG_transpose_mult(const VECTOR3& omega) const;
65  POSE3& invert();
66  POSE3 inverse() const { return invert(*this); }
67  static POSE3 invert(const POSE3& m);
68  POSE3& set(const AANGLE& a);
69  POSE3& set(const MATRIX3& m);
70  POSE3& set(const QUAT& q);
71  POSE3& set(const AANGLE& a, const ORIGIN3& v);
72  POSE3& set(const MATRIX3& m, const ORIGIN3& v);
73  POSE3& set(const QUAT& q, const ORIGIN3& v);
74  POSE3 operator+(const SVELOCITY& v) const;
75  POSE3& operator=(const POSE3& source);
76  POSE3 operator*(const POSE3& m) const;
77  POSE3& update_relative_pose(boost::shared_ptr<const POSE3> pose);
78  static VECTOR3 interpolate_transform_vector(const POSE3& P1, const POSE3& P2, REAL t, const ORIGIN3& o);
79  static VECTOR3 interpolate_transform_point(const POSE3& P1, const POSE3& P2, REAL t, const ORIGIN3& o);
80  static SVELOCITY diff(const POSE3& P1, const POSE3& P2);
81 
83  template <class M>
84  static M& spatial_transform_to_matrix(boost::shared_ptr<const POSE3> source, boost::shared_ptr<const POSE3> target, M& m)
85  {
86  const unsigned SPATIAL_DIM = 6;
87  m.resize(SPATIAL_DIM, SPATIAL_DIM);
88  VECTOR3 r;
89  MATRIX3 E;
90  get_r_E(calc_transform(source, target), r, E);
91  m.set_sub_mat(0, 0, E);
92  m.set_sub_mat(3, 3, E);
94  m.set_sub_mat(3, 0, E*rx);
95  m.set_sub_mat(0, 3, MATRIX3::zero());
96  return m;
97  }
98 
100  template <class M>
101  static M& spatial_transform_to_matrix2(boost::shared_ptr<const POSE3> source, boost::shared_ptr<const POSE3> target, M& m)
102  {
103  const unsigned SPATIAL_DIM = 6;
104  m.resize(SPATIAL_DIM, SPATIAL_DIM);
105  VECTOR3 r;
106  MATRIX3 E;
107  get_r_E(calc_transform(source, target), r, E);
108  m.set_sub_mat(0, 0, E);
109  m.set_sub_mat(3, 3, E);
111  m.set_sub_mat(0, 3, E*rx);
112  m.set_sub_mat(3, 0, MATRIX3::zero());
113  return m;
114  }
115 
117  template <class M>
118  static M& dot_spatial_transform_to_matrix2(boost::shared_ptr<const POSE3> source, boost::shared_ptr<const POSE3> target, M& m)
119  {
120  const unsigned SPATIAL_DIM = 6;
121  m.resize(SPATIAL_DIM, SPATIAL_DIM);
122  VECTOR3 r;
123  MATRIX3 E;
124  get_r_E(calc_transform(source, target), r, E);
125  m.set_sub_mat(0, 0, MATRIX3::zero());
126  m.set_sub_mat(3, 3, MATRIX3::zero());
128  m.set_sub_mat(0, 3, E*rx*rx);
129  m.set_sub_mat(3, 0, MATRIX3::zero());
130  return m;
131  }
132 
135 
138 
140  boost::shared_ptr<const POSE3> rpose;
141 
142  private:
143  static void transform_spatial(boost::shared_ptr<const POSE3> target, const SVECTOR6& v, SVECTOR6& result);
144  static void transform_spatial(boost::shared_ptr<const POSE3> target, const SVECTOR6& v, const VECTOR3& rv, const MATRIX3& E, SVECTOR6& result);
145  void get_r_E(VECTOR3& r, MATRIX3& E, bool inverse) const;
146  static void get_r_E(const TRANSFORM3& T, VECTOR3& r, MATRIX3& E);
147  TRANSFORM3 calc_transform(boost::shared_ptr<const POSE3> p) const { return calc_transform(shared_from_this(), p); }
148  static TRANSFORM3 calc_transform(boost::shared_ptr<const POSE3> source, boost::shared_ptr<const POSE3> target);
149  static bool is_common(boost::shared_ptr<const POSE3> source, boost::shared_ptr<const POSE3> p, unsigned& i);
150 }; // end class
151 
152 std::ostream& operator<<(std::ostream& out, const POSE3& m);
153 
MOVINGTRANSFORM3 & operator=(const MOVINGTRANSFORM3 &source)
Copies a moving transform to another.
Definition: MovingTransform3.cpp:22
boost::shared_ptr< const POSE3 > rpose
the pose that this pose is relative to (if any)
Definition: Pose3.h:140
POSE3()
Default constructor.
Definition: Pose3.cpp:13
POSE3 & set_identity()
Sets this matrix to identity.
Definition: Pose3.cpp:236
POSE3 operator*(const POSE3 &m) const
Multiplies this pose by another.
Definition: Pose3.cpp:262
Quaternion class used for orientation.
Definition: Quat.h:21
QUAT q
the orientation of the pose frame
Definition: Pose3.h:134
A spatial (six dimensional) momentum.
Definition: SMomentum.h:12
VECTOR3 qG_mult(REAL qdw, REAL qdx, REAL qdy, REAL qdz) const
Multiplies the quaternion derivative.
Definition: Pose3.cpp:143
static M & spatial_transform_to_matrix(boost::shared_ptr< const POSE3 > source, boost::shared_ptr< const POSE3 > target, M &m)
Computes a 6x6 matrix that transforms velocity vectors in [w; v] format or force vectors in [f; tau] ...
Definition: Pose3.h:84
SVELOCITY v
the velocity of the original frame
Definition: MovingTransform3.h:31
POSE3 & update_relative_pose(boost::shared_ptr< const POSE3 > pose)
Updates the relative pose for this pose while retaining the same absolute pose.
Definition: Pose3.cpp:1030
ORIGIN3 x
the origin of the pose frame
Definition: Pose3.h:137
POSE3 & invert()
method for inverting a pose in place
Definition: Pose3.cpp:244
SACCEL transform(const SACCEL &a) const
Transforms a spatial acceleration (defined relative to the source frame's relative pose) to a spatial...
Definition: MovingTransform3.cpp:38
Class for representation of orientation by an angle around an axis.
Definition: AAngle.h:15
QUAT qG_transpose_mult(const VECTOR3 &omega) const
Multiplies the quaternion derivative.
Definition: Pose3.cpp:155
A spatial velocity (a twist)
Definition: SVelocity.h:15
static M & spatial_transform_to_matrix2(boost::shared_ptr< const POSE3 > source, boost::shared_ptr< const POSE3 > target, M &m)
Computes a 6x6 matrix that transforms velocity vectors in [v w] format.
Definition: Pose3.h:101
static bool rel_equal(const POSE3 &p1, const POSE3 &p2, REAL tol=EPS)
Determines whether two poses in 3D are relatively equivalent.
Definition: Pose3.cpp:76
A rigid body pose.
Definition: Pose3.h:15
A 6-dimensional floating-point vector for use with spatial algebra.
Definition: SVector6.h:22
POSE3 & set(const AANGLE &a)
Sets this pose from a axis-angle object only (translation will be zero'd)
Definition: Pose3.cpp:214
A transformation between two rigid body poses.
Definition: MovingTransform3.h:14
A 6x6 spatial algebra matrix typically used for dynamics calculations.
Definition: SpatialABInertia.h:20
A 6x6 spatial algebra matrix used for dynamics calculations.
Definition: SpatialRBInertia.h:25
A spatial (six dimensional) acceleration.
Definition: SAccel.h:14
boost::shared_ptr< const POSE3 > target
the "target" pose
Definition: MovingTransform3.h:49
static SVELOCITY diff(const POSE3 &P1, const POSE3 &P2)
Computes the spatial velocity that gets from one pose (P1) to another (P2)
Definition: Pose3.cpp:1012
A three-dimensional floating point vector used for representing points and vectors in 3D with associa...
Definition: Vector3.h:15
SFORCE inverse_transform(const SFORCE &w) const
Transforms a point from one pose to another.
Definition: Pose3.cpp:325
static MOVINGTRANSFORM3 calc_transform(boost::shared_ptr< const POSE3 > source, boost::shared_ptr< const POSE3 > target, const SVELOCITY &vs, const SVELOCITY &vt)
Computes the relative transformation between two moving poses.
Definition: MovingTransform3.cpp:93
A spatial force (a wrench)
Definition: SForce.h:14
POSE3 operator+(const SVELOCITY &v) const
Adds a velocity to a pose to yield a new pose.
Definition: Pose3.cpp:995
A three-dimensional floating point vector used for representing points and vectors in 3D and without ...
Definition: Origin3.h:16
static M & dot_spatial_transform_to_matrix2(boost::shared_ptr< const POSE3 > source, boost::shared_ptr< const POSE3 > target, M &m)
Computes the time derivative of a 6x6 matrix that transforms velocity vectors in [v w] format...
Definition: Pose3.h:118
static MATRIX3 skew_symmetric(REAL a, REAL b, REAL c)
Constructs a skew-symmetric matrix from the given values.
Definition: Matrix3.cpp:260
ORIGIN3 r
the r vector
Definition: MovingTransform3.h:34
static VECTOR3 interpolate_transform_vector(const POSE3 &P1, const POSE3 &P2, REAL t, const ORIGIN3 &o)
Tranforms a vector with an interpolated pose (between poses P1 and P2)
Definition: Pose3.cpp:103
MATRIX3 E
the E matrix
Definition: MovingTransform3.h:40
boost::shared_ptr< const POSE3 > source
the "source" pose
Definition: MovingTransform3.h:46
static VECTOR3 interpolate_transform_point(const POSE3 &P1, const POSE3 &P2, REAL t, const ORIGIN3 &o)
Tranforms a point with an interpolated pose (between poses P1 and P2)
Definition: Pose3.cpp:125
A transformation between two rigid body poses.
Definition: Transform3.h:14
VECTOR3 inverse_transform_vector(const VECTOR3 &v) const
Transforms a vector from one pose to another.
Definition: Pose3.cpp:283
A 3x3 matrix that may be used for orientation, inertia tensors, etc.
Definition: Matrix3.h:20
VECTOR3 inverse_transform_point(const VECTOR3 &p) const
Transforms a point from one pose to another.
Definition: Pose3.cpp:304