9 #include <boost/assign/std/list.hpp> 10 #include <boost/assign/std/set.hpp> 11 #include <boost/assign/std/vector.hpp> 13 #include <boost/make_shared.hpp> 16 #include "SubmapPlanarSLAM.h" 17 #include "SubmapVisualSLAM.h" 18 #include "SubmapExamples.h" 19 #include "SubmapExamples3D.h" 21 #include "NonlinearTSAM.h" 25 using namespace gtsam;
34 using namespace submapPlanarSLAM;
35 typedef TSAM2D::SubNLG SubNLG;
38 fg.addBearingRange(1, 1,
Rot2(), 0., bearingRangeNoise);
39 fg.addBearingRange(2, 1,
Rot2(), 0., bearingRangeNoise);
40 fg.addPoseConstraint(1,
Pose2());
44 int numNodeStopPartition = 1e3;
45 int minNodesPerMap = 1e3;
58 using namespace submapPlanarSLAM;
59 typedef TSAM2D::SubNLG SubNLG;
67 fg.addPoseConstraint(1,
Pose2());
68 fg.addPoseConstraint(4,
Pose2());
71 int numNodeStopPartition = 2;
72 int minNodesPerMap = 1;
95 using namespace submapPlanarSLAM;
96 typedef TSAM2D::SubNLG SubNLG;
102 fg.addPoseConstraint(1,
Pose2());
103 fg.addPoseConstraint(4,
Pose2());
106 int numNodeStopPartition = 2;
107 int minNodesPerMap = 1;
139 using namespace submapPlanarSLAM;
140 typedef TSAM2D::SubNLG SubNLG;
146 fg.addBearingRange(1, 6,
Rot2(), 0., bearingRangeNoise);
147 fg.addBearingRange(2, 6,
Rot2(), 0., bearingRangeNoise);
148 fg.addBearingRange(5, 6,
Rot2(), 0., bearingRangeNoise);
149 fg.addPoseConstraint(1,
Pose2());
150 fg.addPoseConstraint(4,
Pose2());
151 fg.addPoseConstraint(5,
Pose2());
154 int numNodeStopPartition = 2;
155 int minNodesPerMap = 1;
186 using namespace submapPlanarSLAM;
188 typedef TSAM2D::SubNLG SubNLG;
194 fg.addBearingRange(
x0,
l1, Rot2::fromAngle( M_PI_2), 1, bearingRangeNoise);
195 fg.addBearingRange(
x0,
l4, Rot2::fromAngle(-M_PI_2), 1, bearingRangeNoise);
196 fg.addBearingRange(
x0,
l2, Rot2::fromAngle( M_PI_4),
sqrt(2), bearingRangeNoise);
197 fg.addBearingRange(
x0, l5, Rot2::fromAngle(-M_PI_4),
sqrt(2), bearingRangeNoise);
199 fg.addBearingRange(
x1,
l1, Rot2::fromAngle( M_PI_4 * 3),
sqrt(2), bearingRangeNoise);
200 fg.addBearingRange(
x1,
l2, Rot2::fromAngle( M_PI_2), 1, bearingRangeNoise);
201 fg.addBearingRange(
x1,
l3, Rot2::fromAngle( M_PI_4),
sqrt(2), bearingRangeNoise);
202 fg.addBearingRange(
x1,
l4, Rot2::fromAngle(-M_PI_4 * 3),
sqrt(2), bearingRangeNoise);
203 fg.addBearingRange(
x1, l5, Rot2::fromAngle( M_PI_2), 1, bearingRangeNoise);
204 fg.addBearingRange(
x1, l6, Rot2::fromAngle(-M_PI_4),
sqrt(2), bearingRangeNoise);
206 fg.addBearingRange(
x2,
l2, Rot2::fromAngle( M_PI_4 * 3),
sqrt(2), bearingRangeNoise);
207 fg.addBearingRange(
x2, l5, Rot2::fromAngle(-M_PI_4 * 3),
sqrt(2), bearingRangeNoise);
208 fg.addBearingRange(
x2,
l3, Rot2::fromAngle( M_PI_2), 1, bearingRangeNoise);
209 fg.addBearingRange(
x2, l6, Rot2::fromAngle(-M_PI_2), 1, bearingRangeNoise);
217 boost::shared_ptr<Cuts> cuts(
new Cuts());
218 cuts->partitionTable =
PartitionTable(9, -1); PartitionTable*
p = &cuts->partitionTable;
220 (*p)[0]=1; (*p)[1]=0; (*p)[2]=2; (*p)[3]=1; (*p)[4]=0; (*p)[5]=2; (*p)[6]=1; (*p)[7]=0; (*p)[8]=2;
222 cuts->children.push_back(boost::shared_ptr<Cuts>(
new Cuts()));
223 cuts->children[0]->partitionTable =
PartitionTable(9, -1); p = &cuts->children[0]->partitionTable;
225 (*p)[0]=0; (*p)[1]=-1; (*p)[2]=-1; (*p)[3]=1; (*p)[4]=-1; (*p)[5]=-1; (*p)[6]=2; (*p)[7]=-1; (*p)[8]=-1;
227 cuts->children.push_back(boost::shared_ptr<Cuts>(
new Cuts()));
228 cuts->children[1]->partitionTable =
PartitionTable(9, -1); p = &cuts->children[1]->partitionTable;
230 (*p)[0]=-1; (*p)[1]=-1; (*p)[2]=0; (*p)[3]=-1; (*p)[4]=-1; (*p)[5]=1; (*p)[6]=-1; (*p)[7]=-1; (*p)[8]=2;
247 LONGS_EQUAL(1, nd.
root()->children()[0]->children()[0]->frontal().size());
251 LONGS_EQUAL(1, nd.
root()->children()[0]->children()[1]->frontal().size());
260 LONGS_EQUAL(1, nd.
root()->children()[1]->children()[0]->frontal().size());
264 LONGS_EQUAL(1, nd.
root()->children()[1]->children()[1]->frontal().size());
274 using namespace gtsam::submapVisualSLAM;
275 typedef TSAM3D::SubNLG SubNLG;
277 vector<GeneralCamera> cameras;
283 vector<Point3> points;
284 for (
int cube_index = 0; cube_index <= 3; cube_index++) {
285 Point3 center((cube_index-1) * 3, 0.5, 10.);
286 points.push_back(center +
Point3(-0.5, -0.5, -0.5));
287 points.push_back(center +
Point3(-0.5, 0.5, -0.5));
288 points.push_back(center +
Point3( 0.5, 0.5, -0.5));
289 points.push_back(center +
Point3( 0.5, -0.5, -0.5));
290 points.push_back(center +
Point3(-0.5, -0.5, 0.5));
291 points.push_back(center +
Point3(-0.5, 0.5, 0.5));
292 points.push_back(center +
Point3( 0.5, 0.5, 0.5));
293 points.push_back(center +
Point3( 0.5, 0.5, 0.5));
299 for (
int j=1;
j<=8;
j++)
300 graph.
addMeasurement(0,
j, cameras[0].project(points[
j-1]).expmap(measurementZeroNoise->sample()), measurementNoise);
301 for (
int j=1;
j<=16;
j++)
302 graph.
addMeasurement(1,
j, cameras[1].project(points[
j-1]).expmap(measurementZeroNoise->sample()), measurementNoise);
303 for (
int j=9;
j<=24;
j++)
304 graph.
addMeasurement(2,
j, cameras[2].project(points[
j-1]).expmap(measurementZeroNoise->sample()), measurementNoise);
305 for (
int j=17;
j<=24;
j++)
306 graph.
addMeasurement(3,
j, cameras[3].project(points[
j-1]).expmap(measurementZeroNoise->sample()), measurementNoise);
310 for (
int j=1;
j<=24;
j++)
314 const int numNodeStopPartition = 10;
315 const int minNodesPerMap = 5;
static int runAllTests(TestResult &result)
static enum @843 ordering
EIGEN_DEVICE_FUNC const SqrtReturnType sqrt() const
sharedSubNLG root() const
Pose3 x2(Rot3::Ypr(0.0, 0.0, 0.0), l2)
NonlinearFactorGraph graph
TEST(NestedDissection, oneIsland)
void addPrior(Key key, const T &prior, const SharedNoiseModel &model=nullptr)
static const Symbol l3('l', 3)
Pose3 x3(Rot3::Ypr(M_PI/4.0, 0.0, 0.0), l2)
#define LONGS_EQUAL(expected, actual)
noiseModel::Diagonal::shared_ptr SharedDiagonal
std::vector< int > PartitionTable
void addMeasurement(int i, int j, const Point2 &z, const SharedNoiseModel &model)
noiseModel::Diagonal::shared_ptr priorNoise
PinholeCamera< Cal3_S2 > GeneralCamera