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::handleYamlNode(const YAML::Node& yamlNode) {
18  const std::string prefix = "pcl_grid_map_extraction";
19 
20  parameters_.numThreads_ = yamlNode[prefix]["num_processing_threads"].as<int>();
21 
22  parameters_.cloudTransformation_.translation_.x() = yamlNode[prefix]["cloud_transform"]["translation"]["x"].as<double>();
23  parameters_.cloudTransformation_.translation_.y() = yamlNode[prefix]["cloud_transform"]["translation"]["y"].as<double>();
24  parameters_.cloudTransformation_.translation_.z() = yamlNode[prefix]["cloud_transform"]["translation"]["z"].as<double>();
25 
26  parameters_.cloudTransformation_.rpyIntrinsic_.x() = yamlNode[prefix]["cloud_transform"]["rotation"]["r"].as<double>();
27  parameters_.cloudTransformation_.rpyIntrinsic_.y() = yamlNode[prefix]["cloud_transform"]["rotation"]["p"].as<double>();
28  parameters_.cloudTransformation_.rpyIntrinsic_.z() = yamlNode[prefix]["cloud_transform"]["rotation"]["y"].as<double>();
29 
31  yamlNode[prefix]["cluster_extraction"]["use_max_height_as_cell_elevation"].as<bool>();
32  parameters_.clusterExtraction_.clusterTolerance_ = yamlNode[prefix]["cluster_extraction"]["cluster_tolerance"].as<double>();
33  parameters_.clusterExtraction_.minNumPoints_ = yamlNode[prefix]["cluster_extraction"]["min_num_points"].as<int>();
34  parameters_.clusterExtraction_.maxNumPoints_ = yamlNode[prefix]["cluster_extraction"]["max_num_points"].as<int>();
35 
36  parameters_.outlierRemoval_.isRemoveOutliers_ = yamlNode[prefix]["outlier_removal"]["is_remove_outliers"].as<bool>();
37  parameters_.outlierRemoval_.meanK_ = yamlNode[prefix]["outlier_removal"]["mean_K"].as<int>();
38  parameters_.outlierRemoval_.stddevThreshold_ = yamlNode[prefix]["outlier_removal"]["stddev_threshold"].as<double>();
39 
40  parameters_.gridMap_.resolution_ = yamlNode[prefix]["grid_map"]["resolution"].as<double>();
41  parameters_.gridMap_.minCloudPointsPerCell_ = yamlNode[prefix]["grid_map"]["min_num_points_per_cell"].as<int>();
42 
43  parameters_.downsampling_.isDownsampleCloud_ = yamlNode[prefix]["downsampling"]["is_downsample_cloud"].as<bool>();
44  parameters_.downsampling_.voxelSize_.x() = yamlNode[prefix]["downsampling"]["voxel_size"]["x"].as<double>();
45  parameters_.downsampling_.voxelSize_.y() = yamlNode[prefix]["downsampling"]["voxel_size"]["y"].as<double>();
46  parameters_.downsampling_.voxelSize_.z() = yamlNode[prefix]["downsampling"]["voxel_size"]["z"].as<double>();
47 }
48 
49 bool PclLoaderParameters::loadParameters(const std::string& filename) {
50  YAML::Node yamlNode = YAML::LoadFile(filename);
51 
52  const bool loadingFailed = yamlNode.IsNull();
53  if (loadingFailed) {
54  ROS_ERROR_STREAM("PclLoaderParameters: Reading from file failed");
55  return false;
56  }
57 
58  try {
59  handleYamlNode(yamlNode);
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)
void handleYamlNode(const YAML::Node &yamlNode)
#define ROS_ERROR_STREAM(args)


grid_map_pcl
Author(s): Dominic Jud , Edo Jelavic
autogenerated on Tue Jun 1 2021 02:13:43