Graph.h
Go to the documentation of this file.
00001 /*
00002 Copyright (c) 2010-2016, Mathieu Labbe - IntRoLab - Universite de Sherbrooke
00003 All rights reserved.
00004 
00005 Redistribution and use in source and binary forms, with or without
00006 modification, are permitted provided that the following conditions are met:
00007     * Redistributions of source code must retain the above copyright
00008       notice, this list of conditions and the following disclaimer.
00009     * Redistributions in binary form must reproduce the above copyright
00010       notice, this list of conditions and the following disclaimer in the
00011       documentation and/or other materials provided with the distribution.
00012     * Neither the name of the Universite de Sherbrooke nor the
00013       names of its contributors may be used to endorse or promote products
00014       derived from this software without specific prior written permission.
00015 
00016 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
00017 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
00018 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
00019 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
00020 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
00021 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00022 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
00023 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00024 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00025 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00026 */
00027 
00028 #ifndef GRAPH_H_
00029 #define GRAPH_H_
00030 
00031 #include "rtabmap/core/RtabmapExp.h" // DLL export/import defines
00032 
00033 #include <map>
00034 #include <list>
00035 #include <rtabmap/core/Link.h>
00036 #include <rtabmap/core/GeodeticCoords.h>
00037 
00038 namespace rtabmap {
00039 class Memory;
00040 
00041 namespace graph {
00042 
00044 // Graph utilities
00046 
00047 bool RTABMAP_EXP exportPoses(
00048                 const std::string & filePath,
00049                 int format, // 0=Raw (*.txt), 1=RGBD-SLAM (*.txt), 2=KITTI (*.txt), 3=TORO (*.graph), 4=g2o (*.g2o)
00050                 const std::map<int, Transform> & poses,
00051                 const std::multimap<int, Link> & constraints = std::multimap<int, Link>(), // required for formats 3 and 4
00052                 const std::map<int, double> & stamps = std::map<int, double>(),  // required for format 1
00053                 bool g2oRobust = false); // optional for format 4
00054 
00055 bool RTABMAP_EXP importPoses(
00056                 const std::string & filePath,
00057                 int format, // 0=Raw, 1=RGBD-SLAM, 2=KITTI, 3=TORO, 4=g2o, 5=NewCollege(t,x,y), 6=Malaga Urban GPS, 7=St Lucia INS, 8=Karlsruhe
00058                 std::map<int, Transform> & poses,
00059                 std::multimap<int, Link> * constraints = 0, // optional for formats 3 and 4
00060                 std::map<int, double> * stamps = 0); // optional for format 1
00061 
00062 bool RTABMAP_EXP exportGPS(
00063                 const std::string & filePath,
00064                 const std::map<int, GPS> & gpsValues,
00065                 unsigned int rgba = 0xFFFFFFFF);
00066 
00075 void RTABMAP_EXP calcKittiSequenceErrors(
00076                 const std::vector<Transform> &poses_gt,
00077                 const std::vector<Transform> &poses_result,
00078                 float & t_err,
00079                 float & r_err);
00080 
00089 Transform RTABMAP_EXP calcRMSE(
00090                 const std::map<int, Transform> &groundTruth,
00091                 const std::map<int, Transform> &poses,
00092                 float & translational_rmse,
00093                 float & translational_mean,
00094                 float & translational_median,
00095                 float & translational_std,
00096                 float & translational_min,
00097                 float & translational_max,
00098                 float & rotational_rmse,
00099                 float & rotational_mean,
00100                 float & rotational_median,
00101                 float & rotational_std,
00102                 float & rotational_min,
00103                 float & rotational_max);
00104 
00105 std::multimap<int, Link>::iterator RTABMAP_EXP findLink(
00106                 std::multimap<int, Link> & links,
00107                 int from,
00108                 int to,
00109                 bool checkBothWays = true);
00110 std::multimap<int, int>::iterator RTABMAP_EXP findLink(
00111                 std::multimap<int, int> & links,
00112                 int from,
00113                 int to,
00114                 bool checkBothWays = true);
00115 std::multimap<int, Link>::const_iterator RTABMAP_EXP findLink(
00116                 const std::multimap<int, Link> & links,
00117                 int from,
00118                 int to,
00119                 bool checkBothWays = true);
00120 std::multimap<int, int>::const_iterator RTABMAP_EXP findLink(
00121                 const std::multimap<int, int> & links,
00122                 int from,
00123                 int to,
00124                 bool checkBothWays = true);
00125 
00126 std::multimap<int, Link> RTABMAP_EXP filterDuplicateLinks(
00127                 const std::multimap<int, Link> & links);
00128 std::multimap<int, Link> RTABMAP_EXP filterLinks(
00129                 const std::multimap<int, Link> & links,
00130                 Link::Type filteredType);
00131 std::map<int, Link> RTABMAP_EXP filterLinks(
00132                 const std::map<int, Link> & links,
00133                 Link::Type filteredType);
00134 
00135 //Note: This assumes a coordinate system where X is forward, * Y is up, and Z is right.
00136 std::map<int, Transform> RTABMAP_EXP frustumPosesFiltering(
00137                 const std::map<int, Transform> & poses,
00138                 const Transform & cameraPose,
00139                 float horizontalFOV = 45.0f, // in degrees, xfov = atan((image_width/2)/fx)*2
00140                 float verticalFOV = 45.0f,   // in degrees, yfov = atan((image_height/2)/fy)*2
00141                 float nearClipPlaneDistance = 0.1f,
00142                 float farClipPlaneDistance = 100.0f,
00143                 bool negative = false);
00144 
00153 std::map<int, Transform> RTABMAP_EXP radiusPosesFiltering(
00154                 const std::map<int, Transform> & poses,
00155                 float radius,
00156                 float angle,
00157                 bool keepLatest = true);
00158 
00166 std::multimap<int, int> RTABMAP_EXP radiusPosesClustering(
00167                 const std::map<int, Transform> & poses,
00168                 float radius,
00169                 float angle);
00170 
00171 void reduceGraph(
00172                 const std::map<int, Transform> & poses,
00173                 const std::multimap<int, Link> & links,
00174                 std::multimap<int, int> & hyperNodes, //<parent ID, child ID>
00175                 std::multimap<int, Link> & hyperLinks);
00176 
00186 std::list<std::pair<int, Transform> > RTABMAP_EXP computePath(
00187                         const std::map<int, rtabmap::Transform> & poses,
00188                         const std::multimap<int, int> & links,
00189                         int from,
00190                         int to,
00191                         bool updateNewCosts = false);
00192 
00203 std::list<int> RTABMAP_EXP computePath(
00204                         const std::multimap<int, Link> & links,
00205                         int from,
00206                         int to,
00207                         bool updateNewCosts = false,
00208                         bool useSameCostForAllLinks = false);
00209 
00219 std::list<std::pair<int, Transform> > RTABMAP_EXP computePath(
00220                 int fromId,
00221                 int toId,
00222                 const Memory * memory,
00223                 bool lookInDatabase = true,
00224                 bool updateNewCosts = false,
00225                 float linearVelocity = 0.0f,   // m/sec
00226                 float angularVelocity = 0.0f); // rad/sec
00227 
00228 int RTABMAP_EXP findNearestNode(
00229                 const std::map<int, rtabmap::Transform> & nodes,
00230                 const rtabmap::Transform & targetPose);
00231 
00232 std::vector<int> RTABMAP_EXP findNearestNodes(
00233                 const std::map<int, rtabmap::Transform> & nodes,
00234                 const rtabmap::Transform & targetPose,
00235                 int k);
00236 
00244 std::map<int, float> RTABMAP_EXP getNodesInRadius(
00245                 int nodeId,
00246                 const std::map<int, Transform> & nodes,
00247                 float radius);
00248 std::map<int, Transform> RTABMAP_EXP getPosesInRadius(
00249                 int nodeId,
00250                 const std::map<int, Transform> & nodes,
00251                 float radius,
00252                 float angle = 0.0f);
00253 
00254 float RTABMAP_EXP computePathLength(
00255                 const std::vector<std::pair<int, Transform> > & path,
00256                 unsigned int fromIndex = 0,
00257                 unsigned int toIndex = 0);
00258 
00259 // assuming they are all linked in map order
00260 float RTABMAP_EXP computePathLength(
00261                 const std::map<int, Transform> & path);
00262 
00263 std::list<std::map<int, Transform> > RTABMAP_EXP getPaths(
00264                 std::map<int, Transform> poses,
00265                 const std::multimap<int, Link> & links);
00266 
00267 
00268 } /* namespace graph */
00269 
00270 } /* namespace rtabmap */
00271 #endif /* GRAPH_H_ */


rtabmap
Author(s): Mathieu Labbe
autogenerated on Thu Jun 6 2019 21:59:20