Go to the documentation of this file.00001
00028 #include <isam/Slam.h>
00029 #include <isam/slam2d.h>
00030
00031 using namespace std;
00032 using namespace isam;
00033 using namespace Eigen;
00034
00035
00036
00037
00038
00039 void print_all(Slam& slam) {
00040 list<Node*> ids = slam.get_nodes();
00041 for (list<Node*>::iterator iter = ids.begin(); iter != ids.end(); iter++) {
00042 Pose2d_Node* pose = dynamic_cast<Pose2d_Node*>(*iter);
00043 cout << pose->value() << endl;
00044 }
00045 }
00046
00047 int main() {
00048
00049
00050
00051
00052
00053 Slam slam;
00054
00055 Noise noise = Covariance(0.01 * eye(3));
00056
00057 Pose2d prior(0., 0., 0.);
00058 Pose2d_Node x0;
00059 Pose2d_Node x1;
00060 Pose2d_Node x2;
00061 slam.add_node(&x0);
00062 Pose2d_Factor p_x0(&x0, prior, noise);
00063 slam.add_factor(&p_x0);
00064 Pose2d odo(1., 0., 0.);
00065 slam.add_node(&x1);
00066 Pose2d_Pose2d_Factor o_01(&x0, &x1, odo, noise);
00067 slam.add_factor(&o_01);
00068 slam.add_node(&x2);
00069 Pose2d_Pose2d_Factor o_12(&x1, &x2, odo, noise);
00070 slam.add_factor(&o_12);
00071
00072 slam.batch_optimization();
00073
00074 Pose2d_Node a1;
00075 slam.add_node(&a1);
00076 Pose2d_Pose2d_Factor o_01_new(&x0, &a1, odo, noise);
00077 slam.add_factor(&o_01_new);
00078 Pose2d_Pose2d_Factor o_12_new(&a1, &x2, odo, noise);
00079 slam.add_factor(&o_12_new);
00080 slam.remove_node(&x1);
00081
00082 slam.batch_optimization();
00083
00084 slam.print_stats();
00085 slam.print_graph();
00086
00087 print_all(slam);
00088
00089 return 0;
00090 }