MRXT: The Multi-Robot eXploration Tool
Multi-Robot autonomous exploration and mapping simulator.
|
00001 #pragma once 00002 #ifndef ___ROBOT_TYPES___ 00003 #define ___ROBOT_TYPES___ 00004 00005 #include <string.h> 00006 #include <iostream> 00007 #include <stdio.h> 00008 00009 /// 3D position 00010 typedef struct pos3d{ 00011 pos3d(){ 00012 data[0] = 0; data[1] = 0; data[2] = 0; 00013 } 00014 pos3d(float nx, float ny, float nz){ 00015 data[0] = nx; data[1] = ny; data[2] = nz; 00016 } 00017 float data[3]; 00018 00019 pos3d(const pos3d& p3){ 00020 memcpy(data,p3.data,3*sizeof(float)); 00021 } 00022 00023 pos3d& operator= (const pos3d& p3){ 00024 memcpy(data,p3.data,3*sizeof(float)); 00025 return *this; 00026 } 00027 00028 float& getX(){return data[0];} 00029 float& getY(){return data[1];} 00030 float& getZ(){return data[2];} 00031 00032 const float& getX() const {return data[0];} 00033 const float& getY() const {return data[1];} 00034 const float& getZ() const {return data[2];} 00035 00036 pos3d operator+(const pos3d& p) const{ 00037 pos3d res(*this); 00038 res.data[0] += p.data[0]; 00039 res.data[1] += p.data[1]; 00040 res.data[2] += p.data[2]; 00041 return res; 00042 } 00043 pos3d operator-(const pos3d& p) const{ 00044 pos3d res(*this); 00045 res.data[0] -= p.data[0]; 00046 res.data[1] -= p.data[1]; 00047 res.data[2] -= p.data[2]; 00048 return res; 00049 } 00050 void print(char* str=0) const {printf("%sx: %f, y: %f, z: %f\n",str,data[0],data[1],data[2]);}; 00051 00052 }pos3d; 00053 00054 00055 /// pose 00056 typedef struct pose{ 00057 float x; 00058 float y; 00059 float th; 00060 pose(): x(0.0f),y(0.0f),th(0.0f){} 00061 pose(float nx, float ny, float nth): x(nx),y(ny),th(nth){} 00062 pose(const pose& p): x(p.x),y(p.y),th(p.th){} 00063 pose& operator= (const pose& p) {x = p.x; y = p.y; th = p.th; return *this;} 00064 pose operator+ (const pose& p) {return pose(x+p.x, y+p.y, th+p.th);} 00065 pose operator- (const pose& p) {return pose(x-p.x, y-p.y, th-p.th);} 00066 pose& operator+=(const pose& p) {x+=p.x; y+=p.y; th+=p.th; return *this;} 00067 pose& operator-=(const pose& p) {x-=p.x; y-=p.y; th-=p.th; return *this;} 00068 void print(char* str=0) const {printf("%sx: %f, y: %f, th: %f\n",str,x,y,th);} 00069 pos3d toPos3d(){return pos3d(x,y,0);} 00070 }pose; 00071 00072 static pose nullpose; 00073 00074 00075 /// pose in 3d 00076 typedef struct pose3d{ 00077 pose3d(): pos(0.0f,0.0f,0.0f),th(0.0){} 00078 pose3d(const pos3d& p, float o):pos(p),th(o){} 00079 pose3d(float nx, float ny, float nz, float nth): pos(nx,ny,nz),th(nth){} 00080 pos3d pos; 00081 float th; 00082 }pose3d; 00083 00084 /// posCil3d 00085 typedef struct posCil3d{ 00086 posCil3d(){ 00087 data[0] = 0; data[1] = 0; data[2] = 0; 00088 } 00089 posCil3d(float nr, float nalfa, float nz){ 00090 data[0] = nr; data[1] = nalfa; data[2] = nz; 00091 } 00092 float data[3]; 00093 00094 posCil3d(const posCil3d& p3){ 00095 memcpy(data,p3.data,3*sizeof(float)); 00096 } 00097 00098 posCil3d& operator= (const posCil3d& p3){ 00099 memcpy(data,p3.data,3*sizeof(float)); 00100 return *this; 00101 } 00102 00103 float& getR(){return data[0];} 00104 float& getAlfa(){return data[1];} 00105 float& getZ(){return data[2];} 00106 00107 const float& getR() const {return data[0];} 00108 const float& getAlfa() const {return data[1];} 00109 const float& getZ() const {return data[2];} 00110 00111 }posCil3d; 00112 00113 /// speed 00114 typedef struct speed{ 00115 speed(): v(0),w(0){} 00116 speed(float nv, float nw): v(nv),w(nw){} 00117 float v; 00118 float w; 00119 }speed; 00120 00121 /// discrete point (pixel) 00122 typedef struct point{ 00123 point(): x(0),y(0){} 00124 point(unsigned short nx, unsigned short ny): x(nx),y(ny){} 00125 unsigned short x; 00126 unsigned short y; 00127 }point; 00128 00129 /// cluster cell strcuture 00130 typedef struct clusterCell{ 00131 unsigned short x; 00132 unsigned short y; 00133 int scale; 00134 clusterCell(): x(0),y(0), scale(0){} 00135 }clusterCell; 00136 00137 /// float point (coordinates) 00138 typedef struct pointf{ 00139 pointf(): x(0),y(0){} 00140 pointf(float nx, float ny): x(nx),y(ny){} 00141 float x; 00142 float y; 00143 }pointf; 00144 00145 /// line 00146 typedef struct line{ 00147 line(): x1(0.0f), y1(0.0f), x2(0.0f), y2(0.0f){}; 00148 line(float nx1, float ny1, float nx2, float ny2): x1(nx1), y1(ny1), x2(nx2), y2(ny2){}; 00149 line(pointf p1, pointf p2): x1(p1.x), y1(p1.y), x2(p2.x), y2(p2.y){}; 00150 float x1; 00151 float y1; 00152 float x2; 00153 float y2; 00154 }line; 00155 00156 /// region of interest 00157 typedef struct RoI{ 00158 RoI(): x(0),y(0),width(0),height(0){} 00159 RoI(int nx, int ny, int nw, int nh): x(nx),y(ny),width(nw),height(nh){} 00160 int x; 00161 int y; 00162 int width; 00163 int height; 00164 }RoI; 00165 00166 00167 #endif 00168