pose2.h
Go to the documentation of this file.
1 
7 #ifndef POSE2_H
8 #define POSE2_H
9 
10 #include <argos3/core/utility/math/vector3.h>
11 #include <argos3/core/utility/math/quaternion.h>
12 namespace argos
13 {
14  class CPose2 {
15 
16  public:
17  ~CPose2() {
18  }
19 
23  CPose2() :
24  m_cPosition(0,0),
25  m_cOrientation(0) {
26  }
27 
32  CPose2(const CPose2& c_pose) :
33  m_cPosition(c_pose.m_cPosition),
34  m_cOrientation(c_pose.m_cOrientation) {
35  }
36 
42  CPose2(const CVector2& c_position, const CRadians& c_orientation) :
43  m_cPosition(c_position),
44  m_cOrientation(c_orientation) {
45  }
46 
53  CPose2(const Real f_x, const Real f_y, const Real f_th) :
54  m_cPosition(f_x, f_y),
55  m_cOrientation(f_th) {
56  }
57 
62  inline const CVector2& GetPosition() const
63  { return m_cPosition;}
64 
69  inline const CRadians& GetOrientation() const
70  { return m_cOrientation;}
71 
76  inline void Rotate(const CRadians& c_offset) {
77  m_cOrientation += c_offset;
78  }
79 
84  inline void Translate(const CVector2& c_offset) {
85  m_cPosition = (*this)*c_offset;
86  }
87 
93  inline bool operator==(const CPose2& c_pose) const {
94  if(m_cPosition.m_fX != c_pose.m_cPosition.m_fX)
95  return false;
96  if(m_cPosition.m_fY != c_pose.m_cPosition.m_fY)
97  return false;
98  if(m_cOrientation != c_pose.m_cOrientation)
99  return false;
100  return true;
101  }
102 
108  inline bool operator!=(const CPose2& c_pose) const {
109  if(m_cPosition.m_fX == c_pose.m_cPosition.m_fX)
110  return false;
111  if(m_cPosition.m_fY == c_pose.m_cPosition.m_fY)
112  return false;
113  if(m_cOrientation == c_pose.m_cOrientation)
114  return false;
115  return true;
116  }
117 
124  inline friend std::ostream& operator<<(std::ostream& c_os,
125  const CPose2& c_pose) {
126  c_os << "Position("
127  << c_pose.m_cPosition.GetX() << ","
128  << c_pose.m_cPosition.GetY() << ")\n"
129  << "Orientation("
130  << c_pose.m_cOrientation.GetValue()
131  << " radians"
132  << " -> "
133  << c_pose.m_cOrientation.GetValue() * CRadians::RADIANS_TO_DEGREES
134  << " degrees)";
135  return c_os;
136  }
137 
138  public:
144  CPose2(const CVector3& c_position, const CQuaternion& c_orientation);
145 
150  CPose2 Inverse() const;
151 
157  CPose2 operator*(const CPose2& c_pose) const;
158 
164  CVector2 operator*(const CVector2& c_vec) const;
165 
171  CPose2& operator*=(const CPose2& c_pose);
172 
173  private:
174  CVector2 m_cPosition;
175  CRadians m_cOrientation;
176  };
177 
178 } // namespace argos
179 #endif
float Real
Collects all ARGoS code.
Definition: datatypes.h:39
The namespace containing all the ARGoS related code.
Definition: ci_actuator.h:12
It defines the basic type CRadians, used to store an angle value in radians.
Definition: angles.h:42
static const Real RADIANS_TO_DEGREES
Constant to convert from radians to degrees.
Definition: angles.h:275
Real GetValue() const
Returns the value in radians.
Definition: angles.h:111
CPose2 Inverse() const
Computes the returns the inverse of the current pose.
Definition: pose2.cpp:20
CPose2(const CVector2 &c_position, const CRadians &c_orientation)
Constructor using input position and angle.
Definition: pose2.h:42
CPose2(const CPose2 &c_pose)
Copy constructor.
Definition: pose2.h:32
const CVector2 & GetPosition() const
Returns the position of the pose.
Definition: pose2.h:62
void Translate(const CVector2 &c_offset)
Translates the current pose by the given vector.
Definition: pose2.h:84
CPose2 operator*(const CPose2 &c_pose) const
Multiplication operator overloading.
Definition: pose2.cpp:36
CPose2(const Real f_x, const Real f_y, const Real f_th)
Constructor using individual coordinate values and angle.
Definition: pose2.h:53
const CRadians & GetOrientation() const
Returns the orientation of the pose.
Definition: pose2.h:69
bool operator==(const CPose2 &c_pose) const
Equality operator overloading.
Definition: pose2.h:93
CPose2 & operator*=(const CPose2 &c_pose)
Multiplication operator overloading.
Definition: pose2.cpp:67
CPose2()
Default constructor.
Definition: pose2.h:23
bool operator!=(const CPose2 &c_pose) const
Inequality operator overloading.
Definition: pose2.h:108
friend std::ostream & operator<<(std::ostream &c_os, const CPose2 &c_pose)
Serialize the contents of the 2D Pose onto a stream.
Definition: pose2.h:124
void Rotate(const CRadians &c_offset)
Rotates the current pose by the given offset angle.
Definition: pose2.h:76
A 2D vector class.
Definition: vector2.h:27
Real GetY() const
Returns the y coordinate of this vector.
Definition: vector2.h:110
Real GetX() const
Returns the x coordinate of this vector.
Definition: vector2.h:94
A 3D vector class.
Definition: vector3.h:31