From fb3657bbcc467c871b0f6a3ef30575d25a5f087b Mon Sep 17 00:00:00 2001 From: Ivan Santiago Paunovic Date: Wed, 1 Jul 2020 13:16:56 -0300 Subject: [PATCH] Remove usage of domain id in node options (#1205) Signed-off-by: Ivan Santiago Paunovic --- rclcpp/include/rclcpp/node_options.hpp | 5 ---- rclcpp/src/rclcpp/node_options.cpp | 33 -------------------------- 2 files changed, 38 deletions(-) diff --git a/rclcpp/include/rclcpp/node_options.hpp b/rclcpp/include/rclcpp/node_options.hpp index 01b0158759..4be29968f7 100644 --- a/rclcpp/include/rclcpp/node_options.hpp +++ b/rclcpp/include/rclcpp/node_options.hpp @@ -327,11 +327,6 @@ class NodeOptions NodeOptions & allocator(rcl_allocator_t allocator); -protected: - /// Retrieve the ROS_DOMAIN_ID environment variable and populate options. - size_t - get_domain_id_from_env() const; - private: // This is mutable to allow for a const accessor which lazily creates the node options instance. /// Underlying rcl_node_options structure. diff --git a/rclcpp/src/rclcpp/node_options.cpp b/rclcpp/src/rclcpp/node_options.cpp index 3a2dcd7f5c..96afaa9481 100644 --- a/rclcpp/src/rclcpp/node_options.cpp +++ b/rclcpp/src/rclcpp/node_options.cpp @@ -92,7 +92,6 @@ NodeOptions::get_rcl_node_options() const *node_options_ = rcl_node_get_default_options(); node_options_->allocator = this->allocator_; node_options_->use_global_arguments = this->use_global_arguments_; - node_options_->domain_id = this->get_domain_id_from_env(); node_options_->enable_rosout = this->enable_rosout_; int c_argc = 0; @@ -322,36 +321,4 @@ NodeOptions::allocator(rcl_allocator_t allocator) return *this; } -// TODO(wjwwood): reuse rcutils_get_env() to avoid code duplication. -// See also: https://github.com/ros2/rcl/issues/119 -size_t -NodeOptions::get_domain_id_from_env() const -{ - // Determine the domain id based on the options and the ROS_DOMAIN_ID env variable. - size_t domain_id = std::numeric_limits::max(); - char * ros_domain_id = nullptr; - const char * env_var = "ROS_DOMAIN_ID"; -#ifndef _WIN32 - ros_domain_id = getenv(env_var); -#else - size_t ros_domain_id_size; - _dupenv_s(&ros_domain_id, &ros_domain_id_size, env_var); -#endif - if (ros_domain_id) { - uint32_t number = static_cast(strtoul(ros_domain_id, NULL, 0)); - if (number == (std::numeric_limits::max)()) { -#ifdef _WIN32 - // free the ros_domain_id before throwing, if getenv was used on Windows - free(ros_domain_id); -#endif - throw std::runtime_error("failed to interpret ROS_DOMAIN_ID as integral number"); - } - domain_id = static_cast(number); -#ifdef _WIN32 - free(ros_domain_id); -#endif - } - return domain_id; -} - } // namespace rclcpp