ROS2 add_on_set_parameters_callback not trigger with open loop
Hi,
On the galactic version, I use addonsetparameterscallback function to update my node parameters.
However, if I use open while loop, parameters callback function is not updating. If I don't add "while loop" in my code, callback function can trigger. Also I noticed, after while loop added than check the parameters
ros2 param list
while calling service of node '/NodeA': None
I think this issue because of the ros2 design. The same problem did not happen when I used timer instead of while loop. But should I use a timer instead of a loop? I don't think this should be the solution.
this->declare_parameter("parameter");
param_cb_ =
this->add_on_set_parameters_callback(std::bind(&NodeA::ParameterCallback, this, std::placeholders::_1));
// // try to read parameters from parameter server until it is successfully read
// If I add this loop
while (rclcpp::ok())
{
// continue loop
std::this_thread::sleep_for(std::chrono::milliseconds(1000));
}
Asked by bekirbostanci on 2022-07-17 08:47:48 UTC
Answers
The same issue was true for subscribers. All callback functions will not work because the line is started after the node is created. So that solution looks like timer.
https://answers.ros.org/question/352120/subscriber-callback-not-triggering-while-in-a-while-loop/ https://answers.ros.org/question/348863/ros2-calling-method-in-node-class/
Asked by bekirbostanci on 2022-07-17 09:34:07 UTC
Comments