From fe52157b14d9edcdcbfaecb1b101f0e7e754e264 Mon Sep 17 00:00:00 2001 From: john-maidbot Date: Sat, 11 May 2024 12:41:35 -0500 Subject: [PATCH] Get user specified parameters at startup --- .../src/draco_publisher.cpp | 23 +++++++++++++++---- .../src/draco_subscriber.cpp | 5 ++++ .../src/zlib_publisher.cpp | 1 + .../src/zstd_publisher.cpp | 1 + 4 files changed, 25 insertions(+), 5 deletions(-) diff --git a/draco_point_cloud_transport/src/draco_publisher.cpp b/draco_point_cloud_transport/src/draco_publisher.cpp index 72b7f7e..734a7dc 100644 --- a/draco_point_cloud_transport/src/draco_publisher.cpp +++ b/draco_point_cloud_transport/src/draco_publisher.cpp @@ -85,6 +85,7 @@ void DracoPublisher::declareParameters(const std::string & base_topic) declareParam( encode_speed_paramDescriptor.name, config_.encode_speed, encode_speed_paramDescriptor); + getParam(encode_speed_paramDescriptor.name, config_.encode_speed); rcl_interfaces::msg::ParameterDescriptor decode_speed_paramDescriptor; decode_speed_paramDescriptor.name = "decode_speed"; @@ -99,6 +100,7 @@ void DracoPublisher::declareParameters(const std::string & base_topic) declareParam( decode_speed_paramDescriptor.name, config_.decode_speed, decode_speed_paramDescriptor); + getParam(decode_speed_paramDescriptor.name, config_.decode_speed); rcl_interfaces::msg::ParameterDescriptor encode_method_paramDescriptor; encode_method_paramDescriptor.name = "encode_method"; @@ -113,6 +115,7 @@ void DracoPublisher::declareParameters(const std::string & base_topic) declareParam( encode_method_paramDescriptor.name, config_.encode_method, encode_method_paramDescriptor); + getParam(encode_method_paramDescriptor.name, config_.encode_method); rcl_interfaces::msg::ParameterDescriptor deduplicate_paramDescriptor; deduplicate_paramDescriptor.name = "deduplicate"; @@ -120,6 +123,7 @@ void DracoPublisher::declareParameters(const std::string & base_topic) deduplicate_paramDescriptor.description = "Remove duplicate point entries."; declareParam(deduplicate_paramDescriptor.name, true, deduplicate_paramDescriptor); + getParam(deduplicate_paramDescriptor.name, config_.deduplicate); rcl_interfaces::msg::ParameterDescriptor force_quantization_paramDescriptor; force_quantization_paramDescriptor.name = "force_quantization"; @@ -130,6 +134,7 @@ void DracoPublisher::declareParameters(const std::string & base_topic) declareParam( force_quantization_paramDescriptor.name, config_.force_quantization, force_quantization_paramDescriptor); + getParam(force_quantization_paramDescriptor.name, config_.force_quantization); rcl_interfaces::msg::ParameterDescriptor quantization_POSITION_paramDescriptor; quantization_POSITION_paramDescriptor.name = "quantization_POSITION"; @@ -143,8 +148,9 @@ void DracoPublisher::declareParameters(const std::string & base_topic) .set__to_value(31) .set__step(1)}); declareParam( - quantization_POSITION_paramDescriptor.name, config_.quantization_NORMAL, + quantization_POSITION_paramDescriptor.name, config_.quantization_POSITION, quantization_POSITION_paramDescriptor); + getParam(quantization_POSITION_paramDescriptor.name, config_.quantization_POSITION); rcl_interfaces::msg::ParameterDescriptor quantization_NORMAL_paramDescriptor; quantization_NORMAL_paramDescriptor.name = "quantization_NORMAL"; @@ -157,8 +163,9 @@ void DracoPublisher::declareParameters(const std::string & base_topic) .set__to_value(31) .set__step(1)}); declareParam( - quantization_NORMAL_paramDescriptor.name, config_.quantization_COLOR, + quantization_NORMAL_paramDescriptor.name, config_.quantization_NORMAL, quantization_NORMAL_paramDescriptor); + getParam(quantization_NORMAL_paramDescriptor.name, config_.quantization_NORMAL); rcl_interfaces::msg::ParameterDescriptor quantization_COLOR_paramDescriptor; quantization_COLOR_paramDescriptor.name = "quantization_COLOR"; @@ -171,8 +178,9 @@ void DracoPublisher::declareParameters(const std::string & base_topic) .set__to_value(31) .set__step(1)}); declareParam( - quantization_COLOR_paramDescriptor.name, config_.quantization_TEX_COORD, + quantization_COLOR_paramDescriptor.name, config_.quantization_COLOR, quantization_COLOR_paramDescriptor); + getParam(quantization_COLOR_paramDescriptor.name, config_.quantization_COLOR); rcl_interfaces::msg::ParameterDescriptor quantization_TEX_COORD_paramDescriptor; quantization_TEX_COORD_paramDescriptor.name = "quantization_TEX_COORD"; @@ -186,8 +194,9 @@ void DracoPublisher::declareParameters(const std::string & base_topic) .set__to_value(31) .set__step(1)}); declareParam( - quantization_TEX_COORD_paramDescriptor.name, config_.quantization_GENERIC, + quantization_TEX_COORD_paramDescriptor.name, config_.quantization_TEX_COORD, quantization_TEX_COORD_paramDescriptor); + getParam(quantization_TEX_COORD_paramDescriptor.name, config_.quantization_TEX_COORD); rcl_interfaces::msg::ParameterDescriptor quantization_GENERIC_paramDescriptor; quantization_GENERIC_paramDescriptor.name = "quantization_GENERIC"; @@ -201,8 +210,9 @@ void DracoPublisher::declareParameters(const std::string & base_topic) .set__to_value(31) .set__step(1)}); declareParam( - quantization_GENERIC_paramDescriptor.name, config_.quantization_POSITION, + quantization_GENERIC_paramDescriptor.name, config_.quantization_GENERIC, quantization_GENERIC_paramDescriptor); + getParam(quantization_GENERIC_paramDescriptor.name, config_.quantization_GENERIC); rcl_interfaces::msg::ParameterDescriptor expert_quantization_paramDescriptor; expert_quantization_paramDescriptor.name = "expert_quantization"; @@ -214,6 +224,7 @@ void DracoPublisher::declareParameters(const std::string & base_topic) declareParam( expert_quantization_paramDescriptor.name, config_.expert_quantization, expert_quantization_paramDescriptor); + getParam(expert_quantization_paramDescriptor.name, config_.expert_quantization); rcl_interfaces::msg::ParameterDescriptor expert_attribute_types_paramDescriptor; expert_attribute_types_paramDescriptor.name = "expert_attribute_types"; @@ -225,7 +236,9 @@ void DracoPublisher::declareParameters(const std::string & base_topic) declareParam( expert_attribute_types_paramDescriptor.name, config_.expert_attribute_types, expert_attribute_types_paramDescriptor); + getParam(expert_attribute_types_paramDescriptor.name, config_.expert_attribute_types); + // we call get param at runtime to get the latest value for these declareParam("attribute_mapping.attribute_type.x", "POSITION"); declareParam("attribute_mapping.attribute_type.y", "POSITION"); declareParam("attribute_mapping.attribute_type.z", "POSITION"); diff --git a/draco_point_cloud_transport/src/draco_subscriber.cpp b/draco_point_cloud_transport/src/draco_subscriber.cpp index 0020870..b143ed5 100644 --- a/draco_point_cloud_transport/src/draco_subscriber.cpp +++ b/draco_point_cloud_transport/src/draco_subscriber.cpp @@ -48,10 +48,15 @@ namespace draco_point_cloud_transport void DracoSubscriber::declareParameters() { declareParam(std::string("SkipDequantizationPOSITION"), false); + getParam(std::string("SkipDequantizationPOSITION"), config_.SkipDequantizationPOSITION); declareParam(std::string("SkipDequantizationNORMAL"), false); + getParam(std::string("SkipDequantizationNORMAL"), config_.SkipDequantizationNORMAL); declareParam(std::string("SkipDequantizationCOLOR"), false); + getParam(std::string("SkipDequantizationCOLOR"), config_.SkipDequantizationCOLOR); declareParam(std::string("SkipDequantizationTEX_COORD"), false); + getParam(std::string("SkipDequantizationTEX_COORD"), config_.SkipDequantizationTEX_COORD); declareParam(std::string("SkipDequantizationGENERIC"), false); + getParam(std::string("SkipDequantizationGENERIC"), config_.SkipDequantizationGENERIC); auto param_change_callback = [this](std::vector parameters) -> rcl_interfaces::msg::SetParametersResult diff --git a/zlib_point_cloud_transport/src/zlib_publisher.cpp b/zlib_point_cloud_transport/src/zlib_publisher.cpp index 81ec13d..5334bb4 100644 --- a/zlib_point_cloud_transport/src/zlib_publisher.cpp +++ b/zlib_point_cloud_transport/src/zlib_publisher.cpp @@ -54,6 +54,7 @@ void ZlibPublisher::declareParameters(const std::string & base_topic) declareParam( encode_level_paramDescriptor.name, this->encode_level_, encode_level_paramDescriptor); + getParam(encode_level_paramDescriptor.name, this->encode_level_); auto param_change_callback = [this](const std::vector & parameters) -> rcl_interfaces::msg:: diff --git a/zstd_point_cloud_transport/src/zstd_publisher.cpp b/zstd_point_cloud_transport/src/zstd_publisher.cpp index 958a05a..93b4234 100644 --- a/zstd_point_cloud_transport/src/zstd_publisher.cpp +++ b/zstd_point_cloud_transport/src/zstd_publisher.cpp @@ -58,6 +58,7 @@ void ZstdPublisher::declareParameters(const std::string & base_topic) declareParam( encode_level_paramDescriptor.name, this->encode_level_, encode_level_paramDescriptor); + getParam(encode_level_paramDescriptor.name, this->encode_level_); auto param_change_callback = [this](const std::vector & parameters) -> rcl_interfaces::msg::