RTAB-Map 0.25.2
Real-Time Appearance-Based Mapping
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
266 const std::map<int, Transform> & poses,
267 const std::multimap<int, Link> & links,
268 bool slam2D = false);
269
287std::string RTABMAP_CORE_EXPORT checkMaxGraphErrors(
288 const std::map<int, Transform> & poses,
289 const std::multimap<int, Link> & links,
290 float maxErrorRatio,
291 bool robust,
292 bool slam2D = false,
293 MaxGraphErrors * errorsOut = 0);
294
305std::vector<double> RTABMAP_CORE_EXPORT getMaxOdomInf(const std::multimap<int, Link> & links);
306
321std::multimap<int, Link>::iterator RTABMAP_CORE_EXPORT findLink(
322 std::multimap<int, Link> & links,
323 int from,
324 int to,
325 bool checkBothWays = true,
326 Link::Type type = Link::kUndef);
329std::multimap<int, std::pair<int, Link::Type> >::iterator RTABMAP_CORE_EXPORT findLink(
330 std::multimap<int, std::pair<int, Link::Type> > & links,
331 int from,
332 int to,
333 bool checkBothWays = true,
334 Link::Type type = Link::kUndef);
337std::multimap<int, int>::iterator RTABMAP_CORE_EXPORT findLink(
338 std::multimap<int, int> & links,
339 int from,
340 int to,
341 bool checkBothWays = true);
344std::multimap<int, Link>::const_iterator RTABMAP_CORE_EXPORT findLink(
345 const std::multimap<int, Link> & links,
346 int from,
347 int to,
348 bool checkBothWays = true,
349 Link::Type type = Link::kUndef);
352std::multimap<int, std::pair<int, Link::Type> >::const_iterator RTABMAP_CORE_EXPORT findLink(
353 const std::multimap<int, std::pair<int, Link::Type> > & links,
354 int from,
355 int to,
356 bool checkBothWays = true,
357 Link::Type type = Link::kUndef);
360std::multimap<int, int>::const_iterator RTABMAP_CORE_EXPORT findLink(
361 const std::multimap<int, int> & links,
362 int from,
363 int to,
364 bool checkBothWays = true);
365
377std::list<Link> RTABMAP_CORE_EXPORT findLinks(
378 const std::multimap<int, Link> & links,
379 int from);
380
390std::multimap<int, Link> RTABMAP_CORE_EXPORT filterDuplicateLinks(
391 const std::multimap<int, Link> & links);
392
405std::multimap<int, Link> RTABMAP_CORE_EXPORT filterLinks(
406 const std::multimap<int, Link> & links,
407 Link::Type filteredType,
408 bool inverted = false);
411std::map<int, Link> RTABMAP_CORE_EXPORT filterLinks(
412 const std::map<int, Link> & links,
413 Link::Type filteredType,
414 bool inverted = false);
415
431std::map<int, Transform> RTABMAP_CORE_EXPORT frustumPosesFiltering(
432 const std::map<int, Transform> & poses,
433 const Transform & cameraPose,
434 float horizontalFOV = 45.0f,
435 float verticalFOV = 45.0f,
436 float nearClipPlaneDistance = 0.1f,
437 float farClipPlaneDistance = 100.0f,
438 bool negative = false);
439
454std::map<int, Transform> RTABMAP_CORE_EXPORT radiusPosesFiltering(
455 const std::map<int, Transform> & poses,
456 float radius,
457 float angle,
458 bool keepLatest = true);
459
471std::multimap<int, int> RTABMAP_CORE_EXPORT radiusPosesClustering(
472 const std::map<int, Transform> & poses,
473 float radius,
474 float angle);
475
493 const std::map<int, Transform> & poses,
494 const std::multimap<int, Link> & links,
495 std::multimap<int, int> & hyperNodes,
496 std::multimap<int, Link> & hyperLinks);
497
511std::list<std::pair<int, Transform> > RTABMAP_CORE_EXPORT computePath(
512 const std::map<int, rtabmap::Transform> & poses,
513 const std::multimap<int, int> & links,
514 int from,
515 int to,
516 bool updateNewCosts = false);
517
536std::map<int, int> RTABMAP_CORE_EXPORT computePathDepths(
537 const std::multimap<int, int> & links,
538 int from,
539 int maxDepth = 0);
540
554std::list<int> RTABMAP_CORE_EXPORT computePath(
555 const std::multimap<int, Link> & links,
556 int from,
557 int to,
558 bool updateNewCosts = false,
559 bool useSameCostForAllLinks = false);
560
593std::list<std::pair<int, Transform> > RTABMAP_CORE_EXPORT computePath(
594 int fromId,
595 int toId,
596 const Memory * memory,
597 bool lookInDatabase = true,
598 bool updateNewCosts = false,
599 float linearVelocity = 0.0f,
600 float angularVelocity = 0.0f,
601 bool ignoreDirectLinks = false);
602
613int RTABMAP_CORE_EXPORT findNearestNode(
614 const std::map<int, rtabmap::Transform> & poses,
615 const rtabmap::Transform & targetPose,
616 float * distance = 0);
617
632std::map<int, float> RTABMAP_CORE_EXPORT findNearestNodes(
633 int nodeId,
634 const std::map<int, Transform> & poses,
635 float radius,
636 float angle = 0.0f,
637 int k=0);
647std::map<int, float> RTABMAP_CORE_EXPORT findNearestNodes(
648 const Transform & targetPose,
649 const std::map<int, Transform> & poses,
650 float radius,
651 float angle = 0.0f,
652 int k=0);
657std::map<int, Transform> RTABMAP_CORE_EXPORT findNearestPoses(
658 int nodeId,
659 const std::map<int, Transform> & poses,
660 float radius,
661 float angle = 0.0f,
662 int k=0);
665std::map<int, Transform> RTABMAP_CORE_EXPORT findNearestPoses(
666 const Transform & targetPose,
667 const std::map<int, Transform> & poses,
668 float radius,
669 float angle = 0.0f,
670 int k=0);
671
673RTABMAP_DEPRECATED std::map<int, float> RTABMAP_CORE_EXPORT findNearestNodes(const std::map<int, rtabmap::Transform> & nodes, const rtabmap::Transform & targetPose, int k);
675RTABMAP_DEPRECATED std::map<int, float> RTABMAP_CORE_EXPORT getNodesInRadius(int nodeId, const std::map<int, Transform> & nodes, float radius);
677RTABMAP_DEPRECATED std::map<int, float> RTABMAP_CORE_EXPORT getNodesInRadius(const Transform & targetPose, const std::map<int, Transform> & nodes, float radius);
679RTABMAP_DEPRECATED std::map<int, Transform> RTABMAP_CORE_EXPORT getPosesInRadius(int nodeId, const std::map<int, Transform> & nodes, float radius, float angle = 0.0f);
681RTABMAP_DEPRECATED std::map<int, Transform> RTABMAP_CORE_EXPORT getPosesInRadius(const Transform & targetPose, const std::map<int, Transform> & nodes, float radius, float angle = 0.0f);
682
691float RTABMAP_CORE_EXPORT computePathLength(
692 const std::vector<std::pair<int, Transform> > & path);
693
703float RTABMAP_CORE_EXPORT computePathLength(
704 const std::map<int, Transform> & path);
705
718std::list<std::map<int, Transform> > RTABMAP_CORE_EXPORT getPaths(
719 std::map<int, Transform> poses,
720 const std::multimap<int, Link> & links);
721
729void RTABMAP_CORE_EXPORT computeMinMax(const std::map<int, Transform> & poses,
730 cv::Vec3f & min,
731 cv::Vec3f & max);
732
733} /* namespace graph */
734
735} /* namespace rtabmap */
736#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
std::list< std::map< int, Transform > > RTABMAP_CORE_EXPORT getPaths(std::map< int, Transform > poses, const std::multimap< int, Link > &links)
Splits poses into chains connected only by neighbor links.
std::map< int, Transform > RTABMAP_CORE_EXPORT radiusPosesFiltering(const std::map< int, Transform > &poses, float radius, float angle, bool keepLatest=true)
Subsamples poses that are spatially (and optionally angularly) redundant.
std::list< Link > RTABMAP_CORE_EXPORT findLinks(const std::multimap< int, Link > &links, int from)
Lists all links incident on node from.
void RTABMAP_CORE_EXPORT computeMinMax(const std::map< int, Transform > &poses, cv::Vec3f &min, cv::Vec3f &max)
Axis-aligned bounding box of pose positions.
void RTABMAP_CORE_EXPORT calcKittiSequenceErrors(const std::vector< Transform > &poses_gt, const std::vector< Transform > &poses_result, float &t_err, float &r_err)
KITTI odometry benchmark error over fixed trajectory segments.
float RTABMAP_CORE_EXPORT computePathLength(const std::vector< std::pair< int, Transform > > &path)
Path length along an ordered list of poses.
int RTABMAP_CORE_EXPORT findNearestNode(const std::map< int, rtabmap::Transform > &poses, const rtabmap::Transform &targetPose, float *distance=0)
Id of the nearest pose to targetPose.
std::multimap< int, Link > RTABMAP_CORE_EXPORT filterLinks(const std::multimap< int, Link > &links, Link::Type filteredType, bool inverted=false)
Filters links by type or self-reference.
bool RTABMAP_CORE_EXPORT importPoses(const std::string &filePath, int format, std::map< int, Transform > &poses, std::multimap< int, Link > *constraints=0, std::map< int, double > *stamps=0)
Loads poses (and optional constraints) from disk.
Transform RTABMAP_CORE_EXPORT calcRMSE(const std::map< int, Transform > &groundTruth, const std::map< int, Transform > &poses, float &translational_rmse, float &translational_mean, float &translational_median, float &translational_std, float &translational_min, float &translational_max, float &rotational_rmse, float &rotational_mean, float &rotational_median, float &rotational_std, float &rotational_min, float &rotational_max, bool align2D=false)
Absolute trajectory error (ATE) with Sim(3)-style alignment (TUM RGB-D tool).
std::multimap< int, Link > RTABMAP_CORE_EXPORT filterDuplicateLinks(const std::multimap< int, Link > &links)
Removes duplicate undirected links.
std::list< std::pair< int, Transform > > RTABMAP_CORE_EXPORT computePath(const std::map< int, rtabmap::Transform > &poses, const std::multimap< int, int > &links, int from, int to, bool updateNewCosts=false)
A* shortest path on a pose graph with Euclidean edge costs.
std::vector< double > RTABMAP_CORE_EXPORT getMaxOdomInf(const std::multimap< int, Link > &links)
Maximum information-matrix diagonal over odometry neighbor links.
std::map< int, Transform > RTABMAP_CORE_EXPORT frustumPosesFiltering(const std::map< int, Transform > &poses, const Transform &cameraPose, float horizontalFOV=45.0f, float verticalFOV=45.0f, float nearClipPlaneDistance=0.1f, float farClipPlaneDistance=100.0f, bool negative=false)
Keeps poses inside (or outside) a camera frustum.
MaxGraphErrors RTABMAP_CORE_EXPORT computeMaxGraphErrors(const std::map< int, Transform > &poses, const std::multimap< int, Link > &links, bool slam2D=false)
Finds the worst pose-graph constraint residuals after optimization.
void RTABMAP_CORE_EXPORT calcRelativeErrors(const std::vector< Transform > &poses_gt, const std::vector< Transform > &poses_result, float &t_err, float &r_err)
Mean frame-to-frame relative pose error (RPE-style, one step).
std::string RTABMAP_CORE_EXPORT checkMaxGraphErrors(const std::map< int, Transform > &poses, const std::multimap< int, Link > &links, float maxErrorRatio, bool robust, bool slam2D=false, MaxGraphErrors *errorsOut=0)
Checks the errors of an optimized graph against a maximum error ratio (e.g., Parameters::kRGBDOptimiz...
std::map< int, int > RTABMAP_CORE_EXPORT computePathDepths(const std::multimap< int, int > &links, int from, int maxDepth=0)
Single-source graph depth via BFS.
std::map< int, Transform > RTABMAP_CORE_EXPORT findNearestPoses(int nodeId, const std::map< int, Transform > &poses, float radius, float angle=0.0f, int k=0)
Like findNearestNodes(int,const std::map<int,Transform>&,float,float,int) but returns full Transform ...
std::map< int, float > RTABMAP_CORE_EXPORT findNearestNodes(int nodeId, const std::map< int, Transform > &poses, float radius, float angle=0.0f, int k=0)
Spatial neighbors of a node (KD-tree radius or k-NN search).
bool RTABMAP_CORE_EXPORT exportGPS(const std::string &filePath, const std::map< int, GPS > &gpsValues, unsigned int rgba=0xFFFFFFFF)
Exports GPS samples to a PLY point cloud.
std::multimap< int, Link >::iterator RTABMAP_CORE_EXPORT findLink(std::multimap< int, Link > &links, int from, int to, bool checkBothWays=true, Link::Type type=Link::kUndef)
Finds the first link from from to to in a multimap keyed by source id.
void reduceGraph(const std::map< int, Transform > &poses, const std::multimap< int, Link > &links, std::multimap< int, int > &hyperNodes, std::multimap< int, Link > &hyperLinks)
Reduces a pose graph into hyper-nodes and hyper-links.
std::multimap< int, int > RTABMAP_CORE_EXPORT radiusPosesClustering(const std::map< int, Transform > &poses, float radius, float angle)
Radius-neighbor clustering of poses.
RTABMAP_DEPRECATED std::map< int, Transform > RTABMAP_CORE_EXPORT getPosesInRadius(int nodeId, const std::map< int, Transform > &nodes, float radius, float angle=0.0f)
bool RTABMAP_CORE_EXPORT exportPoses(const std::string &filePath, int format, const std::map< int, Transform > &poses, const std::multimap< int, Link > &constraints=std::multimap< int, Link >(), const std::map< int, double > &stamps=std::map< int, double >(), const ParametersMap &parameters=ParametersMap())
Writes poses (and optional constraints) to disk.
RTABMAP_DEPRECATED std::map< int, float > RTABMAP_CORE_EXPORT getNodesInRadius(int nodeId, const std::map< int, Transform > &nodes, float radius)
std::map< std::string, std::string > ParametersMap
Parameter keys mapped to their values, as used by every configurable class (see Parameters).
Definition Parameters.h:44
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