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 "MapBuilder.h"
00039
00040 void showUsage()
00041 {
00042 printf("\nUsage:\n"
00043 "rtabmap-rgbd_mapping driver\n"
00044 " driver Driver number to use: 0=OpenNI-PCL, 1=OpenNI2, 2=Freenect, 3=OpenNI-CV, 4=OpenNI-CV-ASUS\n\n");
00045 exit(1);
00046 }
00047
00048 using namespace rtabmap;
00049 int main(int argc, char * argv[])
00050 {
00051 ULogger::setType(ULogger::kTypeConsole);
00052 ULogger::setLevel(ULogger::kWarning);
00053
00054 int driver = 0;
00055 if(argc < 2)
00056 {
00057 showUsage();
00058 }
00059 else
00060 {
00061 driver = atoi(argv[argc-1]);
00062 if(driver < 0 || driver > 4)
00063 {
00064 UERROR("driver should be between 0 and 4.");
00065 showUsage();
00066 }
00067 }
00068
00069
00070
00071
00072
00073
00074 CameraRGBD * camera = 0;
00075 Transform opticalRotation(0,0,1,0, -1,0,0,0, 0,-1,0,0);
00076 if(driver == 1)
00077 {
00078 if(!CameraOpenNI2::available())
00079 {
00080 UERROR("Not built with OpenNI2 support...");
00081 exit(-1);
00082 }
00083 camera = new CameraOpenNI2("", 0, opticalRotation);
00084 }
00085 else if(driver == 2)
00086 {
00087 if(!CameraFreenect::available())
00088 {
00089 UERROR("Not built with Freenect support...");
00090 exit(-1);
00091 }
00092 camera = new CameraFreenect(0, 0, opticalRotation);
00093 }
00094 else if(driver == 3)
00095 {
00096 if(!CameraOpenNICV::available())
00097 {
00098 UERROR("Not built with OpenNI from OpenCV support...");
00099 exit(-1);
00100 }
00101 camera = new CameraOpenNICV(false, 0, opticalRotation);
00102 }
00103 else if(driver == 4)
00104 {
00105 if(!CameraOpenNICV::available())
00106 {
00107 UERROR("Not built with OpenNI from OpenCV support...");
00108 exit(-1);
00109 }
00110 camera = new CameraOpenNICV(true, 0, opticalRotation);
00111 }
00112 else
00113 {
00114 camera = new rtabmap::CameraOpenni("", 0, opticalRotation);
00115 }
00116
00117 CameraThread cameraThread(camera);
00118 if(!cameraThread.init())
00119 {
00120 UERROR("Camera init failed!");
00121 exit(1);
00122 }
00123
00124
00125
00126 QApplication app(argc, argv);
00127 MapBuilder mapBuilder(&cameraThread);
00128
00129
00130 OdometryThread odomThread(new OdometryBOW());
00131
00132
00133
00134 Rtabmap * rtabmap = new Rtabmap();
00135 rtabmap->init();
00136 RtabmapThread rtabmapThread(rtabmap);
00137
00138
00139 odomThread.registerToEventsManager();
00140 rtabmapThread.registerToEventsManager();
00141 mapBuilder.registerToEventsManager();
00142
00143
00144
00145
00146
00147
00148
00149 UEventsManager::createPipe(&cameraThread, &odomThread, "CameraEvent");
00150
00151
00152 rtabmapThread.start();
00153 odomThread.start();
00154 cameraThread.start();
00155
00156 mapBuilder.show();
00157 app.exec();
00158
00159
00160 mapBuilder.unregisterFromEventsManager();
00161 rtabmapThread.unregisterFromEventsManager();
00162 odomThread.unregisterFromEventsManager();
00163
00164
00165 cameraThread.kill();
00166 odomThread.join(true);
00167 rtabmapThread.join(true);
00168
00169 return 0;
00170 }