VisualOdometryPTAMM.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef _VISUALODOMETRYPTAMM_H
00026 #define _VISUALODOMETRYPTAMM_H
00027
00028
00029 #include "VisualOdometry.h"
00030
00031 #include <cvd/Linux/v4lbuffer.h>
00032 #include <cvd/colourspace_convert.h>
00033 #include <cvd/colourspaces.h>
00034 #include <cvd/image.h>
00035 #include <cvd/byte.h>
00036 #include <cvd/rgb.h>
00037 #include <netinet/in.h>
00038 #include <netdb.h>
00039 #include <sys/socket.h>
00040 #include <arpa/inet.h>
00041 #include <stdio.h>
00042 #include <stdlib.h>
00043 #include <unistd.h>
00044 #include <pthread.h>
00045 #include <sys/types.h>
00046 #include <sys/un.h>
00047 #include <string.h>
00048
00049
00050
00051
00052 #include "opencv2/highgui/highgui.hpp"
00053
00054
00055
00056 #include "opencv2/imgproc/imgproc.hpp"
00057 #include <iostream>
00058 #include <sstream>
00059 #include <pthread.h>
00060
00061 #include <baselib.h>
00062 #include <VrpnTracker.h>
00063
00064 #include <Camera.h>
00065
00066 #include <time.h>
00067
00068 #define PORT 7777
00069
00070 using namespace MipBaselib;
00071
00072 using namespace std;
00073
00074 namespace MipAlgorithms{
00078
00082
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093 class PTAMMVrpnHandler : public VrpnHandler{
00094 public:
00095 PTAMMVrpnHandler(Pose3DandTime* PTAMMdata);
00096
00097
00098 private:
00099 Pose3DandTime* handlerData;
00100
00101
00102
00103 virtual void handleVrpnData(){
00104 timeval measureTime;
00105
00106 double matrix[3][3];
00107 VrpnTracker::quat2Mat(VrpnTracker::instance()->currPos.quat, matrix);
00108 double rpy[3];
00109 VrpnTracker::matToEA(matrix, rpy);
00110
00111 handlerData->time = VrpnTracker::instance()->currPos.msg_time;
00112
00113 handlerData->x = VrpnTracker::instance()->currPos.pos[0] / 1000.0;
00114 handlerData->y = VrpnTracker::instance()->currPos.pos[1] / 1000.0;
00115 handlerData->z = VrpnTracker::instance()->currPos.pos[2] / 1000.0;
00116 handlerData->roll = rpy[0];
00117 handlerData->pitch = rpy[1];
00118 handlerData->yaw = rpy[2];
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132 }
00133 };
00134
00135
00136 class VisualOdometryPTAMM : public VisualOdometry {
00137
00138 public:
00139 VisualOdometryPTAMM(IplImage* _imFrame);
00140
00141 VisualOdometryPTAMM(IplImage* _imFrame, char* logFilePath);
00142 ~VisualOdometryPTAMM();
00143 bool getPose3DUnscaled(Pose3DandTime* pose);
00144 bool readDataFromPTAMM(Pose3DandTime* pose, Time* measTime, Decimal* delay);
00145 void checkAndSendImage();
00146
00147 void setImage(CVD::Image<CVD::byte>* imFrame);
00148 void setImageAndPose(IplImage* _imFrame, Pose3DandTime* pose = 0, int dataType = 0);
00149 void setImage(IplImage* imFrame);
00150 void show();
00151 bool loadImage();
00152 void clear();
00153 inline bool gotConnection(){return connection;};
00154 inline int getPoseType(){return poseType;};
00155 inline void setPoseType(int value){poseType = value;};
00156 inline void setLogActive(bool value){activateLog = value;};
00157 void setLogFile(char* value);
00158
00159
00160
00161
00162
00163
00164
00165 private:
00166
00167 int serversock, clientsock;
00168
00169 pthread_t thread_s;
00170 CVD::Image<CVD::byte> imageBW;
00171 pthread_mutex_t mutex;
00172 IplImage* _myFrame;
00173
00174 bool image_ready;
00175
00176 pthread_t threadVrpn;
00177 PTAMMVrpnHandler* PTAMMdataHandler;
00178 bool connection;
00179
00180 Pose3DandTime myRecPose3D;
00181
00182 Pose3DandTime mySndPose;
00183 int poseType;
00184
00185 bool poseReady;
00186 timeval prevTime;
00187
00188 bool activateLog;
00189 char* ptammLog;
00190 ofstream logFilePTAMM;
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201 };
00202
00203 };
00204
00205 #endif