mirror of
https://github.com/introlab/rtabmap.git
synced 2026-09-01 17:10:26 +08:00
Odometry: added "local map history" option to increase precision Added new Nearest neighbor options (LSH, brute Force, GPU brute Force) Added FREAK/ORB features Increased version to 0.6.5 git-svn-id: http://rtabmap.googlecode.com/svn/trunk/rtabmap@1431 f169173b-cf89-36c8-b27e-44dbe73f0c83
97 lines
3.3 KiB
C++
97 lines
3.3 KiB
C++
/*
|
|
* Copyright (C) 2010-2011, Mathieu Labbe and IntRoLab - Universite de Sherbrooke
|
|
*
|
|
* This file is part of RTAB-Map.
|
|
*
|
|
* RTAB-Map is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* RTAB-Map is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with RTAB-Map. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
#include "rtabmap/core/Rtabmap.h"
|
|
#include "rtabmap/core/RtabmapThread.h"
|
|
#include "rtabmap/core/CameraRGBD.h"
|
|
#include "rtabmap/core/CameraThread.h"
|
|
#include "rtabmap/core/Odometry.h"
|
|
#include "rtabmap/utilite/UEventsManager.h"
|
|
#include <QtGui/QApplication>
|
|
#include <stdio.h>
|
|
|
|
#include "MapBuilder.h"
|
|
|
|
using namespace rtabmap;
|
|
int main(int argc, char * argv[])
|
|
{
|
|
ULogger::setType(ULogger::kTypeConsole);
|
|
ULogger::setLevel(ULogger::kWarning);
|
|
|
|
// GUI stuff, there the handler will receive RtabmapEvent and construct the map
|
|
QApplication app(argc, argv);
|
|
MapBuilder mapBuilder;
|
|
|
|
// Here is the pipeline that we will use:
|
|
// CameraOpenni -> "CameraEvent" -> OdometryThread -> "OdometryEvent" -> RtabmapThread -> "RtabmapEvent"
|
|
|
|
// Create the OpenNI camera, it will send a CameraEvent at the rate specified.
|
|
// Set transform to camera so z is up, y is left and x going forward
|
|
CameraRGBD * camera = new CameraOpenni("", 10, rtabmap::Transform(0,0,1,0, -1,0,0,0, 0,-1,0,0));
|
|
//CameraRGBD * camera = new CameraFreenect(0, 10, rtabmap::Transform(0,0,1,0, -1,0,0,0, 0,-1,0,0));
|
|
CameraThread cameraThread(camera);
|
|
if(!cameraThread.init())
|
|
{
|
|
UERROR("Camera init failed!");
|
|
exit(1);
|
|
}
|
|
|
|
// Create an odometry thread to process camera events, it will send OdometryEvent.
|
|
OdometryThread odomThread(new OdometryBOW()); // 0=SURF 1=SIFT
|
|
|
|
|
|
// Create RTAB-Map to process OdometryEvent
|
|
Rtabmap * rtabmap = new Rtabmap();
|
|
rtabmap->init();
|
|
RtabmapThread rtabmapThread(rtabmap); // ownership is transfered
|
|
|
|
// Setup handlers
|
|
odomThread.registerToEventsManager();
|
|
rtabmapThread.registerToEventsManager();
|
|
mapBuilder.registerToEventsManager();
|
|
|
|
// The RTAB-Map is subscribed by default to CameraEvent, but we want
|
|
// RTAB-Map to process OdometryEvent instead, ignoring the CameraEvent.
|
|
// We can do that by creating a "pipe" between the camera and odometry, then
|
|
// only the odometry will receive CameraEvent from that camera. RTAB-Map is
|
|
// also subscribed to OdometryEvent by default, so no need to create a pipe between
|
|
// odometry and RTAB-Map.
|
|
UEventsManager::createPipe(&cameraThread, &odomThread, "CameraEvent");
|
|
|
|
// Let's start the threads
|
|
rtabmapThread.start();
|
|
odomThread.start();
|
|
cameraThread.start();
|
|
|
|
mapBuilder.show();
|
|
app.exec(); // main loop
|
|
|
|
// remove handlers
|
|
mapBuilder.unregisterFromEventsManager();
|
|
rtabmapThread.unregisterFromEventsManager();
|
|
odomThread.unregisterFromEventsManager();
|
|
|
|
// Kill all threads
|
|
cameraThread.kill();
|
|
odomThread.join(true);
|
|
rtabmapThread.join(true);
|
|
|
|
return 0;
|
|
}
|