Quantcast
Channel: ROS Answers: Open Source Q&A Forum - RSS feed
Viewing all articles
Browse latest Browse all 92

Access parameters set from another node

$
0
0
Hi, I'm using ROS2 Bouncy. I have two nodes. What I would like to do is to allow the first node to set some parameters on the parameters server and then make the second node to retrieve these parameters. The problem is that I'm able to see the parameters only from the node that has set them. NODE 1 rclcpp::init(argc, argv); rclcpp::Node::SharedPtr node = rclcpp::Node::make_shared("node_1"); rclcpp::SyncParametersClient::SharedPtr parameters_client = std::make_shared(node); while (!parameters_client->wait_for_service(1s)){ if (!rclcpp::ok()) { RCLCPP_ERROR(node->get_logger(), "Interrupted while waiting for the service. Exiting."); return 0;} RCLCPP_INFO(node->get_logger(), "service not available, waiting again..."); } std::vector set_parameters_results = parameters_client->set_parameters({rclcpp::Parameter("wheels.radius", 1)}); rclcpp::spin(node); rclcpp::shutdown(); NODE 2 rclcpp::init(argc, argv); rclcpp::Node::SharedPtr node = rclcpp::Node::make_shared("node_2"); rclcpp::SyncParametersClient::SharedPtr parameters_client = std::make_shared(node); while (!parameters_client->wait_for_service(1s)){ if (!rclcpp::ok()) { RCLCPP_ERROR(node->get_logger(), "Interrupted while waiting for the service. Exiting."); return 0;} RCLCPP_INFO(node->get_logger(), "service not available, waiting again..."); } rclcpp::spin_some(node); auto parameters_and_prefixes = parameters_client->list_parameters({ }, 0); std::cout<<"READING PARAMS"<

Viewing all articles
Browse latest Browse all 92


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>