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
00026
00027
00028 #include "rtabmap/core/Rtabmap.h"
00029 #include "rtabmap/core/RtabmapThread.h"
00030 #include "rtabmap/core/CameraRGBD.h"
00031 #include "rtabmap/core/CameraThread.h"
00032 #include "rtabmap/core/Odometry.h"
00033 #include "rtabmap/core/OdometryThread.h"
00034 #include "rtabmap/utilite/UEventsManager.h"
00035 #include <QApplication>
00036 #include <stdio.h>
00037
00038 #include "MapBuilderWifi.h"
00039
00040 #include "WifiThread.h"
00041
00042 void showUsage()
00043 {
00044 printf("\nUsage:\n"
00045 "rtabmap-wifi_mapping [options]\n"
00046 "Options:\n"
00047 " -i \"name\" Wifi interface name (e.g. \"eth0\"). Only required on Linux.\n"
00048 " -m Enable mirroring of the camera image.\n"
00049 " -d # Driver number to use: 0=OpenNI-PCL, 1=OpenNI2, 2=Freenect, 3=OpenNI-CV, 4=OpenNI-CV-ASUS\n\n");
00050 exit(1);
00051 }
00052
00053 using namespace rtabmap;
00054 int main(int argc, char * argv[])
00055 {
00056 ULogger::setType(ULogger::kTypeConsole);
00057 ULogger::setLevel(ULogger::kWarning);
00058
00059 std::string interfaceName = "eth0";
00060 int driver = 0;
00061 bool mirroring = false;
00062
00063
00064 for(int i = 1; i<argc; ++i)
00065 {
00066 if(strcmp(argv[i], "-i") == 0)
00067 {
00068 ++i;
00069 if(i < argc)
00070 {
00071 interfaceName = argv[i];
00072 }
00073 else
00074 {
00075 showUsage();
00076 }
00077 continue;
00078 }
00079 if(strcmp(argv[i], "-m") == 0)
00080 {
00081 mirroring = true;
00082 continue;
00083 }
00084 if(strcmp(argv[i], "-d") == 0)
00085 {
00086 ++i;
00087 if(i < argc)
00088 {
00089 driver = atoi(argv[i]);
00090 if(driver < 0 || driver > 4)
00091 {
00092 UERROR("driver should be between 0 and 4.");
00093 showUsage();
00094 }
00095 }
00096 else
00097 {
00098 showUsage();
00099 }
00100 continue;
00101 }
00102
00103 UERROR("Option \"%s\" not recognized!", argv[i]);
00104 showUsage();
00105 }
00106
00107
00108
00109
00110
00111
00112 CameraRGBD * camera = 0;
00113 Transform opticalRotation(0,0,1,0, -1,0,0,0, 0,-1,0,0);
00114 if(driver == 1)
00115 {
00116 if(!CameraOpenNI2::available())
00117 {
00118 UERROR("Not built with OpenNI2 support...");
00119 exit(-1);
00120 }
00121 camera = new CameraOpenNI2("", 0, opticalRotation);
00122 }
00123 else if(driver == 2)
00124 {
00125 if(!CameraFreenect::available())
00126 {
00127 UERROR("Not built with Freenect support...");
00128 exit(-1);
00129 }
00130 camera = new CameraFreenect(0, 0, opticalRotation);
00131 }
00132 else if(driver == 3)
00133 {
00134 if(!CameraOpenNICV::available())
00135 {
00136 UERROR("Not built with OpenNI from OpenCV support...");
00137 exit(-1);
00138 }
00139 camera = new CameraOpenNICV(false, 0, opticalRotation);
00140 }
00141 else if(driver == 4)
00142 {
00143 if(!CameraOpenNICV::available())
00144 {
00145 UERROR("Not built with OpenNI from OpenCV support...");
00146 exit(-1);
00147 }
00148 camera = new CameraOpenNICV(true, 0, opticalRotation);
00149 }
00150 else
00151 {
00152 camera = new rtabmap::CameraOpenni("", 0, opticalRotation);
00153 }
00154
00155 if(mirroring)
00156 {
00157 camera->setMirroringEnabled(true);
00158 }
00159
00160 CameraThread cameraThread(camera);
00161 if(!cameraThread.init())
00162 {
00163 UERROR("Camera init failed!");
00164
00165 }
00166
00167
00168
00169 QApplication app(argc, argv);
00170 MapBuilderWifi mapBuilderWifi(&cameraThread);
00171
00172
00173 OdometryThread odomThread(new OdometryBOW());
00174
00175
00176 Rtabmap * rtabmap = new Rtabmap();
00177 ParametersMap param;
00178 param.insert(ParametersPair(Parameters::kMemRehearsalSimilarity(), "1.0"));
00179 rtabmap->init(param);
00180 RtabmapThread rtabmapThread(rtabmap);
00181
00182
00183 WifiThread wifiThread(interfaceName);
00184
00185
00186 odomThread.registerToEventsManager();
00187 rtabmapThread.registerToEventsManager();
00188 mapBuilderWifi.registerToEventsManager();
00189
00190
00191
00192
00193
00194
00195
00196 UEventsManager::createPipe(&cameraThread, &odomThread, "CameraEvent");
00197
00198
00199 rtabmapThread.start();
00200 odomThread.start();
00201 cameraThread.start();
00202 wifiThread.start();
00203
00204 mapBuilderWifi.show();
00205 app.exec();
00206
00207
00208 mapBuilderWifi.unregisterFromEventsManager();
00209 rtabmapThread.unregisterFromEventsManager();
00210 odomThread.unregisterFromEventsManager();
00211
00212
00213 cameraThread.kill();
00214 odomThread.join(true);
00215 rtabmapThread.join(true);
00216 wifiThread.join(true);
00217
00218 return 0;
00219 }