11 #include "SubmapPlanarSLAM.h"
12 #include "SubmapVisualSLAM.h"
13 #include "SubmapExamples.h"
14 #include "SubmapExamples3D.h"
16 #include "NonlinearTSAM.h"
20 using namespace gtsam;
29 using namespace submapPlanarSLAM;
30 typedef TSAM2D::SubNLG SubNLG;
33 fg.addBearingRange(1, 1,
Rot2(), 0., bearingRangeNoise);
34 fg.addBearingRange(2, 1,
Rot2(), 0., bearingRangeNoise);
35 fg.addPoseConstraint(1,
Pose2());
39 int numNodeStopPartition = 1e3;
40 int minNodesPerMap = 1e3;
53 using namespace submapPlanarSLAM;
54 typedef TSAM2D::SubNLG SubNLG;
62 fg.addPoseConstraint(1,
Pose2());
63 fg.addPoseConstraint(4,
Pose2());
66 int numNodeStopPartition = 2;
67 int minNodesPerMap = 1;
90 using namespace submapPlanarSLAM;
91 typedef TSAM2D::SubNLG SubNLG;
97 fg.addPoseConstraint(1,
Pose2());
98 fg.addPoseConstraint(4,
Pose2());
101 int numNodeStopPartition = 2;
102 int minNodesPerMap = 1;
134 using namespace submapPlanarSLAM;
135 typedef TSAM2D::SubNLG SubNLG;
141 fg.addBearingRange(1, 6,
Rot2(), 0., bearingRangeNoise);
142 fg.addBearingRange(2, 6,
Rot2(), 0., bearingRangeNoise);
143 fg.addBearingRange(5, 6,
Rot2(), 0., bearingRangeNoise);
144 fg.addPoseConstraint(1,
Pose2());
145 fg.addPoseConstraint(4,
Pose2());
146 fg.addPoseConstraint(5,
Pose2());
149 int numNodeStopPartition = 2;
150 int minNodesPerMap = 1;
181 using namespace submapPlanarSLAM;
183 typedef TSAM2D::SubNLG SubNLG;
189 fg.addBearingRange(
x0,
l1, Rot2::fromAngle(
M_PI_2), 1, bearingRangeNoise);
190 fg.addBearingRange(
x0,
l4, Rot2::fromAngle(-
M_PI_2), 1, bearingRangeNoise);
191 fg.addBearingRange(
x0,
l2, Rot2::fromAngle(
M_PI_4),
sqrt(2), bearingRangeNoise);
192 fg.addBearingRange(
x0, l5, Rot2::fromAngle(-
M_PI_4),
sqrt(2), bearingRangeNoise);
194 fg.addBearingRange(
x1,
l1, Rot2::fromAngle(
M_PI_4 * 3),
sqrt(2), bearingRangeNoise);
195 fg.addBearingRange(
x1,
l2, Rot2::fromAngle(
M_PI_2), 1, bearingRangeNoise);
196 fg.addBearingRange(
x1,
l3, Rot2::fromAngle(
M_PI_4),
sqrt(2), bearingRangeNoise);
197 fg.addBearingRange(
x1,
l4, Rot2::fromAngle(-
M_PI_4 * 3),
sqrt(2), bearingRangeNoise);
198 fg.addBearingRange(
x1, l5, Rot2::fromAngle(
M_PI_2), 1, bearingRangeNoise);
199 fg.addBearingRange(
x1, l6, Rot2::fromAngle(-
M_PI_4),
sqrt(2), bearingRangeNoise);
201 fg.addBearingRange(
x2,
l2, Rot2::fromAngle(
M_PI_4 * 3),
sqrt(2), bearingRangeNoise);
202 fg.addBearingRange(
x2, l5, Rot2::fromAngle(-
M_PI_4 * 3),
sqrt(2), bearingRangeNoise);
203 fg.addBearingRange(
x2,
l3, Rot2::fromAngle(
M_PI_2), 1, bearingRangeNoise);
204 fg.addBearingRange(
x2, l6, Rot2::fromAngle(-
M_PI_2), 1, bearingRangeNoise);
212 std::shared_ptr<Cuts> cuts(
new Cuts());
215 (*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;
217 cuts->children.push_back(std::shared_ptr<Cuts>(
new Cuts()));
218 cuts->children[0]->partitionTable =
PartitionTable(9, -1);
p = &cuts->children[0]->partitionTable;
220 (*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;
222 cuts->children.push_back(std::shared_ptr<Cuts>(
new Cuts()));
223 cuts->children[1]->partitionTable =
PartitionTable(9, -1);
p = &cuts->children[1]->partitionTable;
225 (*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;
242 LONGS_EQUAL(1, nd.
root()->children()[0]->children()[0]->frontal().size());
246 LONGS_EQUAL(1, nd.
root()->children()[0]->children()[1]->frontal().size());
255 LONGS_EQUAL(1, nd.
root()->children()[1]->children()[0]->frontal().size());
259 LONGS_EQUAL(1, nd.
root()->children()[1]->children()[1]->frontal().size());
269 using namespace gtsam::submapVisualSLAM;
270 typedef TSAM3D::SubNLG SubNLG;
272 vector<GeneralCamera> cameras;
278 vector<Point3> points;
279 for (
int cube_index = 0; cube_index <= 3; cube_index++) {
280 Point3 center((cube_index-1) * 3, 0.5, 10.);
281 points.push_back(center +
Point3(-0.5, -0.5, -0.5));
282 points.push_back(center +
Point3(-0.5, 0.5, -0.5));
283 points.push_back(center +
Point3( 0.5, 0.5, -0.5));
284 points.push_back(center +
Point3( 0.5, -0.5, -0.5));
285 points.push_back(center +
Point3(-0.5, -0.5, 0.5));
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));
294 for (
int j=1;
j<=8;
j++)
295 graph.addMeasurement(0,
j, cameras[0].project(points[
j-1]).expmap(measurementZeroNoise->sample()), measurementNoise);
296 for (
int j=1;
j<=16;
j++)
297 graph.addMeasurement(1,
j, cameras[1].project(points[
j-1]).expmap(measurementZeroNoise->sample()), measurementNoise);
298 for (
int j=9;
j<=24;
j++)
299 graph.addMeasurement(2,
j, cameras[2].project(points[
j-1]).expmap(measurementZeroNoise->sample()), measurementNoise);
300 for (
int j=17;
j<=24;
j++)
301 graph.addMeasurement(3,
j, cameras[3].project(points[
j-1]).expmap(measurementZeroNoise->sample()), measurementNoise);
305 for (
int j=1;
j<=24;
j++)
309 const int numNodeStopPartition = 10;
310 const int minNodesPerMap = 5;