PclLoaderParameters.cpp
Go to the documentation of this file.
1 /*
2  * PclLoaderParameters.cpp
3  *
4  * Created on: Nov 7, 2019
5  * Author: Edo Jelavic
6  * Institute: ETH Zurich, Robotic Systems Lab
7  */
8 
10 
11 #include <ros/console.h>
12 
13 namespace grid_map {
14 
15 namespace grid_map_pcl {
16 
17 void PclLoaderParameters::loadParameters(const YAML::Node& yamlNode) {
18  parameters_.numThreads_ = yamlNode["num_processing_threads"].as<int>();
19 
20  parameters_.cloudTransformation_.translation_.x() = yamlNode["cloud_transform"]["translation"]["x"].as<double>();
21  parameters_.cloudTransformation_.translation_.y() = yamlNode["cloud_transform"]["translation"]["y"].as<double>();
22  parameters_.cloudTransformation_.translation_.z() = yamlNode["cloud_transform"]["translation"]["z"].as<double>();
23 
24  parameters_.cloudTransformation_.rpyIntrinsic_.x() = yamlNode["cloud_transform"]["rotation"]["r"].as<double>();
25  parameters_.cloudTransformation_.rpyIntrinsic_.y() = yamlNode["cloud_transform"]["rotation"]["p"].as<double>();
26  parameters_.cloudTransformation_.rpyIntrinsic_.z() = yamlNode["cloud_transform"]["rotation"]["y"].as<double>();
27 
29  yamlNode["cluster_extraction"]["use_max_height_as_cell_elevation"].as<bool>();
30  parameters_.clusterExtraction_.clusterTolerance_ = yamlNode["cluster_extraction"]["cluster_tolerance"].as<double>();
31  parameters_.clusterExtraction_.minNumPoints_ = yamlNode["cluster_extraction"]["min_num_points"].as<int>();
32  parameters_.clusterExtraction_.maxNumPoints_ = yamlNode["cluster_extraction"]["max_num_points"].as<int>();
33 
34  parameters_.outlierRemoval_.isRemoveOutliers_ = yamlNode["outlier_removal"]["is_remove_outliers"].as<bool>();
35  parameters_.outlierRemoval_.meanK_ = yamlNode["outlier_removal"]["mean_K"].as<int>();
36  parameters_.outlierRemoval_.stddevThreshold_ = yamlNode["outlier_removal"]["stddev_threshold"].as<double>();
37 
38  parameters_.gridMap_.resolution_ = yamlNode["grid_map"]["resolution"].as<double>();
39  parameters_.gridMap_.minCloudPointsPerCell_ = yamlNode["grid_map"]["min_num_points_per_cell"].as<int>();
40  parameters_.gridMap_.maxCloudPointsPerCell_ = yamlNode["grid_map"]["max_num_points_per_cell"].as<int>();
41 
42  parameters_.downsampling_.isDownsampleCloud_ = yamlNode["downsampling"]["is_downsample_cloud"].as<bool>();
43  parameters_.downsampling_.voxelSize_.x() = yamlNode["downsampling"]["voxel_size"]["x"].as<double>();
44  parameters_.downsampling_.voxelSize_.y() = yamlNode["downsampling"]["voxel_size"]["y"].as<double>();
45  parameters_.downsampling_.voxelSize_.z() = yamlNode["downsampling"]["voxel_size"]["z"].as<double>();
46 }
47 
48 bool PclLoaderParameters::loadParameters(const std::string& filename) {
49  YAML::Node yamlNode = YAML::LoadFile(filename);
50 
51  const bool loadingFailed = yamlNode.IsNull();
52  if (loadingFailed) {
53  ROS_ERROR_STREAM("PclLoaderParameters: Reading from file failed");
54  return false;
55  }
56 
57  try {
58  const std::string prefix{"pcl_grid_map_extraction"};
59  loadParameters(yamlNode[prefix]);
60  } catch (const std::runtime_error& exception) {
61  ROS_ERROR_STREAM("PclLoaderParameters: Loading parameters failed: " << exception.what());
62  return false;
63  }
64 
65  return true;
66 }
67 
69  return parameters_;
70 }
71 
72 } // namespace grid_map_pcl
73 
74 } // namespace grid_map
bool loadParameters(const std::string &filename)
#define ROS_ERROR_STREAM(args)


grid_map_pcl
Author(s): Dominic Jud , Edo Jelavic
autogenerated on Wed Jul 5 2023 02:23:51