53 _paths(
uSplit(databasePath,
';')),
54 _odometryIgnored(odometryIgnored),
55 _ignoreGoalDelay(ignoreGoalDelay),
56 _goalsIgnored(goalsIgnored),
57 _startIndex(startIndex),
58 _cameraIndex(cameraIndex),
60 _currentId(_ids.end()),
101 const std::string & calibrationFolder,
102 const std::string & cameraName)
120 UERROR(
"No database path set...");
124 std::string path =
_paths.front();
127 UERROR(
"Database path does not exist (%s)", path.c_str());
136 UERROR(
"Driver doesn't exist.");
141 UERROR(
"Can't open database %s", path.c_str());
152 if(iter ==
_ids.end())
154 UWARN(
"Start index is too high (%d), the last in database is %d. Starting from beginning...",
_startIndex,
_ids.size()-1);
164 std::vector<CameraModel> models;
170 if(models.at(0).isValidForProjection())
174 else if(models.at(0).fx() && models.at(0).fy() && models.at(0).imageWidth() == 0)
218 UINFO(
"no more images...");
219 while(
_paths.size() > 1 && data.
id() == 0)
222 UWARN(
"Loading next database \"%s\"...",
_paths.front().c_str());
225 UERROR(
"Failed to initialize the next database \"%s\"",
_paths.front().c_str());
237 double previousStamp = data.
stamp();
238 if(previousStamp == 0)
250 std::string goalStr = (
const char *)data.
userDataRaw().data;
253 std::list<std::string> strs =
uSplit(goalStr,
':');
256 goalId = *strs.rbegin();
268 Transform localTransform, pose, groundTruth;
269 std::vector<float> velocity;
272 if(previousStamp && stamp && stamp > previousStamp)
274 delay = stamp - previousStamp;
280 UWARN(
"Goal \"%s\" detected, posting it! Waiting %f seconds before sending next data...",
281 goalId.c_str(), delay);
285 UWARN(
"Goal \"%s\" detected, posting it!", goalId.c_str());
324 std::vector<float> velocity;
328 cv::Mat infMatrix = cv::Mat::eye(6,6,CV_64FC1);
331 std::map<int, Link> links;
333 if(links.size() && links.begin()->first < *
_currentId)
336 infMatrix = links.begin()->second.infMatrix();
343 UDEBUG(
"First node of map %d, variance set to 9999", mapId);
373 UERROR(
"The option to use database stamps is set (framerate<0), but there are no stamps saved in the database! Aborting...");
379 if(sleepTime > 10000)
381 UWARN(
"Detected long delay (%d sec, stamps = %f vs %f). Waiting a maximum of 10 seconds.",
444 UDEBUG(
"Laser=%d RGB/Left=%d Depth/Right=%d, UserData=%d",
454 UWARN(
"Reading the database: odometry is null! " 455 "Please set \"Ignore odometry = true\" if there is " 456 "no odometry in the database.");
470 UERROR(
"Not initialized...");
bool uIsInteger(const std::string &str, bool checkForSign=true)
std::list< std::string > _paths
cv::Mat _previousInfMatrix
static void post(UEvent *event, bool async=true, const UEventsSender *sender=0)
virtual bool init(const std::string &calibrationFolder=".", const std::string &cameraName="")
SensorData getNextData(CameraInfo *info=0)
void loadLinks(int signatureId, std::map< int, Link > &links, Link::Type type=Link::kUndef) const
void getAllNodeIds(std::set< int > &ids, bool ignoreChildren=false, bool ignoreBadSignatures=false) const
std::pair< std::string, std::string > ParametersPair
void getNodeData(int signatureId, SensorData &data, bool images=true, bool scan=true, bool userData=true, bool occupancyGrid=true) const
std::map< std::string, std::string > ParametersMap
void setGPS(const GPS &gps)
std::vector< float > odomVelocity
Some conversion functions.
bool getNodeInfo(int signatureId, Transform &pose, int &mapId, int &weight, std::string &label, double &stamp, Transform &groundTruthPose, std::vector< float > &velocity, GPS &gps) const
const LaserScan & laserScanRaw() const
const cv::Mat & imageRaw() const
void setUserData(const cv::Mat &userData)
DBReader(const std::string &databasePath, float frameRate=0.0f, bool odometryIgnored=false, bool ignoreGoalDelay=false, bool goalsIgnored=false, int startIndex=0, int cameraIndex=-1)
void setImageRaw(const cv::Mat &imageRaw)
std::list< std::string > uSplit(const std::string &str, char separator= ' ')
void setCameraModel(const CameraModel &model)
bool openConnection(const std::string &url, bool overwritten=false)
#define UASSERT(condition)
Wrappers of STL for convenient functions.
bool isValidForProjection() const
void closeConnection(bool save=true, const std::string &outputUrl="")
bool getCalibration(int signatureId, std::vector< CameraModel > &models, StereoCameraModel &stereoModel) const
const cv::Mat & depthOrRightRaw() const
const cv::Mat & userDataRaw() const
static DBDriver * create(const ParametersMap ¶meters=ParametersMap())
void uSleep(unsigned int ms)
float getImageRate() const
const std::vector< CameraModel > & cameraModels() const
std::list< V >::iterator uIteratorAt(std::list< V > &list, const unsigned int &pos)
virtual bool isCalibrated() const
ULogger class and convenient macros.
void setStamp(double stamp)
const cv::Mat & imageCompressed() const
std::set< int >::iterator _currentId
void setGroundTruth(const Transform &pose)
void setDepthOrRightRaw(const cv::Mat &depthOrImageRaw)
virtual SensorData captureImage(CameraInfo *info=0)
virtual std::string getSerial() const