INTRODUCTION Overview Download and Install Quick Start Documentation Publications NONFRAMEWORK CODE Driver Interfaces Drivers Libraries Utilities FRAMEWORK CODE Interfaces Components Libraries Utilities Full Software Listings DEVELOPER Tutorials Examples Dev Guide Dashboard PEOPLE Contributors Users Project Download Mailing lists
|
pose.h00001 #ifndef ORCANAVUTIL_POSE_H 00002 #define ORCANAVUTIL_POSE_H 00003 00004 #include <cmath> 00005 #include <iostream> 00006 #include <string> 00007 #include <assert.h> 00008 #include <hydronavutil/offset.h> 00009 00010 namespace hydronavutil { 00011 00015 class Pose 00016 { 00017 00018 public: 00019 00020 Pose() {}; 00021 Pose( double x, double y, double theta ) 00022 { p_[0]=x; p_[1]=y; p_[2]=theta; } 00023 00024 // non-const versions 00025 double &x() { return p_[0]; } 00026 double &y() { return p_[1]; } 00027 double &theta() { return p_[2]; } 00028 00029 // const versions 00030 double x() const { return p_[0]; } 00031 double y() const { return p_[1]; } 00032 double theta() const { return p_[2]; } 00033 00034 // Access like a vector 00035 double *v() { return p_; } 00036 const double *v() const { return p_; } 00037 00038 std::string toString() const; 00039 00040 private: 00041 00042 double p_[3]; 00043 00044 }; 00045 std::ostream &operator<<( std::ostream &s, const Pose &p ); 00046 00048 // 00049 // Non-member convenience functions for pose manipulation (see offset.h) 00050 // 00051 00053 inline void normaliseHeading( Pose &pose ) 00054 { NORMALISE_ANGLE( pose.theta() ); } 00055 00057 inline void addPoseOffset( Pose &pose, 00058 const Pose &offset, 00059 bool normaliseHeading ) 00060 { 00061 addPoseOffset( pose.x(), pose.y(), pose.theta(), 00062 offset.x(), offset.y(), offset.theta(), 00063 normaliseHeading ); 00064 } 00065 00067 inline void addPoseOffset( const Pose &start, 00068 const Pose &offset, 00069 Pose &result, 00070 bool normaliseHeading ) 00071 { 00072 addPoseOffset( start.x(), start.y(), start.theta(), 00073 offset.x(), offset.y(), offset.theta(), 00074 result.x(), result.y(), result.theta(), 00075 normaliseHeading ); 00076 } 00077 00079 inline void subtractFinalPoseOffset( Pose &pose, 00080 const Pose &offset, 00081 bool normaliseHeading ) 00082 { 00083 subtractFinalPoseOffset( pose.x(), pose.y(), pose.theta(), 00084 offset.x(), offset.y(), offset.theta(), 00085 normaliseHeading ); 00086 } 00087 00089 inline void subtractFinalPoseOffset( const Pose &start, 00090 const Pose &offset, 00091 Pose &result, 00092 bool normaliseHeading ) 00093 { 00094 subtractFinalPoseOffset( start.x(), start.y(), start.theta(), 00095 offset.x(), offset.y(), offset.theta(), 00096 result.x(), result.y(), result.theta(), 00097 normaliseHeading ); 00098 } 00099 00101 inline void subtractInitialOffset( Pose &pose, 00102 const Pose &initialOffset ) 00103 { 00104 subtractInitialOffset( pose.x(), pose.y(), pose.theta(), 00105 initialOffset.x(), initialOffset.y(), initialOffset.theta() ); 00106 } 00107 00109 inline void subtractInitialOffset( const Pose &pose, 00110 const Pose &initialOffset, 00111 Pose &result ) 00112 { 00113 subtractInitialOffset( pose.x(), pose.y(), pose.theta(), 00114 initialOffset.x(), initialOffset.y(), initialOffset.theta(), 00115 result.x(), result.y(), result.theta() ); 00116 } 00117 00119 inline Pose inverseTransform( const Pose &transform ) 00120 { 00121 hydronavutil::Pose inv; 00122 getInverseTransform( transform.x(), transform.y(), transform.theta(), 00123 inv.x(), inv.y(), inv.theta() ); 00124 return inv; 00125 } 00126 00127 } // end namespace 00128 00129 #endif |
Webmaster: Tobias Kaupp (tobasco at users.sourceforge.net)