17#include <gtsam_unstable/dllexport.h>
19#include "PartitionWorkSpace.h"
21namespace gtsam {
namespace partition {
26 enum GenericNode2DType { NODE_POSE_2D, NODE_LANDMARK_2D };
29 struct GenericNode2D {
31 GenericNode2DType type;
32 GenericNode2D (
const std::size_t& index_in,
const GenericNode2DType& type_in) : index(index_in), type(type_in) {}
36 struct GenericFactor2D {
41 GenericFactor2D(
const size_t index1,
const GenericNode2DType type1,
const size_t index2,
const GenericNode2DType type2,
const int index_ = -1,
const int weight_ = 1)
42 : key1(index1, type1), key2(index2, type2), index(index_), weight(weight_) {}
43 GenericFactor2D(
const size_t index1,
const char type1,
const size_t index2,
const char type2,
const int index_ = -1,
const int weight_ = 1)
44 : key1(index1, type1 ==
'x' ? NODE_POSE_2D : NODE_LANDMARK_2D),
45 key2(index2, type2 ==
'x' ? NODE_POSE_2D : NODE_LANDMARK_2D), index(index_), weight(weight_) {}
49 typedef std::shared_ptr<GenericFactor2D> sharedGenericFactor2D;
50 typedef std::vector<sharedGenericFactor2D> GenericGraph2D;
53 std::list<std::vector<size_t> > GTSAM_UNSTABLE_EXPORT findIslands(
const GenericGraph2D& graph,
const std::vector<size_t>& keys,
WorkSpace& workspace,
54 const int minNrConstraintsPerCamera,
const int minNrConstraintsPerLandmark);
57 inline void reduceGenericGraph(
const GenericGraph2D& graph,
const std::vector<size_t>& cameraKeys,
const std::vector<size_t>& landmarkKeys,
58 const std::vector<int>& dictionary, GenericGraph2D& reducedGraph) {
59 throw std::runtime_error(
"reduceGenericGraph 2d not implemented");
63 inline void checkSingularity(
const GenericGraph2D& graph,
const std::vector<size_t>& frontals,
64 WorkSpace& workspace,
const int minNrConstraintsPerCamera,
const int minNrConstraintsPerLandmark) {
return; }
67 void print(
const GenericGraph2D& graph,
const std::string name =
"GenericGraph2D");
72 enum GenericNode3DType { NODE_POSE_3D, NODE_LANDMARK_3D };
78 struct GenericNode3D {
80 GenericNode3DType type;
81 GenericNode3D (
const std::size_t& index_in,
const GenericNode3DType& type_in) : index(index_in), type(type_in) {}
85 struct GenericFactor3D {
90 GenericFactor3D() :key1(-1, NODE_POSE_3D), key2(-1, NODE_LANDMARK_3D), index(-1), weight(1) {}
91 GenericFactor3D(
const size_t index1,
const size_t index2,
const int index_ = -1,
92 const GenericNode3DType type1 = NODE_POSE_3D,
const GenericNode3DType type2 = NODE_LANDMARK_3D,
const int weight_ = 1)
93 : key1(index1, type1), key2(index2, type2), index(index_), weight(weight_) {}
97 typedef std::shared_ptr<GenericFactor3D> sharedGenericFactor3D;
98 typedef std::vector<sharedGenericFactor3D> GenericGraph3D;
101 std::list<std::vector<size_t> > GTSAM_UNSTABLE_EXPORT findIslands(
const GenericGraph3D& graph,
const std::vector<size_t>& keys,
WorkSpace& workspace,
102 const size_t minNrConstraintsPerCamera,
const size_t minNrConstraintsPerLandmark);
105 void GTSAM_UNSTABLE_EXPORT reduceGenericGraph(
const GenericGraph3D& graph,
const std::vector<size_t>& cameraKeys,
const std::vector<size_t>& landmarkKeys,
106 const std::vector<int>& dictionary, GenericGraph3D& reducedGraph);
109 void checkSingularity(
const GenericGraph3D& graph,
const std::vector<size_t>& frontals,
110 WorkSpace& workspace,
const size_t minNrConstraintsPerCamera,
const size_t minNrConstraintsPerLandmark);
114 void print(
const GenericGraph3D& graph,
const std::string name =
"GenericGraph3D");
120 struct GenericUnaryFactor {
123 GenericUnaryFactor(
const size_t key_,
const GenericNode2DType type_,
const int index_ = -1)
124 : key(key_, type_), index(index_) {}
125 GenericUnaryFactor(
const size_t key_,
const char type_,
const int index_ = -1)
126 : key(key_, type_ ==
'x' ? NODE_POSE_2D : NODE_LANDMARK_2D), index(index_) {}
130 typedef std::shared_ptr<GenericUnaryFactor> sharedGenericUnaryFactor;
131 typedef std::vector<sharedGenericUnaryFactor> GenericUnaryGraph;
136 inline bool hasCommonCamera(
const std::set<size_t>& cameras1,
const std::set<size_t>& cameras2) {
137 if (cameras1.empty() || cameras2.empty())
138 throw std::invalid_argument(
"hasCommonCamera: the input camera set is empty!");
139 std::set<size_t>::const_iterator it1 = cameras1.begin();
140 std::set<size_t>::const_iterator it2 = cameras2.begin();
141 while (it1 != cameras1.end() && it2 != cameras2.end()) {
144 else if (*it1 < *it2)
Global functions in a separate testing namespace.
Definition chartTesting.h:28
the index of the node and the type of the node
Definition GenericGraph.h:29
the index of the node and the type of the node
Definition GenericGraph.h:78
Definition PartitionWorkSpace.h:19