misc.h
Go to the documentation of this file.
00001 #ifndef RGBD_SLAM_MISC_H_
00002 #define RGBD_SLAM_MISC_H_
00003 /* This file is part of RGBDSLAM.
00004  * 
00005  * RGBDSLAM is free software: you can redistribute it and/or modify
00006  * it under the terms of the GNU General Public License as published by
00007  * the Free Software Foundation, either version 3 of the License, or
00008  * (at your option) any later version.
00009  * 
00010  * RGBDSLAM is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  * GNU General Public License for more details.
00014  * 
00015  * You should have received a copy of the GNU General Public License
00016  * along with RGBDSLAM.  If not, see <http://www.gnu.org/licenses/>.
00017  */
00018 #include <QMatrix4x4>
00019 #include <tf/transform_datatypes.h>
00020 #include <sensor_msgs/Image.h>
00021 #include <sensor_msgs/CameraInfo.h>
00022 #include <cv.h>
00023 #include "point_types.h"
00024 #include "g2o/types/slam3d/vertex_se3.h"
00025 
00027 void overlay_edges(cv::Mat visual, cv::Mat depth, cv::Mat& visual_edges, cv::Mat& depth_edges);
00029 void printTransform(const char* name, const tf::Transform t) ;
00031 void printTransform(const char* name, const tf::StampedTransform t) ;
00033 void logTransform(QTextStream& out, const tf::Transform& t, double timestamp, const char* label = NULL);
00034 void printQMatrix4x4(const char* name, const QMatrix4x4& m);
00035 
00037 QMatrix4x4    g2o2QMatrix(const g2o::SE3Quat se3) ;
00039 tf::Transform g2o2TF(     const g2o::SE3Quat se3) ;
00040 template <typename T >
00041 QMatrix4x4 eigenTF2QMatrix(const T& transf) 
00042 {
00043   Eigen::Matrix<qreal, 4, 4, Eigen::RowMajor> m = transf.matrix();
00044   QMatrix4x4 qmat( static_cast<qreal*>( m.data() )  );
00045   printQMatrix4x4("From Eigen::Transform", qmat); 
00046   return qmat;
00047 }
00048 
00049 template <typename T >
00050 tf::Transform eigenTransf2TF(const T& transf) 
00051 {
00052     tf::Transform result;
00053     tf::Vector3 translation;
00054     translation.setX(transf.translation().x());
00055     translation.setY(transf.translation().y());
00056     translation.setZ(transf.translation().z());
00057 
00058     tf::Quaternion rotation;
00059     Eigen::Quaterniond quat;
00060     quat = transf.rotation();
00061     rotation.setX(quat.x());
00062     rotation.setY(quat.y());
00063     rotation.setZ(quat.z());
00064     rotation.setW(quat.w());
00065 
00066     result.setOrigin(translation);
00067     result.setRotation(rotation);
00068     //printTransform("from conversion", result);
00069     return result;
00070 }
00072 g2o::SE3Quat  eigen2G2O(  const Eigen::Matrix4d& eigen_mat);
00074 g2o::SE3Quat  tf2G2O(     const tf::Transform t);
00075 
00077 void mat2components(const Eigen::Matrix4f& t, double& roll, double& pitch, double& yaw, double& dist);
00079 void mat2RPY(const Eigen::Matrix4f& t, double& roll, double& pitch, double& yaw);
00081 void mat2dist(const Eigen::Matrix4f& t, double &dist);
00082 
00083 
00085 pointcloud_type* createXYZRGBPointCloud (const sensor_msgs::ImageConstPtr& depth_msg, const sensor_msgs::ImageConstPtr& rgb_msg, const sensor_msgs::CameraInfoConstPtr& cam_info); 
00086 pointcloud_type* createXYZRGBPointCloud (const cv::Mat& depth_msg, const cv::Mat& rgb_msg, const sensor_msgs::CameraInfoConstPtr& cam_info); 
00087 
00088 #ifndef HEMACLOUDS
00089 
00090 
00091 void transformAndAppendPointCloud (const pointcloud_type &cloud_in, pointcloud_type &cloud_to_append_to,
00092                                    const tf::Transform transformation, float Max_Depth, int idx=0);
00093 
00094 #else
00095 
00096 void transformAndAppendPointCloud (const pointcloud_type &cloud_in, 
00097                                    pcl::PointCloud<hema::PointXYZRGBCamSL> &cloud_to_append_to,
00098                                    const tf::Transform transformation, float max_Depth, int idx);
00099 #endif
00100 
00101 //geometry_msgs::Point pointInWorldFrame(const Eigen::Vector4f& point3d, g2o::SE3Quat transf);
00102 geometry_msgs::Point pointInWorldFrame(const Eigen::Vector4f& point3d, const g2o::VertexSE3::EstimateType& transf);
00103 // true if translation > 10cm or largest euler-angle>5 deg
00104 // used to decide if the camera has moved far enough to generate a new nodes
00105 //bool isBigTrafo(const Eigen::Matrix4f& t);
00106 bool isBigTrafo(const Eigen::Isometry3d& t);
00107 bool isBigTrafo(const g2o::SE3Quat& t);
00109 bool isSmallTrafo(const g2o::SE3Quat& t, double seconds = 1.0);
00110 bool isSmallTrafo(const Eigen::Isometry3d& t, double seconds = 1.0);
00111 
00112 
00113 //bool overlappingViews(LoadedEdge3D edge);
00114 //bool triangleRayIntersection(Eigen::Vector3d triangle1,Eigen::Vector3d triangle2, Eigen::Vector3d ray_origin, Eigen::Vector3d ray);
00115 
00116 
00118 void depthToCV8UC1(cv::Mat& float_img, cv::Mat& mono8_img);
00119 
00121 std::string openCVCode2String(unsigned int code);
00122 
00124 void printMatrixInfo(const cv::Mat& image, std::string name = std::string(""));
00125 
00127 bool asyncFrameDrop(ros::Time depth, ros::Time rgb);
00128 
00129 double errorFunction(const Eigen::Vector4f& x1, const double x1_depth_cov, 
00130                       const Eigen::Vector4f& x2, const double x2_depth_cov, 
00131                       const Eigen::Matrix4f& tf_1_to_2);
00132 
00133 double errorFunction2(const Eigen::Vector4f& x1, 
00134                       const Eigen::Vector4f& x2, 
00135                       const Eigen::Matrix4d& tf_1_to_2);
00136 
00137 float getMinDepthInNeighborhood(const cv::Mat& depth, cv::Point2f center, float diameter);
00138 
00139 void observationLikelihood(const Eigen::Matrix4f& proposed_transformation,//new to old
00140                              pointcloud_type::Ptr new_pc,
00141                              pointcloud_type::Ptr old_pc,
00142                              const sensor_msgs::CameraInfo& old_cam_info,
00143                              double& likelihood, 
00144                              double& confidence,
00145                              unsigned int& inliers,
00146                              unsigned int& outliers,
00147                              unsigned int& occluded,
00148                              unsigned int& all) ;
00149 
00153 double rejectionSignificance(const Eigen::Matrix4f& proposed_transformation,//new to old
00154                              pointcloud_type::Ptr new_pc,
00155                              pointcloud_type::Ptr old_pc);
00156 
00158 bool observation_criterion_met(unsigned int inliers, unsigned int outliers, unsigned int all, double& quality);
00159 
00160 /*
00161 cv::Point nearest_neighbor(const cv::Mat source&, const cv::Mat& destination, const Eigen::Matrix4f& transformation_source_to_destination, cv::Point query_point);
00162 Eigen::Vector3f nearest_neighbor(const cv::Mat source&, const cv::Mat& destination, const Eigen::Matrix4f& transformation_source_to_destination, Eigen::Vector3f query_point);
00163 */
00164 void getColor(const point_type& p, unsigned char& r, unsigned char& g, unsigned char& b);
00165 #endif


rgbdslam_v2
Author(s): Felix Endres, Juergen Hess, Nikolas Engelhard
autogenerated on Thu Jun 6 2019 21:49:45