From d0527cbc8f96e06a61809cb573330332a91d7902 Mon Sep 17 00:00:00 2001 From: brian Date: Fri, 19 Jul 2024 17:15:29 -0700 Subject: [PATCH] approach using node options. This requires params_file parameter to be specified in the controller yaml, even if the same file --- .../src/ign_ros2_control_plugin.cpp | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/ign_ros2_control/src/ign_ros2_control_plugin.cpp b/ign_ros2_control/src/ign_ros2_control_plugin.cpp index 7d0e2c02..79fa755e 100644 --- a/ign_ros2_control/src/ign_ros2_control_plugin.cpp +++ b/ign_ros2_control/src/ign_ros2_control_plugin.cpp @@ -345,13 +345,13 @@ void IgnitionROS2ControlPlugin::Configure( } std::vector argv; - for (const auto & arg : arguments) { - RCLCPP_INFO( - logger, - arg.data() - ); - argv.push_back(reinterpret_cast(arg.data())); - } + // for (const auto & arg : arguments) { + // RCLCPP_INFO( + // logger, + // arg.data() + // ); + // argv.push_back(reinterpret_cast(arg.data())); + // } // Create a default context, if not already if (!rclcpp::ok()) { @@ -365,8 +365,10 @@ void IgnitionROS2ControlPlugin::Configure( msg.data() ); - this->dataPtr->context_ = std::make_shared(); - this->dataPtr->context_->init(static_cast(argv.size()), argv.data()); + // this->dataPtr->context_ = std::make_shared(); + // this->dataPtr->context_->init(static_cast(argv.size()), argv.data()); + + this->dataPtr->context_ = rclcpp::contexts::get_global_default_context(); std::string node_name = "gz_ros2_control"; @@ -375,6 +377,7 @@ void IgnitionROS2ControlPlugin::Configure( rclcpp::NodeOptions node_options; node_options.context(this->dataPtr->context_); + node_options.arguments(arguments); this->dataPtr->node_ = rclcpp::Node::make_shared(node_name, ns, node_options); this->dataPtr->executor_ = std::make_shared(executor_options); @@ -479,6 +482,7 @@ void IgnitionROS2ControlPlugin::Configure( rclcpp::NodeOptions cm_node_options = controller_manager::get_cm_node_options(); cm_node_options.context(this->dataPtr->context_); + cm_node_options.arguments(arguments); // Create the controller manager RCLCPP_INFO(this->dataPtr->node_->get_logger(), "Loading controller_manager");