Composition and Parameters: Best Practice Suggestions

This is the only place I know that is using the node interface, but there might be others. turtlebot2_demo/turtlebot2_drivers/src/kobuki_node.cpp at master · ros2/turtlebot2_demo · GitHub

As for register_param_change_callback, I can see how the comments could be confusing. To clarify, the function is supposed to act atomically in sense that any changes to state in your code are only expected to occur if all the parameters are valid. In other words if changing the parameters modifies internal variables, it is expected to change nothing if it fails.

This restriction/expectation is there because otherwise the atomic parameter API could guarantee nothing.

Another note, it is expect that you set the result manually in the callback, by doing result.successful = true after you verify that the parameters are valid for your node.

The parameter callback is actually called by set_parameters_atomically. By calling set_parameters_atomically inside your callback you are actually creating a cycle, creating the memory errors you are seeing (probably some kind of stackoverflow).

Hope that helps.

1 Like