From 7ba746c8bd7678c4df29acdee432cdf7d458c025 Mon Sep 17 00:00:00 2001 From: Chris Lalancette Date: Mon, 17 Oct 2022 08:54:43 -0400 Subject: [PATCH] Monitor parameter changes: Add note to save callback handle Signed-off-by: Chris Lalancette --- .../Intermediate/Monitoring-For-Parameter-Changes-CPP.rst | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/source/Tutorials/Intermediate/Monitoring-For-Parameter-Changes-CPP.rst b/source/Tutorials/Intermediate/Monitoring-For-Parameter-Changes-CPP.rst index cfc2729ae8d..137c018fcb9 100644 --- a/source/Tutorials/Intermediate/Monitoring-For-Parameter-Changes-CPP.rst +++ b/source/Tutorials/Intermediate/Monitoring-For-Parameter-Changes-CPP.rst @@ -120,10 +120,14 @@ The first statement, ``#include `` is included so that the code can util The next, ``#include "rclcpp/rclcpp.hpp"`` is included to allow the code to reference the various functionality provided by the rclcpp interface, including the ParameterEventHandler class. After the class declaration, the code defines a class, ``SampleNodeWithParameters``. -The constructor for the class, declares an integer parameter ``an_int_param``, with a default value of 0. +The constructor for the class declares an integer parameter ``an_int_param``, with a default value of 0. Next, the code creates a ``ParameterEventHandler`` that will be used to monitor changes to parameters. Finally, the code creates a lambda function and sets it as the callback to invoke whenever ``an_int_param`` is updated. +.. note:: + + It is very important to save the handle that is returned by ``add_parameter_callback``; otherwise, the callback will not be properly registered. + .. code-block:: C++ SampleNodeWithParameters() @@ -150,7 +154,7 @@ Following the ``SampleNodeWithParameters`` is a typical ``main`` function which .. code-block:: C++ - int main(int argc, char** argv) + int main(int argc, char ** argv) { rclcpp::init(argc, argv); rclcpp::spin(std::make_shared());