38 #include <QApplication>
40 #include <pcl/io/pcd_io.h>
41 #include <pcl/io/ply_io.h>
42 #include <pcl/filters/filter.h>
50 "rtabmap-lidar_mapping IP PORT\n"
51 "rtabmap-lidar_mapping PCAP_FILEPATH\n"
54 " rtabmap-lidar_mapping 192.168.1.201 2368\n\n");
88 printf(
"Using ip=%s port=%d\n", ip.c_str(), port);
89 lidar =
new LidarVLP16(boost::asio::ip::address_v4::from_string(ip), port);
94 printf(
"Using file=%s\n", filepath.c_str());
101 UERROR(
"Lidar init failed!");
115 float resolution = 0.05;
175 rtabmapThread.
start();
179 printf(
"Press Tab key to switch between map and odom views (or both).\n");
180 printf(
"Press Space key to pause.\n");
192 odomThread.
join(
true);
193 rtabmapThread.
join(
true);
196 printf(
"Saving rtabmap_cloud.pcd...\n");
197 std::map<int, Signature>
nodes;
198 std::map<int, Transform> optimizedPoses;
199 std::multimap<int, Link> links;
200 rtabmap->getGraph(optimizedPoses, links,
true,
true, &
nodes,
true,
true,
true,
true);
201 pcl::PointCloud<pcl::PointXYZI>::Ptr cloud(
new pcl::PointCloud<pcl::PointXYZI>);
202 for(std::map<int, Transform>::iterator
iter=optimizedPoses.begin();
iter!=optimizedPoses.end(); ++
iter)
214 printf(
"Voxel grid filtering of the assembled cloud (voxel=%f, %d points)\n", 0.01
f, (
int)cloud->size());
217 printf(
"Saving rtabmap_cloud.pcd... done! (%d points)\n", (
int)cloud->size());
218 pcl::io::savePCDFile(
"rtabmap_cloud.pcd", *cloud);
223 printf(
"Saving rtabmap_cloud.pcd... failed! The cloud is empty.\n");
227 printf(
"Saving rtabmap_trajectory.txt ...\n");
228 if(optimizedPoses.size() &&
graph::exportPoses(
"rtabmap_trajectory.txt", 0, optimizedPoses, links))
230 printf(
"Saving rtabmap_trajectory.txt... done!\n");
234 printf(
"Saving rtabmap_trajectory.txt... failed!\n");