32 #include <pcl/visualization/cloud_viewer.h> 34 #include <QApplication> 42 "rtabmap-noEventsExample camera_rate odom_update map_update calibration_dir calibration_name path_left_images path_right_images\n" 44 " camera_rate Rate (Hz) of the camera.\n" 45 " odom_update Do odometry update each X camera frames.\n" 46 " map_update Do map update each X odometry frames.\n" 49 " (with images from \"https://github.com/introlab/rtabmap/wiki/Stereo-mapping#process-a-directory-of-stereo-images\") \n" 50 " $ rtabmap-noEventsExample 20 2 10 stereo_20Hz stereo_20Hz stereo_20Hz/left stereo_20Hz/right\n" 51 " Camera rate = 20 Hz\n" 52 " Odometry update rate = 10 Hz\n" 53 " Map update rate = 1 Hz\n");
57 int main(
int argc,
char * argv[])
68 int cameraRate = atoi(argv[argIndex++]);
71 printf(
"camera_rate should be > 0\n");
74 int odomUpdate = atoi(argv[argIndex++]);
77 printf(
"odom_update should be > 0\n");
80 int mapUpdate = atoi(argv[argIndex++]);
83 printf(
"map_update should be > 0\n");
87 printf(
"Camera rate = %d Hz\n", cameraRate);
88 printf(
"Odometry update rate = %d Hz\n", cameraRate/odomUpdate);
89 printf(
"Map update rate = %d Hz\n", (cameraRate/odomUpdate)/mapUpdate);
91 std::string calibrationDir = argv[argIndex++];
92 std::string calibrationName = argv[argIndex++];
93 std::string pathLeftImages = argv[argIndex++];
94 std::string pathRightImages = argv[argIndex++];
96 Transform opticalRotation(0,0,1,0, -1,0,0,0, 0,-1,0,0);
104 if(camera.
init(calibrationDir, calibrationName))
110 QApplication
app(argc, argv);
113 QApplication::processEvents();
116 int cameraIteration = 0;
117 int odometryIteration = 0;
118 printf(
"Press \"Space\" in the window to pause\n");
119 while(data.
isValid() && mapBuilder.isVisible())
121 if(cameraIteration++ % odomUpdate == 0)
126 if(odometryIteration++ % mapUpdate == 0)
128 if(rtabmap.
process(data, pose))
133 printf(
"Loop closure detected!\n");
141 QApplication::processEvents();
143 while(mapBuilder.
isPaused() && mapBuilder.isVisible())
146 QApplication::processEvents();
152 if(mapBuilder.isVisible())
154 printf(
"Processed all frames\n");
160 UERROR(
"Camera init failed!");
void processStatistics(const rtabmap::Statistics &stats)
void processOdometry(const SensorData &data, Transform pose, const rtabmap::OdometryInfo &odom)
virtual bool init(const std::string &calibrationFolder=".", const std::string &cameraName="")
static void setLevel(ULogger::Level level)
static rtabmap::Transform opticalRotation(1.0f, 0.0f, 0.0f, 0.0f, 0.0f,-1.0f, 0.0f, 0.0f, 0.0f, 0.0f,-1.0f, 0.0f)
int main(int argc, char *argv[])
Transform process(SensorData &data, OdometryInfo *info=0)
SensorData takeImage(CameraInfo *info=0)
int getLoopClosureId() const
const Statistics & getStatistics() const
static void setType(Type type, const std::string &fileName=kDefaultLogFileName, bool append=true)
bool process(const SensorData &data, Transform odomPose, const cv::Mat &odomCovariance=cv::Mat::eye(6, 6, CV_64FC1), const std::vector< float > &odomVelocity=std::vector< float >(), const std::map< std::string, float > &externalStats=std::map< std::string, float >())
Main loop of rtabmap.
void init(const ParametersMap ¶meters, const std::string &databasePath="")
void uSleep(unsigned int ms)