ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

ROS2 add_on_set_parameters_callback not trigger with open loop

asked 2022-07-17 08:47:48 -0500

updated 2022-07-17 08:48:25 -0500


On the galactic version, I use add_on_set_parameters_callback 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.

  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 
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2022-07-17 09:34:07 -0500

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.

edit flag offensive delete link more

Question Tools

1 follower


Asked: 2022-07-17 08:47:48 -0500

Seen: 269 times

Last updated: Jul 17 '22