CLaserOdometry2D.h
Go to the documentation of this file.
00001 
00016 #ifndef CLaserOdometry2D_H
00017 #define CLaserOdometry2D_H
00018 
00019 #include <ros/ros.h>
00020 #include <tf/transform_broadcaster.h>
00021 #include <tf/transform_listener.h>
00022 #include <nav_msgs/Odometry.h>
00023 #include <sensor_msgs/LaserScan.h>
00024 #include <geometry_msgs/Twist.h>
00025 
00026 // MRPT related headers
00027 // MRPT related headers
00028 #include <mrpt/version.h>
00029 #if MRPT_VERSION>=0x130
00030 #       include <mrpt/obs/CObservation2DRangeScan.h>
00031 #   include <mrpt/obs/CObservationOdometry.h>
00032     using namespace mrpt::obs;
00033 #else
00034 #       include <mrpt/slam/CObservation2DRangeScan.h>
00035 #   include <mrpt/slam/CObservationOdometry.h>
00036     using namespace mrpt::slam;
00037 #endif
00038 #include <mrpt/system/threads.h>
00039 #include <mrpt/system/os.h>
00040 #include <mrpt/poses/CPose3D.h>
00041 #include <mrpt/utils.h>
00042 #include <mrpt/opengl.h>
00043 #include <mrpt/math/CHistogram.h>
00044 
00045 #include <boost/bind.hpp>
00046 #include <Eigen/Dense>
00047 #include <unsupported/Eigen/MatrixFunctions>
00048 #include <iostream>
00049 #include <fstream>
00050 #include <numeric>
00051 
00052 
00053 
00054 class CLaserOdometry2D
00055 {
00056 public:
00057         CLaserOdometry2D();
00058     ~CLaserOdometry2D();
00059     bool is_initialized();
00060     bool scan_available();
00061     void Init();
00062     void odometryCalculation();
00063 
00064     std::string laser_scan_topic;
00065     std::string base_frame_id;
00066     std::string odom_frame_id;
00067     double freq;
00068 
00069 protected:
00070     ros::NodeHandle n;
00071     sensor_msgs::LaserScan last_scan;    
00072     bool module_initialized,first_laser_scan,new_scan_available;
00073     tf::TransformListener tf_listener;          //Do not put inside the callback
00074     tf::TransformBroadcaster odom_broadcaster;
00075 
00076     //Subscriptions & Publishers
00077     ros::Subscriber laser_sub;
00078     ros::Publisher odom_pub;
00079 
00080     //CallBacks
00081     void LaserCallBack(const sensor_msgs::LaserScan::ConstPtr& new_scan);
00082 
00083     // Internal Data
00084         std::vector<Eigen::MatrixXf> range;
00085         std::vector<Eigen::MatrixXf> range_old;
00086         std::vector<Eigen::MatrixXf> range_inter;
00087         std::vector<Eigen::MatrixXf> range_warped;
00088         std::vector<Eigen::MatrixXf> xx;
00089         std::vector<Eigen::MatrixXf> xx_inter;
00090         std::vector<Eigen::MatrixXf> xx_old;
00091         std::vector<Eigen::MatrixXf> xx_warped;
00092         std::vector<Eigen::MatrixXf> yy;
00093         std::vector<Eigen::MatrixXf> yy_inter;
00094         std::vector<Eigen::MatrixXf> yy_old;
00095         std::vector<Eigen::MatrixXf> yy_warped;
00096         std::vector<Eigen::MatrixXf> transformations;
00097         
00098         Eigen::MatrixXf range_wf;
00099         Eigen::MatrixXf dtita;
00100         Eigen::MatrixXf dt;
00101         Eigen::MatrixXf rtita;
00102         Eigen::MatrixXf normx, normy, norm_ang;
00103         Eigen::MatrixXf weights;
00104         Eigen::MatrixXi null;
00105 
00106     Eigen::MatrixXf A,Aw;
00107     Eigen::MatrixXf B,Bw;
00108         Eigen::Matrix<float, 3, 1> Var; //3 unknowns: vx, vy, w
00109         Eigen::Matrix<float, 3, 3> cov_odo;
00110 
00111 
00112 
00113     //std::string LaserVarName;                         //Name of the topic containing the scan lasers \laser_scan
00114         float fps;                                                              //In Hz
00115         float fovh;                                                             //Horizontal FOV
00116         unsigned int cols;
00117         unsigned int cols_i;
00118         unsigned int width;
00119         unsigned int ctf_levels;
00120         unsigned int image_level, level;
00121         unsigned int num_valid_range;
00122     unsigned int iter_irls;
00123         float g_mask[5];
00124 
00125     //mrpt::gui::CDisplayWindowPlots window;
00126         mrpt::utils::CTicTac            m_clock;
00127         float           m_runtime;
00128     ros::Time last_odom_time;
00129 
00130         mrpt::math::CMatrixFloat31 kai_abs;
00131         mrpt::math::CMatrixFloat31 kai_loc;
00132         mrpt::math::CMatrixFloat31 kai_loc_old;
00133         mrpt::math::CMatrixFloat31 kai_loc_level;
00134 
00135         mrpt::poses::CPose3D laser_pose;
00136         mrpt::poses::CPose3D laser_oldpose;
00137     mrpt::poses::CPose3D robot_pose;
00138     mrpt::poses::CPose3D robot_oldpose;
00139         bool test;
00140     std::vector<double> last_m_lin_speeds;
00141     std::vector<double> last_m_ang_speeds;
00142 
00143 
00144         // Methods
00145         void createImagePyramid();
00146         void calculateCoord();
00147         void performWarping();
00148         void calculaterangeDerivativesSurface();
00149         void computeNormals();  
00150         void computeWeights();
00151         void findNullPoints();
00152         void solveSystemOneLevel();
00153     void solveSystemNonLinear();
00154         void filterLevelSolution();
00155         void PoseUpdate();
00156     void Reset(mrpt::poses::CPose3D ini_pose, CObservation2DRangeScan scan);
00157 };
00158 
00159 #endif


rf2o_laser_odometry
Author(s): Mariano Jaimez , Javier G. Monroy
autogenerated on Thu Jun 6 2019 21:16:31