Repository navigation
Description
Hi all,
I am trying to add parameters to a node following the demo at https://github.com/ros2/demos/blob/master/demo_nodes_cpp/src/parameters/set_and_get_parameters.cpp
Problem is, the node is based on the Lyfecycle interface and I suspect rclcpp::SyncParametersClient does not accept them yet. I have seen that this problem appears in multiple other places as the NodeInterface is not yet fully integrated (see
ros-perception/image_common#108 for example)
For reference, the code I use is:
this->parameters_client_ = std::make_shared<rclcpp::SyncParametersClient>(this);
where this extends from rclcpp_lifecycle::LifecycleNode. I have also tried with std::make_shared<rclcpp::SyncParametersClient>(this->shared_from_this()); in vain. The error is listed as follow:
/opt/ros/eloquent/include/rclcpp/parameter_client.hpp:201:12: note: no known conversion for argument 1 from ‘std::shared_ptr<rclcpp_lifecycle::LifecycleNode>’ to ‘rclcpp::Node::SharedPtr {aka std::shared_ptr<rclcpp::Node>}’
which makes me suggest it is the same problem as ros-perception/image_common#108
Thanks in advance for your support.
EDIT
After looking closely at the constructors for rclcpp::SyncParametersClient it seems that the rclcpp::node_interfaces::NodeBaseInterface::SharedPtr is partially integrated, i.e. only when passing a rclcpp::executor::Executor::SharedPtr along with it. This means we should be able to initialize the parameters_client outside of the node class.
Could it be possible to extend the Constructor
rclcpp::SyncParametersClient::SyncParametersClient(rclcpp::Node::SharedPtr, const string&, const rmw_qos_profile_t&)
to accept a rclcpp::node_interfaces::NodeBaseInterface::SharedPtr and not only a rclcpp::Node::SharedPtr?
Activity
buschbapti commentedon Feb 20, 2020
Hello,
Any news on this issue? I am still unable to declare the parameter server in Lifecycle nodes and that is becoming problematic as this is an important feature. One workaround would be to declare a service for each parameters but it is bit tedious.
Thanks in advance.
fujitatomoya commentedon Feb 25, 2020
i guess that is related to #898, the problem is that we have separated classes rclcpp::Node and rclcpp_lifecycle::LifercycleNode. but i believe that rclcpp_lifecycle::LifercycleNode is built on top of rclcpp::Node. so rclcpp_lifecycle::LifecycleNode Class inherits based on rclcpp::Node and featured with lifecycle interfaces.
sparkskraps commentedon Feb 28, 2020
I noticed this problem and began to deal with it these days.
As @buschbapti metioned, we can extend the constructor SyncParametersClient(...) to accept not only rclcpp::Node. Just like the way this file handled. It is easy to implement.
If you want the rclcpp_lifecycle::LifecycleNode as parameter of constructor SyncParametersClient(...), just to be consistent with the original constructor that rclcpp::Node takes as an argument. Need to do more work.
Cause the file parameter_client.hpp/cpp is located in the rclcpp package, which was compiled before pacakge rclcpp_lifecycle.
Here are some thoughts.
Any thoughts on this ?