Utils.h
Go to the documentation of this file.
1 
18 #pragma once
19 #ifndef _UTILS_H
20 #define _UTILS_H
21 
22 #include "ros/ros.h"
23 #include "ros/package.h"
24 #include "pcl_conversions/pcl_conversions.h"
25 #include <pcl_ros/point_cloud.h>
26 
27 #include <Viewer.h>
28 
29 extern const std::string TARGET_CLOUD_TOPIC;
30 extern const std::string SOURCE_CLOUD_TOPIC;
31 
32 class Utils
33 {
34  typedef pcl::PointCloud<pcl::PointXYZ> PointCloudXYZ;
35  typedef pcl::PointCloud<pcl::PointXYZRGB> PointCloudRGB;
36  typedef pcl::PointCloud<pcl::Normal> PointCloudNormal;
37 
38 private:
43  Utils(){};
44 
49  ~Utils(){};
50 
51 public:
57  static void setPCpath(const std::string& pointcloud_folder_path);
58 
68  static bool getNormals(PointCloudRGB::Ptr& cloud, double normal_radius, PointCloudNormal::Ptr& normals);
69 
77  static bool isValidCloud(PointCloudXYZ::Ptr cloud);
78 
86  static bool isValidCloud(PointCloudRGB::Ptr cloud);
87 
95  static bool isValidCloud(PointCloudNormal::Ptr normals);
96 
104  static bool isValidMesh(pcl::PolygonMesh::Ptr mesh);
105 
113  static bool isValidCloudMsg(const sensor_msgs::PointCloud2& cloud_msg);
114 
122  static bool isValidTransform(Eigen::Matrix4f transform);
123 
132  static void colorizeCloud(PointCloudRGB::Ptr cloud_rgb, int R, int G, int B);
133 
143  static void cloudToXYZRGB(PointCloudXYZ::Ptr cloud, PointCloudRGB::Ptr cloud_rgb, int R, int G, int B);
144 
151  static void cloudToROSMsg(PointCloudRGB::Ptr cloud, sensor_msgs::PointCloud2& cloud_msg, const std::string& frameid="world");
152 
159  static void cloudToROSMsg(const pcl::PCLPointCloud2& cloud, sensor_msgs::PointCloud2& cloud_msg, const std::string& frameid="world");
160 
167  static double computeCloudResolution(PointCloudXYZ::Ptr cloud);
168 
175  static double computeCloudResolution(PointCloudRGB::Ptr cloud);
176 
182  static void printTransform(const Eigen::Matrix4f& transform);
183 
190  static void printMatrix(const Eigen::Ref<const Eigen::MatrixXf>& matrix, const int size);
191 
200  static void onePointCloud(PointCloudRGB::Ptr cloud, int size,
201  PointCloudRGB::Ptr one_point_cloud);
202 
212  static void translateCloud(PointCloudRGB::Ptr cloud_in, PointCloudRGB::Ptr cloud_out,
213  double x_offset = 0, double y_offset = 0, double z_offset = 0);
214 
224  static void rotateCloud(PointCloudRGB::Ptr cloud_in, PointCloudRGB::Ptr cloud_out,
225  double roll, double pitch, double yaw);
226 
234  static void getVectorFromNormal(PointCloudNormal::Ptr normal, double idx,
235  Eigen::Vector3f& vector);
236 
247  static bool searchForSameRows(Eigen::MatrixXd source_m, Eigen::MatrixXd target_m,
248  std::vector<int>& source_indx, std::vector<int>& target_indx);
249 
259  static bool areSameVectors(const Eigen::VectorXd v1,
260  const Eigen::VectorXd v2,
261  double threshold);
262 
271  static int findOnVector(double value,
272  const Eigen::VectorXd v,
273  double threshold);
274 
283  static int findOnMatrix(const Eigen::VectorXd v,
284  const Eigen::MatrixXd m,
285  double threshold);
286 
293  static void extractRowFromMatrix(Eigen::MatrixXd& matrix, int row);
294 
301  static void extractColFromMatrix(Eigen::MatrixXd& matrix, int col);
302 };
303 
304 #endif
static void printTransform(const Eigen::Matrix4f &transform)
Print on console transform values with matrix format.
Definition: Utils.cpp:176
static bool getNormals(PointCloudRGB::Ptr &cloud, double normal_radius, PointCloudNormal::Ptr &normals)
Get the normals for input cloud with specified normal&#39;s radius.
Definition: Utils.cpp:27
static bool isValidTransform(Eigen::Matrix4f transform)
Check whether transform contains valid data and is not NaN.
Definition: Utils.cpp:71
static void extractColFromMatrix(Eigen::MatrixXd &matrix, int col)
Supress col from matrix.
Definition: Utils.cpp:304
static bool searchForSameRows(Eigen::MatrixXd source_m, Eigen::MatrixXd target_m, std::vector< int > &source_indx, std::vector< int > &target_indx)
Check if both matrix have a coinciden row.
Definition: Utils.cpp:245
static void printMatrix(const Eigen::Ref< const Eigen::MatrixXf > &matrix, const int size)
Print on console matrix values with matrix format.
Definition: Utils.cpp:182
const std::string SOURCE_CLOUD_TOPIC
Definition: Utils.cpp:25
static int findOnVector(double value, const Eigen::VectorXd v, double threshold)
Find value on vector with given threshold. Returns index vector of value found. If not found returns ...
Definition: Utils.cpp:284
~Utils()
This class is not meant to be instantiated.
Definition: Utils.h:49
pcl::PointCloud< pcl::PointXYZRGB > PointCloudRGB
Definition: Utils.h:35
Utils()
This class is not meant to be instantiated.
Definition: Utils.h:43
static void cloudToXYZRGB(PointCloudXYZ::Ptr cloud, PointCloudRGB::Ptr cloud_rgb, int R, int G, int B)
Convert XYZ cloud to XYZRGB cloud with specified RGB values.
Definition: Utils.cpp:94
static void getVectorFromNormal(PointCloudNormal::Ptr normal, double idx, Eigen::Vector3f &vector)
Obtain normal values as a vector.
Definition: Utils.cpp:234
static void colorizeCloud(PointCloudRGB::Ptr cloud_rgb, int R, int G, int B)
Apply RGB values to cloud.
Definition: Utils.cpp:84
static bool isValidCloud(PointCloudXYZ::Ptr cloud)
Check whether cloud contains data and is not empty.
Definition: Utils.cpp:46
static void onePointCloud(PointCloudRGB::Ptr cloud, int size, PointCloudRGB::Ptr one_point_cloud)
Apply extract indices filter to input cloud with given indices.
Definition: Utils.cpp:188
static bool areSameVectors(const Eigen::VectorXd v1, const Eigen::VectorXd v2, double threshold)
Check if given vectors are equal with a given tolerance (threshold).
Definition: Utils.cpp:273
const std::string TARGET_CLOUD_TOPIC
Definition: Utils.cpp:24
pcl::PointCloud< pcl::Normal > PointCloudNormal
Definition: Utils.h:36
static void cloudToROSMsg(PointCloudRGB::Ptr cloud, sensor_msgs::PointCloud2 &cloud_msg, const std::string &frameid="world")
Convert XYZRGB cloud to PointCloud2.
Definition: Utils.cpp:100
static int findOnMatrix(const Eigen::VectorXd v, const Eigen::MatrixXd m, double threshold)
Find vector as row on matrix with given threshold. Returns index of matrix row. If not found returns ...
Definition: Utils.cpp:294
static void extractRowFromMatrix(Eigen::MatrixXd &matrix, int row)
Supress row from matrix.
Definition: Utils.cpp:315
static void translateCloud(PointCloudRGB::Ptr cloud_in, PointCloudRGB::Ptr cloud_out, double x_offset=0, double y_offset=0, double z_offset=0)
Apply translation to Cloud. Values given in [m].
Definition: Utils.cpp:203
static double computeCloudResolution(PointCloudXYZ::Ptr cloud)
Obtain the resolution of the cloud.
Definition: Utils.cpp:114
static void rotateCloud(PointCloudRGB::Ptr cloud_in, PointCloudRGB::Ptr cloud_out, double roll, double pitch, double yaw)
Apply rotation to cloud. Values given in [rad].
Definition: Utils.cpp:215
Definition: Utils.h:32
static bool isValidMesh(pcl::PolygonMesh::Ptr mesh)
Check whether mesh contains data and is not empty.
Definition: Utils.cpp:61
static bool isValidCloudMsg(const sensor_msgs::PointCloud2 &cloud_msg)
Check whether PointCloud2 contains data and is not empty.
Definition: Utils.cpp:66
static void setPCpath(const std::string &pointcloud_folder_path)
Set the pointcloud folder path object.
pcl::PointCloud< pcl::PointXYZ > PointCloudXYZ
Definition: Utils.h:34


leica_point_cloud_processing
Author(s): Ines Lara Sicilia
autogenerated on Fri Feb 5 2021 03:20:30