Go to the documentation of this file.00001
00053 #include <isam/isam.h>
00054
00055 using namespace std;
00056 using namespace isam;
00057 using namespace Eigen;
00058
00059 int main() {
00060
00061 Slam slam;
00062
00063
00064 vector<Pose2d_Node*> pose_nodes;
00065
00066 Noise noise3 = Information(100. * eye(3));
00067 Noise noise2 = Information(100. * eye(2));
00068
00069
00070 Pose2d_Node* new_pose_node = new Pose2d_Node();
00071
00072 slam.add_node(new_pose_node);
00073
00074 pose_nodes.push_back(new_pose_node);
00075
00076
00077 Pose2d origin(0., 0., 0.);
00078 Pose2d_Factor* prior = new Pose2d_Factor(pose_nodes[0], origin, noise3);
00079
00080 slam.add_factor(prior);
00081
00082 for (int i=1; i<4; i++) {
00083
00084 Pose2d_Node* new_pose_node = new Pose2d_Node();
00085 slam.add_node(new_pose_node);
00086 pose_nodes.push_back(new_pose_node);
00087
00088
00089 Pose2d odometry(1., 0., 0.);
00090 Pose2d_Pose2d_Factor* constraint = new Pose2d_Pose2d_Factor(pose_nodes[i-1], pose_nodes[i], odometry, noise3);
00091 slam.add_factor(constraint);
00092 }
00093
00094
00095 Point2d_Node* new_point_node = new Point2d_Node();
00096 slam.add_node(new_point_node);
00097
00098
00099 Point2d measure(5., 3.);
00100 Pose2d_Point2d_Factor* measurement =
00101 new Pose2d_Point2d_Factor(pose_nodes[1], new_point_node, measure, noise2);
00102 slam.add_factor(measurement);
00103
00104
00105 slam.batch_optimization();
00106
00107
00108 cout << "Pose 2: " << pose_nodes[2]->value() << endl;
00109
00110
00111 cout << endl << "Full graph:" << endl;
00112 slam.write(cout);
00113
00114 return 0;
00115 }