RtabmapThread.cpp
Go to the documentation of this file.
1 /*
2 Copyright (c) 2010-2016, Mathieu Labbe - IntRoLab - Universite de Sherbrooke
3 All rights reserved.
4 
5 Redistribution and use in source and binary forms, with or without
6 modification, are permitted provided that the following conditions are met:
7  * Redistributions of source code must retain the above copyright
8  notice, this list of conditions and the following disclaimer.
9  * Redistributions in binary form must reproduce the above copyright
10  notice, this list of conditions and the following disclaimer in the
11  documentation and/or other materials provided with the distribution.
12  * Neither the name of the Universite de Sherbrooke nor the
13  names of its contributors may be used to endorse or promote products
14  derived from this software without specific prior written permission.
15 
16 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
20 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27 
28 #include "rtabmap/core/Rtabmap.h"
31 #include "rtabmap/core/Camera.h"
36 #include "rtabmap/core/Memory.h"
37 
40 #include <rtabmap/utilite/UStl.h>
41 #include <rtabmap/utilite/UTimer.h>
43 
44 namespace rtabmap {
45 
47  _dataBufferMaxSize(Parameters::defaultRtabmapImageBufferSize()),
48  _rate(Parameters::defaultRtabmapDetectionRate()),
49  _createIntermediateNodes(Parameters::defaultRtabmapCreateIntermediateNodes()),
50  _frameRateTimer(new UTimer()),
51  _previousStamp(0.0),
52  _rtabmap(rtabmap),
53  _paused(false),
54  lastPose_(Transform::getIdentity())
55 
56 {
57  UASSERT(rtabmap != 0);
58 }
59 
61 {
63 
64  close(true);
65 
66  delete _frameRateTimer;
67 }
68 
69 void RtabmapThread::pushNewState(State newState, const ParametersMap & parameters)
70 {
71  ULOGGER_DEBUG("to %d", newState);
72 
73  _stateMutex.lock();
74  {
75  _state.push(newState);
76  _stateParam.push(parameters);
77  }
79 
81 }
82 
84 {
85  _dataMutex.lock();
86  {
87  _dataBuffer.clear();
88  _newMapEvents.clear();
90  covariance_ = cv::Mat();
91  _previousStamp = 0;
92  }
94 
96  {
97  _userData = cv::Mat();
98  }
100 }
101 
103 {
104  UASSERT(rate >= 0.0f);
105  _rate = rate;
106 }
107 
108 void RtabmapThread::setDataBufferSize(unsigned int size)
109 {
110  _dataBufferMaxSize = size;
111 }
112 
114 {
115  _createIntermediateNodes = enabled;
116 }
117 
118 void RtabmapThread::close(bool databaseSaved, const std::string & ouputDatabasePath)
119 {
120  this->join(true);
121  if(_rtabmap)
122  {
123  _rtabmap->close(databaseSaved, ouputDatabasePath);
124  delete _rtabmap;
125  _rtabmap = 0;
126  }
127 }
128 
129 void RtabmapThread::publishMap(bool optimized, bool full, bool graphOnly) const
130 {
131  UDEBUG("optimized=%s, full=%s, graphOnly=%s", optimized?"true":"false", full?"true":"false", graphOnly?"true":"false");
132  if(_rtabmap)
133  {
134  std::map<int, Signature> signatures;
135  std::map<int, Transform> poses;
136  std::multimap<int, Link> constraints;
137  std::map<int, int> mapIds;
138  std::map<int, double> stamps;
139  std::map<int, std::string> labels;
140  std::map<int, std::vector<unsigned char> > userDatas;
141 
142  _rtabmap->getGraph(poses,
143  constraints,
144  optimized,
145  full,
146  &signatures,
147  !graphOnly,
148  !graphOnly,
149  !graphOnly,
150  !graphOnly);
151 
152  this->post(new RtabmapEvent3DMap(
153  signatures,
154  poses,
155  constraints));
156  }
157  else
158  {
159  UERROR("Rtabmap is null!");
160  }
161 }
162 
164 {
166  if(_rtabmap == 0)
167  {
168  UERROR("Cannot start rtabmap thread if no rtabmap object is set! Stopping the thread...");
169  this->kill();
170  }
171 }
172 
174 {
175  this->clearBufferedData();
176  // this will post the newData semaphore
178 }
179 
181 {
183  ParametersMap parameters;
184 
185  _stateMutex.lock();
186  {
187  if(!_state.empty() && !_stateParam.empty())
188  {
189  state = _state.front();
190  _state.pop();
191  parameters = _stateParam.front();
192  _stateParam.pop();
193  }
194  }
196 
197  int id = 0;
198  cv::Mat userData;
199  UTimer timer;
200  std::string str;
201  switch(state)
202  {
203  case kStateDetecting:
204  this->process();
205  break;
206  case kStateInit:
207  UASSERT(!parameters.at("RtabmapThread/DatabasePath").empty());
208  str = parameters.at("RtabmapThread/DatabasePath");
209  parameters.erase("RtabmapThread/DatabasePath");
210  Parameters::parse(parameters, Parameters::kRtabmapImageBufferSize(), _dataBufferMaxSize);
211  Parameters::parse(parameters, Parameters::kRtabmapDetectionRate(), _rate);
212  Parameters::parse(parameters, Parameters::kRtabmapCreateIntermediateNodes(), _createIntermediateNodes);
213  UASSERT(_rate >= 0.0f);
214  _rtabmap->init(parameters, str);
215  break;
217  Parameters::parse(parameters, Parameters::kRtabmapImageBufferSize(), _dataBufferMaxSize);
218  Parameters::parse(parameters, Parameters::kRtabmapDetectionRate(), _rate);
219  Parameters::parse(parameters, Parameters::kRtabmapCreateIntermediateNodes(), _createIntermediateNodes);
220  UASSERT(_rate >= 0.0f);
221  _rtabmap->parseParameters(parameters);
222  break;
223  case kStateReseting:
225  this->clearBufferedData();
226  break;
227  case kStateClose:
228  if(_dataBuffer.size())
229  {
230  UWARN("Closing... %d data still buffered! They will be cleared.", (int)_dataBuffer.size());
231  this->clearBufferedData();
232  }
233  _rtabmap->close(uStr2Bool(parameters.at("saved")), parameters.at("outputPath"));
234  break;
235  case kStateDumpingMemory:
236  _rtabmap->dumpData();
237  break;
240  break;
243  parameters.at("path"),
244  atoi(parameters.at("id").c_str()),
245  atoi(parameters.at("margin").c_str()));
246  break;
249  parameters.at("path"),
250  uStr2Bool(parameters.at("optimized")),
251  uStr2Bool(parameters.at("global")),
252  atoi(parameters.at("type").c_str()));
253  break;
255  this->clearBufferedData();
256  break;
257  case kStatePublishingMap:
258  this->publishMap(
259  uStr2Bool(parameters.at("optimized")),
260  uStr2Bool(parameters.at("global")),
261  uStr2Bool(parameters.at("graph_only")));
262  break;
263  case kStateTriggeringMap:
265  break;
266  case kStateSettingGoal:
267  id = atoi(parameters.at("id").c_str());
268  if(id == 0 && !parameters.at("label").empty() && _rtabmap->getMemory())
269  {
270  id = _rtabmap->getMemory()->getSignatureIdByLabel(parameters.at("label"));
271  if(id <= 0)
272  {
273  UERROR("Failed to find a node with label \"%s\".", parameters.at("label").c_str());
274  }
275  }
276  else if(id < 0)
277  {
278  UERROR("Failed to set a goal. ID (%d) should be positive > 0", id);
279  }
280  timer.start();
281  if(id > 0 && !_rtabmap->computePath(id, true))
282  {
283  UERROR("Failed to compute a path to goal %d.", id);
284  }
285  this->post(new RtabmapGlobalPathEvent(
286  id,
287  parameters.at("label"),
288  _rtabmap->getPath(),
289  timer.elapsed()));
290  break;
292  _rtabmap->clearPath(0);
293  break;
294  case kStateLabelling:
295  if(!_rtabmap->labelLocation(atoi(parameters.at("id").c_str()), parameters.at("label").c_str()))
296  {
297  this->post(new RtabmapLabelErrorEvent(atoi(parameters.at("id").c_str()), parameters.at("label").c_str()));
298  }
299  break;
300  default:
301  UFATAL("Invalid state !?!?");
302  break;
303  }
304 }
305 
306 
308 {
309  if(this->isRunning())
310  {
311  if(event->getClassName().compare("IMUEvent") == 0)
312  {
313  // IMU events are published at high frequency, early exit
314  return false;
315  }
316  else if(event->getClassName().compare("CameraEvent") == 0)
317  {
318  UDEBUG("CameraEvent");
319  CameraEvent * e = (CameraEvent*)event;
320  if(e->getCode() == CameraEvent::kCodeData)
321  {
322  if (_rtabmap->isRGBDMode())
323  {
324  if (!e->info().odomPose.isNull() || (_rtabmap->getMemory() && !_rtabmap->getMemory()->isIncremental()))
325  {
326  OdometryInfo infoCov;
327  infoCov.reg.covariance = e->info().odomCovariance;
328  if(e->info().odomVelocity.size() == 6)
329  {
330  infoCov.transform = Transform(
331  e->info().odomVelocity[0],
332  e->info().odomVelocity[1],
333  e->info().odomVelocity[2],
334  e->info().odomVelocity[3],
335  e->info().odomVelocity[4],
336  e->info().odomVelocity[5]);
337  infoCov.interval = 1.0;
338  }
339  this->addData(OdometryEvent(e->data(), e->info().odomPose, infoCov));
340  }
341  else
342  {
343  lastPose_.setNull();
344  }
345  }
346  else
347  {
348  OdometryInfo infoCov;
349  infoCov.reg.covariance = e->info().odomCovariance;
350  this->addData(OdometryEvent(e->data(), e->info().odomPose, infoCov));
351  }
352 
353  }
354  }
355  else if(event->getClassName().compare("OdometryEvent") == 0)
356  {
357  UDEBUG("OdometryEvent");
358  OdometryEvent * e = (OdometryEvent*)event;
359  if(!e->pose().isNull() || (_rtabmap->getMemory() && !_rtabmap->getMemory()->isIncremental()))
360  {
361  this->addData(*e);
362  }
363  else
364  {
365  lastPose_.setNull();
366  }
367  }
368  else if(event->getClassName().compare("UserDataEvent") == 0)
369  {
370  if(!_paused)
371  {
372  UDEBUG("UserDataEvent");
373  bool updated = false;
374  UserDataEvent * e = (UserDataEvent*)event;
376  if(!e->data().empty())
377  {
378  updated = !_userData.empty();
379  _userData = e->data();
380  }
382  if(updated)
383  {
384  UWARN("New user data received before the last one was processed... replacing "
385  "user data with this new one. Note that UserDataEvent should be used only "
386  "if the rate of UserDataEvent is lower than RTAB-Map's detection rate (%f Hz).", _rate);
387  }
388  }
389  }
390  else if(event->getClassName().compare("RtabmapEventCmd") == 0)
391  {
392  RtabmapEventCmd * rtabmapEvent = (RtabmapEventCmd*)event;
393  RtabmapEventCmd::Cmd cmd = rtabmapEvent->getCmd();
394  if(cmd == RtabmapEventCmd::kCmdInit)
395  {
396  ULOGGER_DEBUG("CMD_INIT");
397  ParametersMap parameters = ((RtabmapEventCmd*)event)->getParameters();
398  UASSERT(rtabmapEvent->value1().isStr());
399  UASSERT(parameters.insert(ParametersPair("RtabmapThread/DatabasePath", rtabmapEvent->value1().toStr())).second);
400  pushNewState(kStateInit, parameters);
401  }
402  else if(cmd == RtabmapEventCmd::kCmdClose)
403  {
404  ULOGGER_DEBUG("CMD_CLOSE");
405  UASSERT(rtabmapEvent->value1().isUndef() || rtabmapEvent->value1().isBool());
406  ParametersMap param;
407  param.insert(ParametersPair("saved", uBool2Str(rtabmapEvent->value1().isUndef() || rtabmapEvent->value1().toBool())));
408  param.insert(ParametersPair("outputPath", rtabmapEvent->value2().toStr()));
409  pushNewState(kStateClose, param);
410  }
411  else if(cmd == RtabmapEventCmd::kCmdResetMemory)
412  {
413  ULOGGER_DEBUG("CMD_RESET_MEMORY");
415  }
416  else if(cmd == RtabmapEventCmd::kCmdDumpMemory)
417  {
418  ULOGGER_DEBUG("CMD_DUMP_MEMORY");
420  }
422  {
423  ULOGGER_DEBUG("CMD_DUMP_PREDICTION");
425  }
427  {
428  ULOGGER_DEBUG("CMD_GENERATE_DOT_GRAPH");
429  UASSERT(rtabmapEvent->value1().isBool());
430  UASSERT(rtabmapEvent->value2().isStr());
431  UASSERT(rtabmapEvent->value1().toBool() || rtabmapEvent->value3().isInt() || rtabmapEvent->value3().isUInt());
432  UASSERT(rtabmapEvent->value1().toBool() || rtabmapEvent->value4().isInt() || rtabmapEvent->value4().isUInt());
433  ParametersMap param;
434  param.insert(ParametersPair("path", rtabmapEvent->value2().toStr()));
435  param.insert(ParametersPair("id", !rtabmapEvent->value1().toBool()?rtabmapEvent->value3().toStr():"0"));
436  param.insert(ParametersPair("margin", !rtabmapEvent->value1().toBool()?rtabmapEvent->value4().toStr():"0"));
438  }
439  else if(cmd == RtabmapEventCmd::kCmdExportPoses)
440  {
441  ULOGGER_DEBUG("CMD_EXPORT_POSES");
442  UASSERT(rtabmapEvent->value1().isBool());
443  UASSERT(rtabmapEvent->value2().isBool());
444  UASSERT(rtabmapEvent->value3().isStr());
445  UASSERT(rtabmapEvent->value4().isUndef() || rtabmapEvent->value4().isInt() || rtabmapEvent->value4().isUInt());
446  ParametersMap param;
447  param.insert(ParametersPair("global", rtabmapEvent->value1().toStr()));
448  param.insert(ParametersPair("optimized", rtabmapEvent->value1().toStr()));
449  param.insert(ParametersPair("path", rtabmapEvent->value3().toStr()));
450  param.insert(ParametersPair("type", rtabmapEvent->value4().isInt()?rtabmapEvent->value4().toStr():"0"));
452 
453  }
455  {
456  ULOGGER_DEBUG("CMD_CLEAN_DATA_BUFFER");
458  }
459  else if(cmd == RtabmapEventCmd::kCmdPublish3DMap)
460  {
461  ULOGGER_DEBUG("CMD_PUBLISH_MAP");
462  UASSERT(rtabmapEvent->value1().isBool());
463  UASSERT(rtabmapEvent->value2().isBool());
464  UASSERT(rtabmapEvent->value3().isBool());
465  ParametersMap param;
466  param.insert(ParametersPair("global", rtabmapEvent->value1().toStr()));
467  param.insert(ParametersPair("optimized", rtabmapEvent->value2().toStr()));
468  param.insert(ParametersPair("graph_only", rtabmapEvent->value3().toStr()));
470  }
471  else if(cmd == RtabmapEventCmd::kCmdTriggerNewMap)
472  {
473  ULOGGER_DEBUG("CMD_TRIGGER_NEW_MAP");
475  }
476  else if(cmd == RtabmapEventCmd::kCmdPause)
477  {
478  ULOGGER_DEBUG("CMD_PAUSE");
479  _paused = !_paused;
480  }
481  else if(cmd == RtabmapEventCmd::kCmdGoal)
482  {
483  ULOGGER_DEBUG("CMD_GOAL");
484  UASSERT(rtabmapEvent->value1().isStr() || rtabmapEvent->value1().isInt() || rtabmapEvent->value1().isUInt());
485  ParametersMap param;
486  param.insert(ParametersPair("label", rtabmapEvent->value1().isStr()?rtabmapEvent->value1().toStr():""));
487  param.insert(ParametersPair("id", !rtabmapEvent->value1().isStr()?rtabmapEvent->value1().toStr():"0"));
489  }
490  else if(cmd == RtabmapEventCmd::kCmdCancelGoal)
491  {
492  ULOGGER_DEBUG("CMD_CANCEL_GOAL");
494  }
495  else if(cmd == RtabmapEventCmd::kCmdLabel)
496  {
497  ULOGGER_DEBUG("CMD_LABEL");
498  UASSERT(rtabmapEvent->value1().isStr());
499  UASSERT(rtabmapEvent->value2().isUndef() || rtabmapEvent->value2().isInt() || rtabmapEvent->value2().isUInt());
500  ParametersMap param;
501  param.insert(ParametersPair("label", rtabmapEvent->value1().toStr()));
502  param.insert(ParametersPair("id", rtabmapEvent->value2().isUndef()?"0":rtabmapEvent->value2().toStr()));
504  }
505  else
506  {
507  UWARN("Cmd %d unknown!", cmd);
508  }
509  }
510  else if(event->getClassName().compare("ParamEvent") == 0)
511  {
512  ULOGGER_DEBUG("changing parameters");
513  pushNewState(kStateChangingParameters, ((ParamEvent*)event)->getParameters());
514  }
515  }
516  return false;
517 }
518 
519 //============================================================
520 // MAIN LOOP
521 //============================================================
523 {
524  OdometryEvent data;
525  if(_state.empty() && getData(data))
526  {
527  if(_rtabmap->getMemory())
528  {
529  bool wasPlanning = _rtabmap->getPath().size()>0;
530  if(_rtabmap->process(data.data(), data.pose(), data.covariance(), data.velocity()))
531  {
532  Statistics stats = _rtabmap->getStatistics();
533  stats.addStatistic(Statistics::kMemoryImages_buffered(), (float)_dataBuffer.size());
534  ULOGGER_DEBUG("posting statistics_ event...");
535  this->post(new RtabmapEvent(stats));
536 
537  if(wasPlanning && _rtabmap->getPath().size() == 0)
538  {
539  // Goal reached or failed
541  }
542  }
543  }
544  else
545  {
546  UERROR("RTAB-Map is not initialized! Ignoring received data...");
547  }
548  }
549 }
550 
551 void RtabmapThread::addData(const OdometryEvent & odomEvent)
552 {
553  if(!_paused)
554  {
555  UScopeMutex scopeMutex(_dataMutex);
556 
557  bool ignoreFrame = false;
558  if(_rate>0.0f)
559  {
560  if((_previousStamp>=0.0 && odomEvent.data().stamp()>_previousStamp && odomEvent.data().stamp() - _previousStamp < 1.0f/_rate) ||
561  ((_previousStamp<=0.0 || odomEvent.data().stamp()<=_previousStamp) && _frameRateTimer->getElapsedTime() < 1.0f/_rate))
562  {
563  ignoreFrame = true;
564  }
565  }
566  if(!lastPose_.isIdentity() &&
567  (odomEvent.pose().isIdentity() ||
568  odomEvent.info().reg.covariance.at<double>(0,0)>=9999))
569  {
570  if(odomEvent.pose().isIdentity())
571  {
572  UWARN("Odometry is reset (identity pose detected). Increment map id! (stamp=%fs)", odomEvent.data().stamp());
573  }
574  else
575  {
576  UWARN("Odometry is reset (high variance (%f >=9999 detected, stamp=%fs). Increment map id!", odomEvent.info().reg.covariance.at<double>(0,0), odomEvent.data().stamp());
577  }
578  _newMapEvents.push_back(odomEvent.data().stamp());
579  covariance_ = cv::Mat();
580  }
581 
582  if(uIsFinite(odomEvent.info().reg.covariance.at<double>(0,0)) &&
583  odomEvent.info().reg.covariance.at<double>(0,0) != 1.0 &&
584  odomEvent.info().reg.covariance.at<double>(0,0)>0.0)
585  {
586  // Use largest covariance error (to be independent of the odometry frame rate)
587  if(covariance_.empty() || odomEvent.info().reg.covariance.at<double>(0,0) > covariance_.at<double>(0,0))
588  {
589  covariance_ = odomEvent.info().reg.covariance;
590  }
591  }
592 
593  if(ignoreFrame && !_createIntermediateNodes)
594  {
595  return;
596  }
597  else if(!ignoreFrame)
598  {
600  _previousStamp = odomEvent.data().stamp();
601  }
602 
603  lastPose_ = odomEvent.pose();
604 
605  bool notify = true;
606 
607  if(covariance_.empty())
608  {
609  covariance_ = cv::Mat::eye(6,6,CV_64FC1);
610  }
611  OdometryInfo odomInfo = odomEvent.info().copyWithoutData();
612  odomInfo.reg.covariance = covariance_;
613  if(ignoreFrame)
614  {
615  // set negative id so rtabmap will detect it as an intermediate node
616  SensorData tmp = odomEvent.data();
617  tmp.setId(-1);
618  tmp.setFeatures(std::vector<cv::KeyPoint>(), std::vector<cv::Point3f>(), cv::Mat());// remove features
619  _dataBuffer.push_back(OdometryEvent(tmp, odomEvent.pose(), odomInfo));
620  }
621  else
622  {
623  _dataBuffer.push_back(OdometryEvent(odomEvent.data(), odomEvent.pose(), odomInfo));
624  }
625  UINFO("Added data %d", odomEvent.data().id());
626 
627  covariance_ = cv::Mat();
628  while(_dataBufferMaxSize > 0 && _dataBuffer.size() > _dataBufferMaxSize)
629  {
630  if(_rate > 0.0f)
631  {
632  ULOGGER_WARN("Data buffer is full, the oldest data is removed to add the new one.");
633  }
634  _dataBuffer.pop_front();
635  notify = false;
636  }
637 
638  if(notify)
639  {
641  }
642  }
643 }
644 
646 {
647  ULOGGER_DEBUG("");
648 
649  ULOGGER_INFO("waiting for data");
651  ULOGGER_INFO("wake-up");
652 
653  bool dataFilled = false;
654  bool triggerNewMap = false;
655  _dataMutex.lock();
656  {
657  if(_state.empty() && !_dataBuffer.empty())
658  {
659  data = _dataBuffer.front();
660  _dataBuffer.pop_front();
661 
663  {
664  if(!_userData.empty())
665  {
666  data.data().setUserData(_userData);
667  _userData = cv::Mat();
668  }
669  }
671 
672  while(_newMapEvents.size() && _newMapEvents.front() <= data.data().stamp())
673  {
674  UWARN("Triggering new map %f<=%f...", _newMapEvents.front() , data.data().stamp());
675  triggerNewMap = true;
676  _newMapEvents.pop_front();
677  }
678 
679  dataFilled = true;
680  }
681  }
682  _dataMutex.unlock();
683 
684  if(triggerNewMap)
685  {
687  }
688 
689  return dataFilled;
690 }
691 
692 } /* namespace rtabmap */
int getCode() const
Definition: UEvent.h:74
const UVariant & value2() const
Definition: RtabmapEvent.h:114
SensorData & data()
Definition: OdometryEvent.h:69
static bool parse(const ParametersMap &parameters, const std::string &key, bool &value)
Definition: Parameters.cpp:476
void release(int n=1)
Definition: USemaphore.h:168
bool isRGBDMode() const
Definition: Rtabmap.h:126
void dumpData() const
Definition: Rtabmap.cpp:3983
cv::Mat odomCovariance
Definition: CameraInfo.h:70
Definition: UTimer.h:46
std::list< OdometryEvent > _dataBuffer
bool isBool() const
Definition: UVariant.h:63
Definition: UEvent.h:57
void clearPath(int status)
Definition: Rtabmap.cpp:5212
int lock() const
Definition: UMutex.h:87
void exportPoses(const std::string &path, bool optimized, bool global, int format)
Definition: Rtabmap.cpp:858
double elapsed()
Definition: UTimer.h:75
f
#define ULOGGER_INFO(...)
Definition: ULogger.h:54
Definition: lz4.c:365
bool computePath(int targetNode, bool global)
Definition: Rtabmap.cpp:5230
string cmd
const UVariant & value3() const
Definition: RtabmapEvent.h:115
std::pair< std::string, std::string > ParametersPair
Definition: Parameters.h:44
void generateDOTGraph(const std::string &path, int id=0, int margin=5)
Definition: Rtabmap.cpp:826
bool UTILITE_EXP uStr2Bool(const char *str)
bool labelLocation(int id, const std::string &label)
Definition: Rtabmap.cpp:786
OdometryInfo copyWithoutData() const
Definition: OdometryInfo.h:64
void kill()
Definition: UThread.cpp:48
unsigned int _dataBufferMaxSize
bool isRunning() const
Definition: UThread.cpp:245
GLM_FUNC_DECL genType e()
std::map< std::string, std::string > ParametersMap
Definition: Parameters.h:43
std::string UTILITE_EXP uBool2Str(bool boolean)
const UVariant & value1() const
Definition: RtabmapEvent.h:113
void init(const ParametersMap &parameters, const std::string &databasePath="", bool loadDatabaseParameters=false)
Definition: Rtabmap.cpp:292
void setId(int id)
Definition: SensorData.h:156
std::vector< float > odomVelocity
Definition: CameraInfo.h:71
Some conversion functions.
bool acquire(int n=1, int ms=0)
Definition: USemaphore.h:101
int triggerNewMap()
Definition: Rtabmap.cpp:737
#define UFATAL(...)
double getElapsedTime()
Definition: UTimer.cpp:97
void post(UEvent *event, bool async=true) const
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
Definition: Rtabmap.cpp:4543
bool isIdentity() const
Definition: Transform.cpp:136
virtual void mainLoopBegin()
bool uIsFinite(const T &value)
Definition: UMath.h:55
#define UASSERT(condition)
Wrappers of STL for convenient functions.
const cv::Mat & data() const
Definition: UserDataEvent.h:50
const Transform & pose() const
Definition: OdometryEvent.h:71
void close(bool databaseSaved=true, const std::string &ouputDatabasePath="")
Definition: Rtabmap.cpp:392
bool isNull() const
Definition: Transform.cpp:107
#define ULOGGER_DEBUG(...)
Definition: ULogger.h:53
virtual std::string getClassName() const =0
bool isInt() const
Definition: UVariant.h:68
void publishMap(bool optimized, bool full, bool graphOnly) const
bool isStr() const
Definition: UVariant.h:72
bool getData(OdometryEvent &data)
int getSignatureIdByLabel(const std::string &label, bool lookInDatabase=true) const
Definition: Memory.cpp:2490
const Statistics & getStatistics() const
Definition: Rtabmap.cpp:699
static void registerCurrentThread(const std::string &name)
Definition: ULogger.cpp:218
bool toBool() const
Definition: UVariant.cpp:97
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.
Definition: Rtabmap.cpp:992
virtual void mainLoopKill()
const UVariant & value4() const
Definition: RtabmapEvent.h:116
void start()
Definition: UTimer.cpp:87
int id() const
Definition: SensorData.h:155
const OdometryInfo & info() const
Definition: OdometryEvent.h:89
double stamp() const
Definition: SensorData.h:157
RecoveryProgressState state
void parseParameters(const ParametersMap &parameters)
Definition: Rtabmap.cpp:469
const cv::Mat & covariance() const
Definition: OdometryEvent.h:72
void setUserData(const cv::Mat &userData, bool clearPreviousData=true)
Definition: SensorData.cpp:378
bool isUInt() const
Definition: UVariant.h:69
#define false
Definition: ConvertUTF.c:56
void setDetectorRate(float rate)
#define UDEBUG(...)
int getPathStatus() const
Definition: Rtabmap.h:212
const CameraInfo & info() const
Definition: CameraEvent.h:81
void resetMemory()
Definition: Rtabmap.cpp:897
const std::vector< std::pair< int, Transform > > & getPath() const
Definition: Rtabmap.h:216
int unlock() const
Definition: UMutex.h:113
#define UERROR(...)
void setDataBufferSize(unsigned int bufferSize)
#define ULOGGER_WARN(...)
Definition: ULogger.h:55
void dumpPrediction() const
Definition: Rtabmap.cpp:4395
ULogger class and convenient macros.
#define UWARN(...)
const Memory * getMemory() const
Definition: Rtabmap.h:146
void close(bool databaseSaved, const std::string &databasePath="")
std::string toStr(bool *ok=0) const
Definition: UVariant.cpp:586
void addData(const OdometryEvent &odomEvent)
void createIntermediateNodes(bool enabled)
virtual bool handleEvent(UEvent *anEvent)
RegistrationInfo reg
Definition: OdometryInfo.h:96
std::queue< ParametersMap > _stateParam
const SensorData & data() const
Definition: CameraEvent.h:79
std::vector< float > velocity() const
Definition: OdometryEvent.h:73
bool isIncremental() const
Definition: Memory.h:212
static void removeHandler(UEventsHandler *handler)
void join(bool killFirst=false)
Definition: UThread.cpp:85
std::list< double > _newMapEvents
bool isUndef() const
Definition: UVariant.h:62
void pushNewState(State newState, const ParametersMap &parameters=ParametersMap())
Transform odomPose
Definition: CameraInfo.h:69
RtabmapThread(Rtabmap *rtabmap)
void setFeatures(const std::vector< cv::KeyPoint > &keypoints, const std::vector< cv::Point3f > &keypoints3D, const cv::Mat &descriptors)
Definition: SensorData.cpp:757
void addStatistic(const std::string &name, float value)
Definition: Statistics.cpp:93
std::queue< State > _state
#define UINFO(...)


rtabmap
Author(s): Mathieu Labbe
autogenerated on Mon Dec 14 2020 03:35:00