From 157c8e486d0d2129f92a3e1ed7fa8129af3c1a54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matou=C5=A1=20Vrba?= Date: Sun, 15 Oct 2023 12:08:09 +0200 Subject: [PATCH] minor refactor of BelowGroundRemoval filter (does anyone even use this?) --- src/remove_below_ground_filter.cpp | 42 ++++++++++++++++-------------- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/src/remove_below_ground_filter.cpp b/src/remove_below_ground_filter.cpp index e133f64..291f671 100644 --- a/src/remove_below_ground_filter.cpp +++ b/src/remove_below_ground_filter.cpp @@ -3,29 +3,31 @@ namespace mrs_pcl_tools { -void RemoveBelowGroundFilter::initialize(ros::NodeHandle& nh, const std::shared_ptr common_handlers) { - common_handlers->param_loader->loadParamReusable("keep_organized", keep_organized, false); - common_handlers->param_loader->loadParam("ground_removal/plane_offset", plane_offset, 1.0); - const auto pfx = common_handlers->param_loader->getPrefix(); + void RemoveBelowGroundFilter::initialize(ros::NodeHandle& nh, const std::shared_ptr common_handlers) + { + common_handlers->param_loader->loadParamReusable("keep_organized", keep_organized, false); + common_handlers->param_loader->loadParam("ground_removal/plane_offset", plane_offset, 1.0); + const auto pfx = common_handlers->param_loader->getPrefix(); - if (common_handlers->transformer == nullptr) { - common_handlers->param_loader->setPrefix(""); - std::string uav_name; - common_handlers->param_loader->loadParamReusable("uav_name", uav_name); - common_handlers->param_loader->setPrefix(pfx); - this->transformer = std::make_shared("RemoveBelowGroundFilter"); - this->transformer->setDefaultPrefix(uav_name); - this->transformer->setLookupTimeout(ros::Duration(0.3)); - this->transformer->retryLookupNewest(true); - } else { - this->transformer = common_handlers->transformer; - } + if (common_handlers->transformer == nullptr) + { + common_handlers->param_loader->setPrefix(""); + const auto uav_name = common_handlers->param_loader->loadParamReusable2("uav_name"); + common_handlers->param_loader->setPrefix(pfx); + this->transformer = std::make_shared("RemoveBelowGroundFilter"); + this->transformer->setDefaultPrefix(uav_name); + this->transformer->setLookupTimeout(ros::Duration(0.3)); + this->transformer->retryLookupNewest(true); + } else + { + this->transformer = common_handlers->transformer; + } - m_ground_detector.initialize(nh, this->transformer, - GroundplaneDetector::groundplane_detection_config_t(*common_handlers->param_loader, pfx + "ground_removal/")); + m_ground_detector.initialize(nh, + this->transformer, GroundplaneDetector::groundplane_detection_config_t(*common_handlers->param_loader, pfx + "ground_removal/")); - initialized = true; -} + initialized = true; + } } // namespace mrs_pcl_tools