RTAB-Map 0.23.10
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 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);
304std::multimap<int, std::pair<int, Link::Type> >::iterator RTABMAP_CORE_EXPORT findLink(
305 std::multimap<int, std::pair<int, Link::Type> > & links,
306 int from,
307 int to,
308 bool checkBothWays = true,
309 Link::Type type = Link::kUndef);
312std::multimap<int, int>::iterator RTABMAP_CORE_EXPORT findLink(
313 std::multimap<int, int> & links,
314 int from,
315 int to,
316 bool checkBothWays = true);
319std::multimap<int, Link>::const_iterator RTABMAP_CORE_EXPORT findLink(
320 const std::multimap<int, Link> & links,
321 int from,
322 int to,
323 bool checkBothWays = true,
324 Link::Type type = Link::kUndef);
327std::multimap<int, std::pair<int, Link::Type> >::const_iterator RTABMAP_CORE_EXPORT findLink(
328 const std::multimap<int, std::pair<int, Link::Type> > & links,
329 int from,
330 int to,
331 bool checkBothWays = true,
332 Link::Type type = Link::kUndef);
335std::multimap<int, int>::const_iterator RTABMAP_CORE_EXPORT findLink(
336 const std::multimap<int, int> & links,
337 int from,
338 int to,
339 bool checkBothWays = true);
340
352std::list<Link> RTABMAP_CORE_EXPORT findLinks(
353 const std::multimap<int, Link> & links,
354 int from);
355
365std::multimap<int, Link> RTABMAP_CORE_EXPORT filterDuplicateLinks(
366 const std::multimap<int, Link> & links);
367
380std::multimap<int, Link> RTABMAP_CORE_EXPORT filterLinks(
381 const std::multimap<int, Link> & links,
382 Link::Type filteredType,
383 bool inverted = false);
386std::map<int, Link> RTABMAP_CORE_EXPORT filterLinks(
387 const std::map<int, Link> & links,
388 Link::Type filteredType,
389 bool inverted = false);
390
406std::map<int, Transform> RTABMAP_CORE_EXPORT frustumPosesFiltering(
407 const std::map<int, Transform> & poses,
408 const Transform & cameraPose,
409 float horizontalFOV = 45.0f,
410 float verticalFOV = 45.0f,
411 float nearClipPlaneDistance = 0.1f,
412 float farClipPlaneDistance = 100.0f,
413 bool negative = false);
414
429std::map<int, Transform> RTABMAP_CORE_EXPORT radiusPosesFiltering(
430 const std::map<int, Transform> & poses,
431 float radius,
432 float angle,
433 bool keepLatest = true);
434
446std::multimap<int, int> RTABMAP_CORE_EXPORT radiusPosesClustering(
447 const std::map<int, Transform> & poses,
448 float radius,
449 float angle);
450
468 const std::map<int, Transform> & poses,
469 const std::multimap<int, Link> & links,
470 std::multimap<int, int> & hyperNodes,
471 std::multimap<int, Link> & hyperLinks);
472
486std::list<std::pair<int, Transform> > RTABMAP_CORE_EXPORT computePath(
487 const std::map<int, rtabmap::Transform> & poses,
488 const std::multimap<int, int> & links,
489 int from,
490 int to,
491 bool updateNewCosts = false);
492
506std::list<int> RTABMAP_CORE_EXPORT computePath(
507 const std::multimap<int, Link> & links,
508 int from,
509 int to,
510 bool updateNewCosts = false,
511 bool useSameCostForAllLinks = false);
512
545std::list<std::pair<int, Transform> > RTABMAP_CORE_EXPORT computePath(
546 int fromId,
547 int toId,
548 const Memory * memory,
549 bool lookInDatabase = true,
550 bool updateNewCosts = false,
551 float linearVelocity = 0.0f,
552 float angularVelocity = 0.0f,
553 bool ignoreDirectLinks = false);
554
565int RTABMAP_CORE_EXPORT findNearestNode(
566 const std::map<int, rtabmap::Transform> & poses,
567 const rtabmap::Transform & targetPose,
568 float * distance = 0);
569
584std::map<int, float> RTABMAP_CORE_EXPORT findNearestNodes(
585 int nodeId,
586 const std::map<int, Transform> & poses,
587 float radius,
588 float angle = 0.0f,
589 int k=0);
599std::map<int, float> RTABMAP_CORE_EXPORT findNearestNodes(
600 const Transform & targetPose,
601 const std::map<int, Transform> & poses,
602 float radius,
603 float angle = 0.0f,
604 int k=0);
609std::map<int, Transform> RTABMAP_CORE_EXPORT findNearestPoses(
610 int nodeId,
611 const std::map<int, Transform> & poses,
612 float radius,
613 float angle = 0.0f,
614 int k=0);
617std::map<int, Transform> RTABMAP_CORE_EXPORT findNearestPoses(
618 const Transform & targetPose,
619 const std::map<int, Transform> & poses,
620 float radius,
621 float angle = 0.0f,
622 int k=0);
623
625RTABMAP_DEPRECATED std::map<int, float> RTABMAP_CORE_EXPORT findNearestNodes(const std::map<int, rtabmap::Transform> & nodes, const rtabmap::Transform & targetPose, int k);
627RTABMAP_DEPRECATED std::map<int, float> RTABMAP_CORE_EXPORT getNodesInRadius(int nodeId, const std::map<int, Transform> & nodes, float radius);
629RTABMAP_DEPRECATED std::map<int, float> RTABMAP_CORE_EXPORT getNodesInRadius(const Transform & targetPose, const std::map<int, Transform> & nodes, float radius);
631RTABMAP_DEPRECATED std::map<int, Transform> RTABMAP_CORE_EXPORT getPosesInRadius(int nodeId, const std::map<int, Transform> & nodes, float radius, float angle = 0.0f);
633RTABMAP_DEPRECATED std::map<int, Transform> RTABMAP_CORE_EXPORT getPosesInRadius(const Transform & targetPose, const std::map<int, Transform> & nodes, float radius, float angle = 0.0f);
634
643float RTABMAP_CORE_EXPORT computePathLength(
644 const std::vector<std::pair<int, Transform> > & path);
645
655float RTABMAP_CORE_EXPORT computePathLength(
656 const std::map<int, Transform> & path);
657
670std::list<std::map<int, Transform> > RTABMAP_CORE_EXPORT getPaths(
671 std::map<int, Transform> poses,
672 const std::multimap<int, Link> & links);
673
681void RTABMAP_CORE_EXPORT computeMinMax(const std::map<int, Transform> & poses,
682 cv::Vec3f & min,
683 cv::Vec3f & max);
684
685} /* namespace graph */
686
687} /* namespace rtabmap */
688#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.
MaxGraphErrors RTABMAP_CORE_EXPORT computeMaxGraphErrors(const std::map< int, Transform > &poses, const std::multimap< int, Link > &links, bool for3DoF=false)
Finds the worst pose-graph constraint residuals after optimization.
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.
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::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