Go to the documentation of this file.00001
00002 #include <ndt_visualisation/ndt_viz.h>
00003 #include <mrpt/utils/CTicTac.h>
00004
00005 #include "ndt_mcl/ParticleFilter3D.h"
00006 #include "ndt_mcl/impl/3d_ndt_mcl.hpp"
00007 using namespace mrpt;
00008 using namespace mrpt::gui;
00009 using namespace mrpt::opengl;
00010
00011 NDTViz<pcl::PointXYZI> ndt_viz;
00012
00013 int main(void){
00014 ParticleFilter3D filt;
00015
00016 filt.initializeNormalRandom(1000, 1, 2, 3, 0.1, 0.2, 0.3, 0.5, 0.5, 0.5, 0.1, 0.1, 0.1);
00017
00018 fprintf(stderr,"Initilized a filter with %d Particles\n", filt.size());
00019 double dx = 0.05;
00020 double dy = 0;
00021 double dz = 0.01;
00022
00023 double droll = 0;
00024 double dpitch =-0.001;
00025 double dyaw = 0.01;
00026
00027 Eigen::Affine3d Tmotion = filt.xyzrpy2affine(dx, dy, dz, droll,dpitch,dyaw);
00028
00029 mrpt::opengl::CGridPlaneXYPtr plane = mrpt::opengl::CGridPlaneXY::Create();
00030 mrpt::opengl::COpenGLScenePtr &scene = ndt_viz.win3D->get3DSceneAndLock();
00031
00032 scene->insert( plane);
00033 ndt_viz.win3D->unlockAccess3DScene();
00034
00035 ndt_viz.displayTrajectory();
00036 for(int i=0;i<1000;i++){
00037 filt.SIRUpdate();
00038 filt.predict(Tmotion, dx*0.1, dy*0.1, dz*0.1, droll*0.1, dpitch*0.1, dyaw*0.1);
00039
00040 ndt_viz.clearParticles();
00041
00042 for(int i=0;i<filt.size();i++){
00043 double x,y,z;
00044 filt.pcloud[i].getXYZ(x,y,z);
00045 ndt_viz.addParticle(x, y,z, 1.0, 1.0, 1.0);
00046 }
00047
00048 Eigen::Affine3d mean = filt.getMean();
00049 ndt_viz.addTrajectoryPoint(mean.translation()[0],mean.translation()[1],mean.translation()[2],1.0,0,0);
00050
00051 ndt_viz.displayParticles();
00052
00053 ndt_viz.repaint();
00054 }
00055
00056 fprintf(stderr,"-- The End --\n");
00057 return 0;
00058 }