gtsam
Loading...
Searching...
No Matches
dataset.h
Go to the documentation of this file.
1/* ----------------------------------------------------------------------------
2
3 * GTSAM Copyright 2010, Georgia Tech Research Corporation,
4 * Atlanta, Georgia 30332-0415
5 * All Rights Reserved
6 * Authors: Frank Dellaert, et al. (see THANKS for the full author list)
7
8 * See LICENSE for the license information
9
10 * -------------------------------------------------------------------------- */
11
21
22#pragma once
23
24#include <gtsam/base/Testable.h>
25#include <gtsam/base/types.h>
28#include <gtsam/geometry/SL4.h>
34
35#include <map>
36#include <optional>
37#include <string>
38#include <utility> // for pair
39#include <vector>
40
41namespace gtsam {
42
54GTSAM_EXPORT std::string findExampleDataFile(const std::string& name);
55
60GTSAM_EXPORT std::string createRewrittenFileName(const std::string& name);
61
70
73 KernelFunctionTypeNONE, KernelFunctionTypeHUBER, KernelFunctionTypeTUKEY
74};
75
82template <typename T>
83GTSAM_EXPORT std::map<size_t, T> parseVariables(const std::string &filename,
84 size_t maxIndex = 0);
85
92template <typename T>
93GTSAM_EXPORT std::vector<BinaryMeasurement<T>>
94parseMeasurements(const std::string &filename,
95 const noiseModel::Diagonal::shared_ptr &model = nullptr,
96 size_t maxIndex = 0);
97
102template <typename T>
103GTSAM_EXPORT std::vector<typename BetweenFactor<T>::shared_ptr>
104parseFactors(const std::string &filename,
105 const noiseModel::Diagonal::shared_ptr &model = nullptr,
106 size_t maxIndex = 0);
107
109typedef std::pair<size_t, Pose2> IndexedPose;
110typedef std::pair<size_t, Point2> IndexedLandmark;
111typedef std::pair<std::pair<size_t, size_t>, Pose2> IndexedEdge;
112
118GTSAM_EXPORT std::optional<IndexedPose> parseVertexPose(std::istream& is,
119 const std::string& tag);
120
126GTSAM_EXPORT std::optional<IndexedLandmark> parseVertexLandmark(std::istream& is,
127 const std::string& tag);
128
134GTSAM_EXPORT std::optional<IndexedEdge> parseEdge(std::istream& is,
135 const std::string& tag);
136
141 std::pair<NonlinearFactorGraph::shared_ptr, Values::shared_ptr>;
142
150GTSAM_EXPORT GraphAndValues load2D(
151 std::pair<std::string, SharedNoiseModel> dataset, size_t maxIndex = 0,
152 bool addNoise = false,
153 bool smart = true, //
154 NoiseFormat noiseFormat = NoiseFormatAUTO,
155 KernelFunctionType kernelFunctionType = KernelFunctionTypeNONE);
156
168GTSAM_EXPORT GraphAndValues
169load2D(const std::string& filename, SharedNoiseModel model = SharedNoiseModel(),
170 size_t maxIndex = 0, bool addNoise = false, bool smart = true,
171 NoiseFormat noiseFormat = NoiseFormatAUTO, //
172 KernelFunctionType kernelFunctionType = KernelFunctionTypeNONE);
173
175GTSAM_EXPORT void save2D(const NonlinearFactorGraph& graph,
176 const Values& config, const noiseModel::Diagonal::shared_ptr model,
177 const std::string& filename);
178
187GTSAM_EXPORT GraphAndValues
188readG2o(const std::string& g2oFile, const bool is3D = false,
189 KernelFunctionType kernelFunctionType = KernelFunctionTypeNONE);
190
203GTSAM_EXPORT void writeG2o(const NonlinearFactorGraph& graph,
204 const Values& estimate, const std::string& filename);
205
218GTSAM_EXPORT GraphAndValues load3D(const std::string& filename);
219
220// Wrapper-friendly versions of parseFactors<Pose2> and parseFactors<Pose2>
221using BetweenFactorPose2s = std::vector<BetweenFactor<Pose2>::shared_ptr>;
222GTSAM_EXPORT BetweenFactorPose2s
223parse2DFactors(const std::string &filename,
224 const noiseModel::Diagonal::shared_ptr &model = nullptr,
225 size_t maxIndex = 0);
226
227using BetweenFactorPose3s = std::vector<BetweenFactor<Pose3>::shared_ptr>;
228GTSAM_EXPORT BetweenFactorPose3s
229parse3DFactors(const std::string &filename,
230 const noiseModel::Diagonal::shared_ptr &model = nullptr,
231 size_t maxIndex = 0);
232
233using BetweenFactorSL4s = std::vector<BetweenFactor<SL4>::shared_ptr>;
234
235using BinaryMeasurementsUnit3 = std::vector<BinaryMeasurement<Unit3>>;
236using BinaryMeasurementsPoint3 = std::vector<BinaryMeasurement<Point3>>;
237using BinaryMeasurementsRot3 = std::vector<BinaryMeasurement<Rot3>>;
238} // namespace gtsam
Typedefs for easier changing of types.
Concept check for values that can be used in unit tests.
3D Pose manifold SO(3) x R^3 and group SE(3)
2D Pose
Projective Special Linear Group (SL(4, R)) factor.
A non-templated config holding any types of Manifold-group elements.
Factor Graph consisting of non-linear factors.
Binary measurement represents a measurement between two keys in a graph. A binary measurement is simi...
Global functions in a separate testing namespace.
Definition chartTesting.h:28
std::optional< IndexedPose > parseVertexPose(std::istream &is, const std::string &tag)
Parse TORO/G2O vertex "id x y yaw".
Definition dataset.cpp:173
std::pair< NonlinearFactorGraph::shared_ptr, Values::shared_ptr > GraphAndValues
Return type for load functions, which return a graph and initial values.
Definition dataset.h:140
GraphAndValues load2D(const std::string &filename, SharedNoiseModel model, size_t maxIndex, bool addNoise, bool smart, NoiseFormat noiseFormat, KernelFunctionType kernelFunctionType)
Load TORO/G2O style graph files.
Definition dataset.cpp:505
GTSAM_EXPORT std::map< size_t, T > parseVariables(const std::string &filename, size_t maxIndex=0)
Parse variables in a line-based text format (like g2o) into a map.
void writeG2o(const NonlinearFactorGraph &graph, const Values &estimate, const std::string &filename)
This function writes a g2o file from NonlinearFactorGraph and a Values structure.
Definition dataset.cpp:665
std::pair< size_t, Pose2 > IndexedPose
Return type for auxiliary functions.
Definition dataset.h:109
GraphAndValues readG2o(const std::string &g2oFile, const bool is3D, KernelFunctionType kernelFunctionType)
This function parses a g2o file and stores the measurements into a NonlinearFactorGraph and the initi...
Definition dataset.cpp:650
GTSAM_EXPORT std::vector< typename BetweenFactor< T >::shared_ptr > parseFactors(const std::string &filename, const noiseModel::Diagonal::shared_ptr &model=nullptr, size_t maxIndex=0)
Parse BetweenFactors in a line-based text format (like g2o) into a vector of shared pointers.
KernelFunctionType
Robust kernel type to wrap around quadratic noise model.
Definition dataset.h:72
NoiseFormat
Indicates how noise parameters are stored in file.
Definition dataset.h:63
@ NoiseFormatGRAPH
default: toro-style order, but covariance matrix !
Definition dataset.h:66
@ NoiseFormatAUTO
Try to guess covariance matrix layout.
Definition dataset.h:68
@ NoiseFormatTORO
Information matrix, but inf_ff inf_fs inf_ss inf_rr inf_fr inf_sr.
Definition dataset.h:65
@ NoiseFormatCOV
Covariance matrix C11, C12, C13, C22, C23, C33.
Definition dataset.h:67
@ NoiseFormatG2O
Information matrix I11, I12, I13, I22, I23, I33.
Definition dataset.h:64
noiseModel::Base::shared_ptr SharedNoiseModel
Aliases.
Definition NoiseModel.h:846
GraphAndValues load3D(const std::string &filename)
Load a TORO/G2O-style 3D graph.
Definition dataset.cpp:1088
std::optional< IndexedEdge > parseEdge(std::istream &is, const std::string &tag)
Parse TORO/G2O edge "id1 id2 x y yaw".
Definition dataset.cpp:299
void save2D(const NonlinearFactorGraph &graph, const Values &config, const noiseModel::Diagonal::shared_ptr model, const std::string &filename)
save 2d graph
Definition dataset.cpp:617
std::optional< IndexedLandmark > parseVertexLandmark(std::istream &is, const std::string &tag)
Parse G2O landmark vertex "id x y".
Definition dataset.cpp:193
std::string createRewrittenFileName(const std::string &name)
Creates a temporary file name that needs to be ignored in .gitingnore for checking read-write opratio...
Definition dataset.cpp:104
std::string findExampleDataFile(const std::string &name)
Find the full path to an example dataset distributed with gtsam.
Definition dataset.cpp:69
A 2D pose (Point2,Rot2).
Definition Pose2.h:39
Definition NonlinearFactorGraph.h:57
A non-templated config holding any types of Manifold-group elements.
Definition Values.h:65