RTAB-Map 0.23.10
Loading...
Searching...
No Matches
Graph.h
1/*
2Copyright (c) 2010-2016, Mathieu Labbe - IntRoLab - Universite de Sherbrooke
3All rights reserved.
4
5Redistribution and use in source and binary forms, with or without
6modification, 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
16THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
20DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23ON 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
25SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*/
27
28#ifndef GRAPH_H_
29#define GRAPH_H_
30
31#include "rtabmap/core/rtabmap_core_export.h" // DLL export/import defines
32
33#include <map>
34#include <list>
35#include <rtabmap/core/Parameters.h>
36#include <rtabmap/core/Link.h>
37#include <rtabmap/core/GPS.h>
38#include <rtabmap/core/CameraModel.h>
39
40namespace rtabmap {
41class Memory;
42
61namespace graph {
62
80bool RTABMAP_CORE_EXPORT exportPoses(
81 const std::string & filePath,
82 int format,
83 const std::map<int, Transform> & poses,
84 const std::multimap<int, Link> & constraints = std::multimap<int, Link>(),
85 const std::map<int, double> & stamps = std::map<int, double>(),
86 const ParametersMap & parameters = ParametersMap());
87
110bool RTABMAP_CORE_EXPORT importPoses(
111 const std::string & filePath,
112 int format,
113 std::map<int, Transform> & poses,
114 std::multimap<int, Link> * constraints = 0,
115 std::map<int, double> * stamps = 0);
116
123bool RTABMAP_CORE_EXPORT exportGPS(
124 const std::string & filePath,
125 const std::map<int, GPS> & gpsValues,
126 unsigned int rgba = 0xFFFFFFFF);
127
144void RTABMAP_CORE_EXPORT calcKittiSequenceErrors(
145 const std::vector<Transform> &poses_gt,
146 const std::vector<Transform> &poses_result,
147 float & t_err,
148 float & r_err);
149
167void RTABMAP_CORE_EXPORT calcRelativeErrors (
168 const std::vector<Transform> &poses_gt,
169 const std::vector<Transform> &poses_result,
170 float & t_err,
171 float & r_err);
172
208Transform RTABMAP_CORE_EXPORT calcRMSE(
209 const std::map<int, Transform> &groundTruth,
210 const std::map<int, Transform> &poses,
211 float & translational_rmse,
212 float & translational_mean,
213 float & translational_median,
214 float & translational_std,
215 float & translational_min,
216 float & translational_max,
217 float & rotational_rmse,
218 float & rotational_mean,
219 float & rotational_median,
220 float & rotational_std,
221 float & rotational_min,
222 float & rotational_max,
223 bool align2D = false);
224
232{
233 float linear=-1.0f;
234 float angular=-1.0f;
235 float linearRatio=-1.0f;
236 float angularRatio=-1.0f;
239};
240
265MaxGraphErrors RTABMAP_CORE_EXPORT computeMaxGraphErrors(
266 const std::map<int, Transform> & poses,
267 const std::multimap<int, Link> & links,
268 bool for3DoF = false);
269
280std::vector<double> RTABMAP_CORE_EXPORT getMaxOdomInf(const std::multimap<int, Link> & links);
281
296std::multimap<int, Link>::iterator RTABMAP_CORE_EXPORT findLink(
297 std::multimap<int, Link> & links,
298 int from,
299 int to,
300 bool checkBothWays = true,
301 Link::Type type = Link::kUndef);
303std::multimap<int, std::pair<int, Link::Type> >::iterator RTABMAP_CORE_EXPORT findLink(
304 std::multimap<int, std::pair<int, Link::Type> > & links,
305 int from,
306 int to,
307 bool checkBothWays = true,
308 Link::Type type = Link::kUndef);
310std::multimap<int, int>::iterator RTABMAP_CORE_EXPORT findLink(
311 std::multimap<int, int> & links,
312 int from,
313 int to,
314 bool checkBothWays = true);
316std::multimap<int, Link>::const_iterator RTABMAP_CORE_EXPORT findLink(
317 const std::multimap<int, Link> & links,
318 int from,
319 int to,
320 bool checkBothWays = true,
321 Link::Type type = Link::kUndef);
323std::multimap<int, std::pair<int, Link::Type> >::const_iterator RTABMAP_CORE_EXPORT findLink(
324 const std::multimap<int, std::pair<int, Link::Type> > & links,
325 int from,
326 int to,
327 bool checkBothWays = true,
328 Link::Type type = Link::kUndef);
330std::multimap<int, int>::const_iterator RTABMAP_CORE_EXPORT findLink(
331 const std::multimap<int, int> & links,
332 int from,
333 int to,
334 bool checkBothWays = true);
335
347std::list<Link> RTABMAP_CORE_EXPORT findLinks(
348 const std::multimap<int, Link> & links,
349 int from);
350
360std::multimap<int, Link> RTABMAP_CORE_EXPORT filterDuplicateLinks(
361 const std::multimap<int, Link> & links);
362
375std::multimap<int, Link> RTABMAP_CORE_EXPORT filterLinks(
376 const std::multimap<int, Link> & links,
377 Link::Type filteredType,
378 bool inverted = false);
380std::map<int, Link> RTABMAP_CORE_EXPORT filterLinks(
381 const std::map<int, Link> & links,
382 Link::Type filteredType,
383 bool inverted = false);
384
400std::map<int, Transform> RTABMAP_CORE_EXPORT frustumPosesFiltering(
401 const std::map<int, Transform> & poses,
402 const Transform & cameraPose,
403 float horizontalFOV = 45.0f,
404 float verticalFOV = 45.0f,
405 float nearClipPlaneDistance = 0.1f,
406 float farClipPlaneDistance = 100.0f,
407 bool negative = false);
408
423std::map<int, Transform> RTABMAP_CORE_EXPORT radiusPosesFiltering(
424 const std::map<int, Transform> & poses,
425 float radius,
426 float angle,
427 bool keepLatest = true);
428
440std::multimap<int, int> RTABMAP_CORE_EXPORT radiusPosesClustering(
441 const std::map<int, Transform> & poses,
442 float radius,
443 float angle);
444
461void reduceGraph(
462 const std::map<int, Transform> & poses,
463 const std::multimap<int, Link> & links,
464 std::multimap<int, int> & hyperNodes,
465 std::multimap<int, Link> & hyperLinks);
466
480std::list<std::pair<int, Transform> > RTABMAP_CORE_EXPORT computePath(
481 const std::map<int, rtabmap::Transform> & poses,
482 const std::multimap<int, int> & links,
483 int from,
484 int to,
485 bool updateNewCosts = false);
486
500std::list<int> RTABMAP_CORE_EXPORT computePath(
501 const std::multimap<int, Link> & links,
502 int from,
503 int to,
504 bool updateNewCosts = false,
505 bool useSameCostForAllLinks = false);
506
539std::list<std::pair<int, Transform> > RTABMAP_CORE_EXPORT computePath(
540 int fromId,
541 int toId,
542 const Memory * memory,
543 bool lookInDatabase = true,
544 bool updateNewCosts = false,
545 float linearVelocity = 0.0f,
546 float angularVelocity = 0.0f,
547 bool ignoreDirectLinks = false);
548
559int RTABMAP_CORE_EXPORT findNearestNode(
560 const std::map<int, rtabmap::Transform> & poses,
561 const rtabmap::Transform & targetPose,
562 float * distance = 0);
563
578std::map<int, float> RTABMAP_CORE_EXPORT findNearestNodes(
579 int nodeId,
580 const std::map<int, Transform> & poses,
581 float radius,
582 float angle = 0.0f,
583 int k=0);
593std::map<int, float> RTABMAP_CORE_EXPORT findNearestNodes(
594 const Transform & targetPose,
595 const std::map<int, Transform> & poses,
596 float radius,
597 float angle = 0.0f,
598 int k=0);
603std::map<int, Transform> RTABMAP_CORE_EXPORT findNearestPoses(
604 int nodeId,
605 const std::map<int, Transform> & poses,
606 float radius,
607 float angle = 0.0f,
608 int k=0);
610std::map<int, Transform> RTABMAP_CORE_EXPORT findNearestPoses(
611 const Transform & targetPose,
612 const std::map<int, Transform> & poses,
613 float radius,
614 float angle = 0.0f,
615 int k=0);
616
618RTABMAP_DEPRECATED std::map<int, float> RTABMAP_CORE_EXPORT findNearestNodes(const std::map<int, rtabmap::Transform> & nodes, const rtabmap::Transform & targetPose, int k);
620RTABMAP_DEPRECATED std::map<int, float> RTABMAP_CORE_EXPORT getNodesInRadius(int nodeId, const std::map<int, Transform> & nodes, float radius);
622RTABMAP_DEPRECATED std::map<int, float> RTABMAP_CORE_EXPORT getNodesInRadius(const Transform & targetPose, const std::map<int, Transform> & nodes, float radius);
624RTABMAP_DEPRECATED std::map<int, Transform> RTABMAP_CORE_EXPORT getPosesInRadius(int nodeId, const std::map<int, Transform> & nodes, float radius, float angle = 0.0f);
626RTABMAP_DEPRECATED std::map<int, Transform> RTABMAP_CORE_EXPORT getPosesInRadius(const Transform & targetPose, const std::map<int, Transform> & nodes, float radius, float angle = 0.0f);
627
636float RTABMAP_CORE_EXPORT computePathLength(
637 const std::vector<std::pair<int, Transform> > & path);
638
648float RTABMAP_CORE_EXPORT computePathLength(
649 const std::map<int, Transform> & path);
650
663std::list<std::map<int, Transform> > RTABMAP_CORE_EXPORT getPaths(
664 std::map<int, Transform> poses,
665 const std::multimap<int, Link> & links);
666
674void RTABMAP_CORE_EXPORT computeMinMax(const std::map<int, Transform> & poses,
675 cv::Vec3f & min,
676 cv::Vec3f & max);
677
678} /* namespace graph */
679
680} /* namespace rtabmap */
681#endif /* GRAPH_H_ */
Three-tiered memory management (STM, WM, LTM) for RTAB-Map.
Definition Memory.h:102
Represents a 3D rigid body transformation (rotation + translation).
Definition Transform.h:53
Pose-graph I/O, trajectory metrics, link utilities, and path planning.
Largest pose-graph constraint violations after optimization.
Definition Graph.h:232
float angular
Absolute angular error (rad) of the worst link.
Definition Graph.h:234
float linearRatio
linear / sqrt(trans variance) of the worst link.
Definition Graph.h:235
float linear
Absolute linear error (m) of the worst link.
Definition Graph.h:233
Link angularLink
Link with largest angularRatio.
Definition Graph.h:238
float angularRatio
angular / sqrt(rot variance) of the worst link.
Definition Graph.h:236
Link linearLink
Link with largest linearRatio.
Definition Graph.h:237