42 #include <QApplication> 43 #include <QPushButton> 44 #include <pcl/console/print.h> 50 "odometryViewer [options]\n" 52 " -driver # Driver number to use: 0=OpenNI-PCL, 1=OpenNI2, 2=Freenect, 3=OpenNI-CV, 4=OpenNI-CV-ASUS, 5=Freenect2, 6=dc1394, 7=FlyCapture2\n" 53 " -hz #.# Camera rate (default 0, 0 means as fast as the camera can)\n" 54 " -db \"input.db\" Use database instead of camera (recorded with rtabmap-dataRecorder)\n" 55 " -clouds # Maximum clouds shown (default 10, zero means inf)\n" 56 " -sec #.# Delay (seconds) before reading the database (if set)\n" 62 int main (
int argc,
char * argv[])
69 std::string inputDatabase;
74 for(
int i=1; i<argc; ++i)
76 if(strcmp(argv[i],
"-driver") == 0)
81 driver = std::atoi(argv[i]);
82 if(driver < 0 || driver > 7)
93 if(strcmp(argv[i],
"-hz") == 0)
110 if(strcmp(argv[i],
"-db") == 0)
115 inputDatabase = argv[i];
118 printf(
"Database path (%s) should end with \"db\" \n", inputDatabase.c_str());
128 if(strcmp(argv[i],
"-clouds") == 0)
133 maxClouds = std::atoi(argv[i]);
145 if(strcmp(argv[i],
"-sec") == 0)
162 if(strcmp(argv[i],
"-help") == 0 || strcmp(argv[i],
"--help") == 0)
168 if(inputDatabase.size())
170 UINFO(
"Using database input \"%s\"", inputDatabase.c_str());
174 UINFO(
"Using OpenNI camera");
177 UINFO(
"Camera rate = %f Hz", rate);
178 UINFO(
"Maximum clouds shown = %d", maxClouds);
179 UINFO(
"Delay = %f s", sec);
182 for(rtabmap::ParametersMap::iterator iter=parameters.begin(); iter!=parameters.end(); ++iter)
184 UINFO(
" Param \"%s\"=\"%s\"", iter->first.c_str(), iter->second.c_str());
188 int regStrategy = rtabmap::Parameters::defaultRegStrategy();
191 float maxDepth = 4.0f;
192 float voxelSize = rtabmap::Parameters::defaultIcpVoxelSize();
194 float normalsRadius = 0.0f;
195 if(regStrategy == 1 || regStrategy == 2)
203 bool pointToPlane = rtabmap::Parameters::defaultIcpPointToPlane();
207 normalsK = rtabmap::Parameters::defaultIcpPointToPlaneK();
209 normalsRadius = rtabmap::Parameters::defaultIcpPointToPlaneRadius();
217 QApplication
app(argc, argv);
226 odomViewer.setWindowTitle(
"Odometry view");
227 odomViewer.resize(1280, 480+QPushButton().minimumHeight());
230 rtabmap::Transform t=
rtabmap::Transform(0,0,1,0, -1,0,0,0, 0,-1,0,0);
232 if(inputDatabase.size())
244 UERROR(
"Not built with OpenNI2 support...");
253 UERROR(
"Not built with Freenect support...");
262 UERROR(
"Not built with OpenNI from OpenCV support...");
271 UERROR(
"Not built with OpenNI from OpenCV support...");
280 UERROR(
"Not built with Freenect2 support...");
289 UERROR(
"Not built with dc1394 support...");
298 UERROR(
"Not built with FlyCapture2/Triclops support...");
305 UFATAL(
"Camera driver (%d) not found!", driver);
316 cameraThread.
setScanFromDepth(icp, decimation<1?1:decimation, maxDepth, voxelSize, normalsK, normalsRadius);
319 cameraThread.
start();
323 cameraThread.
join(
true);
324 odomThread.
join(
true);
328 printf(
"The camera is not calibrated! You should calibrate the camera first.\n");
334 printf(
"Failed to initialize the camera! Please select another driver (see \"--help\").\n");
static bool parse(const ParametersMap ¶meters, const std::string &key, bool &value)
GLM_FUNC_DECL genType sec(genType const &angle)
static const char * showUsage()
std::pair< std::string, std::string > ParametersPair
static ParametersMap parseArguments(int argc, char *argv[], bool onlyParameters=false)
float UTILITE_EXP uStr2Float(const std::string &str)
std::map< std::string, std::string > ParametersMap
Some conversion functions.
std::string getExtension()
static void setLevel(ULogger::Level level)
virtual bool init(const std::string &calibrationFolder=".", const std::string &cameraName="")=0
Wrappers of STL for convenient functions.
virtual bool isCalibrated() const =0
Transform RTABMAP_EXP icp(const pcl::PointCloud< pcl::PointXYZ >::ConstPtr &cloud_source, const pcl::PointCloud< pcl::PointXYZ >::ConstPtr &cloud_target, double maxCorrespondenceDistance, int maximumIterations, bool &hasConverged, pcl::PointCloud< pcl::PointXYZ > &cloud_source_registered, float epsilon=0.0f, bool icp2D=false)
static void setType(Type type, const std::string &fileName=kDefaultLogFileName, bool append=true)
static Odometry * create(const ParametersMap ¶meters)
void setScanFromDepth(bool enabled, int decimation=4, float maxDepth=4.0f, float voxelSize=0.0f, int normalsK=0, int normalsRadius=0.0f)
static void addHandler(UEventsHandler *handler)
ULogger class and convenient macros.
void join(bool killFirst=false)
int main(int argc, char *argv[])
void uInsert(std::map< K, V > &map, const std::pair< K, V > &pair)