I'm playing around with the manual_composition example code and I want to insert a parameter service for the nodes.
I wasn't sure what the intended implementation path is for that.
I implemented it this way:
// Add some nodes to the executor which provide work for the executor during its "spin" function.
// An example of available work is executing a subscription callback, or a timer callback.
auto talker = std::make_shared<composition::Talker>();
auto tparameter_service = std::make_shared<rclcpp::parameter_service::ParameterService>(talker);
auto tparameter_client = std::make_shared<rclcpp::parameter_client::SyncParametersClient>(talker);
exec.add_node(talker);
auto listener = std::make_shared<composition::Listener>();
auto lparameter_service = std::make_shared<rclcpp::parameter_service::ParameterService>(listener);
auto lparameter_client = std::make_shared<rclcpp::parameter_client::AsyncParametersClient>(listener);
exec.add_node(listener);
// spin will block until work comes in, execute work as it becomes available, and keep blocking.
// It will only be interrupted by Ctrl-C.
exec.spin();
By adding the two service/client objects for each node, I am successfully able to send and get params for each individual node using the ros2param tool.
However, I run into issues if I try to connect an **on_parameter_event()** callback.
auto parameter_event_sub = tparameter_client->on_parameter_event(std::bind(&composition::Talker::event_callback, talker, std::placeholders::_1));
-
void Talker::event_callback(const rcl_interfaces::msg::ParameterEvent::SharedPtr event)
{
std::cout << "Parameter event:" << std::endl << " new parameters:" << std::endl;
for (auto & new_parameter : event->new_parameters) {
std::cout << " " << new_parameter.name << std::endl;
}
std::cout << " changed parameters:" << std::endl;
for (auto & changed_parameter : event->changed_parameters) {
std::cout << " " << changed_parameter.name << std::endl;
}
std::cout << " deleted parameters:" << std::endl;
for (auto & deleted_parameter : event->deleted_parameters) {
std::cout << " " << deleted_parameter.name << std::endl;
}
}
I added one to the talker client **tparameter_client**, but when I set variables to the listener, it still triggers the on_parameter_event. Interestingly, it doesn't add the parameter to the talker, but it does fire its on_parameter_event callback.
So, I'm not sure if that's a bug, or if I'm using the API incorrectly.
I've seen some comments where the parameter service/client stuff may be launched automatically inside the node in the future. So should I be putting it in the Talker class constructer instead? Will that be the intended usage of the parameter service, especially when working with components and composition?
Or have I discovered a bug and should add it to the GitHub Issues?
Thanks.
---
[Visit Topic](
https://discourse.ros.org/t/composition-and-parameters-best-practice-suggestions/1001/1) or reply to this email to respond.
If you do not want to receive messages from ros-users please use the unsubscribe link below. If you use the one above, you will stop all of ros-users from receiving updates.
______________________________________________________________________________
ros-users mailing list
ros-users@lists.ros.org
http://lists.ros.org/mailman/listinfo/ros-users
Unsubscribe: <
http://lists.ros.org/mailman//options/ros-users>