37 #include <QApplication> 39 #include <pcl/io/pcd_io.h> 40 #include <pcl/io/ply_io.h> 41 #include <pcl/filters/filter.h> 48 "rtabmap-rgbd_mapping driver\n" 49 " driver Driver number to use: 0=OpenNI-PCL, 1=OpenNI2, 2=Freenect, 3=OpenNI-CV, 4=OpenNI-CV-ASUS, 5=Freenect2, 6=ZED SDK, 7=RealSense, 8=RealSense2 9=Kinect for Azure SDK 10=MYNT EYE S\n\n");
66 driver = atoi(argv[argc-1]);
67 if(driver < 0 || driver > 10)
69 UERROR(
"driver should be between 0 and 10.");
84 UERROR(
"Not built with OpenNI2 support...");
93 UERROR(
"Not built with Freenect support...");
102 UERROR(
"Not built with OpenNI from OpenCV support...");
111 UERROR(
"Not built with OpenNI from OpenCV support...");
116 else if (driver == 5)
120 UERROR(
"Not built with Freenect2 support...");
125 else if (driver == 6)
129 UERROR(
"Not built with ZED SDK support...");
134 else if (driver == 7)
138 UERROR(
"Not built with RealSense support...");
143 else if (driver == 8)
147 UERROR(
"Not built with RealSense2 support...");
152 else if (driver == 9)
156 UERROR(
"Not built with Kinect for Azure SDK support...");
161 else if (driver == 10)
165 UERROR(
"Not built with Mynt Eye S support...");
177 UERROR(
"Camera init failed!");
185 QApplication
app(argc, argv);
197 rtabmap->
init(params);
214 rtabmapThread.
start();
216 cameraThread.
start();
228 odomThread.
join(
true);
229 rtabmapThread.
join(
true);
232 printf(
"Saving rtabmap_cloud.pcd...\n");
233 std::map<int, Signature> nodes;
234 std::map<int, Transform> optimizedPoses;
235 std::multimap<int, Link> links;
236 rtabmap->
getGraph(optimizedPoses, links,
true,
true, &nodes,
true,
true,
true,
true);
237 pcl::PointCloud<pcl::PointXYZRGB>::Ptr cloud(
new pcl::PointCloud<pcl::PointXYZRGB>);
238 for(std::map<int, Transform>::iterator iter=optimizedPoses.begin(); iter!=optimizedPoses.end(); ++iter)
240 Signature node = nodes.find(iter->first)->second;
250 pcl::PointCloud<pcl::PointXYZRGB>::Ptr tmpNoNaN(
new pcl::PointCloud<pcl::PointXYZRGB>);
251 std::vector<int> index;
253 if(!tmpNoNaN->empty())
260 printf(
"Voxel grid filtering of the assembled cloud (voxel=%f, %d points)\n", 0.01
f, (
int)cloud->size());
263 printf(
"Saving rtabmap_cloud.pcd... done! (%d points)\n", (
int)cloud->size());
264 pcl::io::savePCDFile(
"rtabmap_cloud.pcd", *cloud);
269 printf(
"Saving rtabmap_cloud.pcd... failed! The cloud is empty.\n");
273 printf(
"Saving rtabmap_trajectory.txt ...\n");
274 if(optimizedPoses.size() &&
graph::exportPoses(
"rtabmap_trajectory.txt", 0, optimizedPoses, links))
276 printf(
"Saving rtabmap_trajectory.txt... done!\n");
280 printf(
"Saving rtabmap_trajectory.txt... failed!\n");
283 rtabmap->
close(
false);
static void createPipe(const UEventsSender *sender, const UEventsHandler *receiver, const std::string &eventName)
pcl::PointCloud< pcl::PointXYZ >::Ptr RTABMAP_EXP transformPointCloud(const pcl::PointCloud< pcl::PointXYZ >::Ptr &cloud, const Transform &transform)
pcl::PointCloud< pcl::PointXYZ >::Ptr RTABMAP_EXP removeNaNFromPointCloud(const pcl::PointCloud< pcl::PointXYZ >::Ptr &cloud)
std::map< std::string, std::string > ParametersMap
void init(const ParametersMap ¶meters, const std::string &databasePath="", bool loadDatabaseParameters=false)
static void setLevel(ULogger::Level level)
void getGraph(std::map< int, Transform > &poses, std::multimap< int, Link > &constraints, bool optimized, bool global, std::map< int, Signature > *signatures=0, bool withImages=false, bool withScan=false, bool withUserData=false, bool withGrid=false, bool withWords=true, bool withGlobalDescriptors=true) const
virtual bool init(const std::string &calibrationFolder=".", const std::string &cameraName="")=0
void close(bool databaseSaved=true, const std::string &ouputDatabasePath="")
static Odometry * create(const ParametersMap ¶meters=ParametersMap())
pcl::PointCloud< pcl::PointXYZRGB >::Ptr RTABMAP_EXP cloudRGBFromSensorData(const SensorData &sensorData, int decimation=1, float maxDepth=0.0f, float minDepth=0.0f, std::vector< int > *validIndices=0, const ParametersMap &stereoParameters=ParametersMap(), const std::vector< float > &roiRatios=std::vector< float >())
static void setType(Type type, const std::string &fileName=kDefaultLogFileName, bool append=true)
int main(int argc, char *argv[])
bool RTABMAP_EXP exportPoses(const std::string &filePath, int format, const std::map< int, Transform > &poses, const std::multimap< int, Link > &constraints=std::multimap< int, Link >(), const std::map< int, double > &stamps=std::map< int, double >(), const ParametersMap ¶meters=ParametersMap())
void registerToEventsManager()
SensorData & sensorData()
void unregisterFromEventsManager()
void join(bool killFirst=false)
pcl::PointCloud< pcl::PointXYZ >::Ptr RTABMAP_EXP voxelize(const pcl::PointCloud< pcl::PointXYZ >::Ptr &cloud, const pcl::IndicesPtr &indices, float voxelSize)