OpenWalker Project
Documentation of the ROS Packages
rotation3_ref.h
Go to the documentation of this file.
1 
34 #ifndef OPEN_WALKER_CORE_ROTATION3_REF_H
35 #define OPEN_WALKER_CORE_ROTATION3_REF_H
36 
37 #include <ow_core/conversions.h>
38 #include <ow_core/matrix_ref.h>
39 
40 namespace ow_core
41 {
52 template <typename _Derived>
53 class Rotation3Ref : public MatrixRef<_Derived, 3, 3>
54 {
55 public:
56  typedef _Derived Derived;
58 
59 public:
73  explicit Rotation3Ref(Derived& ref, int startRow = 0, int startCol = 0) :
74  Base(ref, startRow, startCol)
75  {
76  }
77 
81  using Base::operator=;
82 
86  using Base::operator*;
87 
91  template <typename OtherDerived>
92  Rotation3Ref& operator=(const Eigen::RotationBase<OtherDerived, 3>& r)
93  {
94  *this = r.toRotationMatrix();
95  return *this;
96  }
97 
103  void operator=(const tf::Quaternion& q)
104  {
105  quaternionTFToEigenMatrix(q, *this);
106  }
107 
113  void operator=(const geometry_msgs::Quaternion& q)
114  {
115  quaternionMsgToEigenMatrix(q, *this);
116  }
117 
123  void operator=(const tf::Matrix3x3& R)
124  {
125  matrixTFToEigenMatrix(R, *this);
126  }
127 
132  operator tf::Quaternion() const
133  {
134  tf::Quaternion q;
135  matrixEigenToQuaternionTF(*this, q);
136  return q;
137  }
138 
143  operator geometry_msgs::Quaternion() const
144  {
145  geometry_msgs::Quaternion q;
146  matrixEigenToQuaternionMsg(*this, q);
147  return q;
148  }
149 
154  operator tf::Matrix3x3() const
155  {
156  tf::Matrix3x3 m;
157  matrixEigenToMatrixTF(*this, m);
158  return m;
159  }
160 
165  tf::Quaternion toQuaternionTF()
166  {
167  return static_cast<tf::Quaternion>(*this);
168  }
169 
174  geometry_msgs::Quaternion toQuaternionMsg()
175  {
176  return static_cast<geometry_msgs::Quaternion>(*this);
177  }
178 
183  tf::Matrix3x3 toMatrixTF()
184  {
185  return static_cast<tf::Matrix3x3>(*this);
186  }
187 
188 private:
192  Rotation3Ref();
193 };
194 
195 } // namespace ow_core
196 
197 #endif // OPEN_WALKER_CORE_ROTATION3_REF_H
tf::Quaternion toQuaternionTF()
Conversion to tf::Quaternion.
Definition: rotation3_ref.h:165
void matrixTFToEigenMatrix(const tf::Matrix3x3 &t, Eigen::MatrixBase< _Derived > &e)
Converts a tf::Matrix3x3 into an Eigen::Matrix3.
Definition: conversions.h:82
void matrixEigenToQuaternionMsg(const Eigen::MatrixBase< _Derived > &e, geometry_msgs::Quaternion &t)
Converts an Eigen::Matrix3 to a geometry_msgs::Quaternion.
Definition: conversions.h:213
geometry_msgs::Quaternion toQuaternionMsg()
Conversion to geometry_msgs::Quaternion.
Definition: rotation3_ref.h:174
Rotation3Ref & operator=(const Eigen::RotationBase< OtherDerived, 3 > &r)
Assignment of Eigen::RotationBase.
Definition: rotation3_ref.h:92
void quaternionMsgToEigenMatrix(const geometry_msgs::Quaternion &t, Eigen::MatrixBase< _Derived > &e)
Converts a geometry_msgs::Quaternion into an Eigen::Matrix3.
Definition: conversions.h:184
Contains global conversion functions.
Definition: angular_acceleration.h:39
void operator=(const geometry_msgs::Quaternion &q)
Assignment of geometry_msgs::Quaternion.
Definition: rotation3_ref.h:113
void matrixEigenToMatrixTF(const Eigen::MatrixBase< _Derived > &e, tf::Matrix3x3 &t)
Converts an Eigen::MatrixBase into a tf::Matrix3x3.
Definition: conversions.h:111
The Rotation3Ref class.
Definition: rotation3_ref.h:53
tf::Matrix3x3 toMatrixTF()
Conversion to tf::Matrix3x3.
Definition: rotation3_ref.h:183
The MatrixRef class.
Definition: matrix_ref.h:51
void operator=(const tf::Matrix3x3 &R)
Assignment of tf::Matrix3x3.
Definition: rotation3_ref.h:123
void quaternionTFToEigenMatrix(const tf::Quaternion &t, Eigen::MatrixBase< _Derived > &e)
Converts a tf::Quaternion into an Eigen::MatrixBase.
Definition: conversions.h:135
Rotation3Ref(Derived &ref, int startRow=0, int startCol=0)
Default Constructor.
Definition: rotation3_ref.h:73
void operator=(const tf::Quaternion &q)
Assignment of tf::Quaternion.
Definition: rotation3_ref.h:103