From 9933e6869d4555f088b48c50a182a1170eb9fc98 Mon Sep 17 00:00:00 2001 From: Arashdeep Singh <147547278+ArashdeepSinghMaan@users.noreply.github.com> Date: Mon, 3 Nov 2025 21:52:35 +0530 Subject: [PATCH 1/8] Enhance documentation on ROS 2 main function Expanded explanation of the main function and ROS 2 initialization process. Signed-off-by: Arashdeep Singh <147547278+ArashdeepSinghMaan@users.noreply.github.com> --- .../Writing-A-Simple-Cpp-Publisher-And-Subscriber.rst | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/source/Tutorials/Beginner-Client-Libraries/Writing-A-Simple-Cpp-Publisher-And-Subscriber.rst b/source/Tutorials/Beginner-Client-Libraries/Writing-A-Simple-Cpp-Publisher-And-Subscriber.rst index b8f0490325a..a588afdd6e8 100644 --- a/source/Tutorials/Beginner-Client-Libraries/Writing-A-Simple-Cpp-Publisher-And-Subscriber.rst +++ b/source/Tutorials/Beginner-Client-Libraries/Writing-A-Simple-Cpp-Publisher-And-Subscriber.rst @@ -199,7 +199,12 @@ In the bottom of the class is the declaration of the timer, publisher, and count size_t count_; Following the ``MinimalPublisher`` class is ``main``, where the node actually executes. -``rclcpp::init`` initializes ROS 2, and ``rclcpp::spin`` starts processing data from the node, including callbacks from the timer. +``rclcpp::init`` initializes ROS 2, and ``rclcpp::spin`` starts processing data from the node, including callbacks from the timer. The ``main()`` function begins by calling ``rclcpp::init(argc, argv);`` which initializes the ROS 2 client library. This step prepares the system to handle communication and parses any command-line arguments for remapping, parameters, or logging configuration. It is important to call this function before creating any nodes. + +Next, the node is executed using ``rclcpp::spin(std::make_shared());`` which creates a shared instance of the node and enters an event loop that keeps it active. The ``spin()`` function processes all incoming callbacks, including those from timers, subscriptions, and services, and continues running until the node is explicitly shut down (for example, when ``Ctrl+C`` is pressed). + +Finally, ``rclcpp::shutdown();`` is called to stop all ROS 2 activity, clean up allocated resources, and ensure that the program exits gracefully. + .. code-block:: C++ From 932594a497870209474e2c4c6bf3064420aec621 Mon Sep 17 00:00:00 2001 From: Arashdeep Singh <147547278+ArashdeepSinghMaan@users.noreply.github.com> Date: Tue, 4 Nov 2025 19:09:39 +0530 Subject: [PATCH 2/8] Update source/Tutorials/Beginner-Client-Libraries/Writing-A-Simple-Cpp-Publisher-And-Subscriber.rst MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Alejandro Hernández Cordero Signed-off-by: Arashdeep Singh <147547278+ArashdeepSinghMaan@users.noreply.github.com> --- .../Writing-A-Simple-Cpp-Publisher-And-Subscriber.rst | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/source/Tutorials/Beginner-Client-Libraries/Writing-A-Simple-Cpp-Publisher-And-Subscriber.rst b/source/Tutorials/Beginner-Client-Libraries/Writing-A-Simple-Cpp-Publisher-And-Subscriber.rst index a588afdd6e8..c32395a668e 100644 --- a/source/Tutorials/Beginner-Client-Libraries/Writing-A-Simple-Cpp-Publisher-And-Subscriber.rst +++ b/source/Tutorials/Beginner-Client-Libraries/Writing-A-Simple-Cpp-Publisher-And-Subscriber.rst @@ -199,9 +199,12 @@ In the bottom of the class is the declaration of the timer, publisher, and count size_t count_; Following the ``MinimalPublisher`` class is ``main``, where the node actually executes. -``rclcpp::init`` initializes ROS 2, and ``rclcpp::spin`` starts processing data from the node, including callbacks from the timer. The ``main()`` function begins by calling ``rclcpp::init(argc, argv);`` which initializes the ROS 2 client library. This step prepares the system to handle communication and parses any command-line arguments for remapping, parameters, or logging configuration. It is important to call this function before creating any nodes. +``rclcpp::init`` initializes ROS 2, and ``rclcpp::spin`` starts processing data from the node, including callbacks from the timer. The ``main()`` function begins by calling ``rclcpp::init(argc, argv);`` which initializes the ROS 2 client library. +This step prepares the system to handle communication and parses any command-line arguments for remapping, parameters, or logging configuration. +It is important to call this function before creating any nodes. -Next, the node is executed using ``rclcpp::spin(std::make_shared());`` which creates a shared instance of the node and enters an event loop that keeps it active. The ``spin()`` function processes all incoming callbacks, including those from timers, subscriptions, and services, and continues running until the node is explicitly shut down (for example, when ``Ctrl+C`` is pressed). +Next, the node is executed using ``rclcpp::spin(std::make_shared());`` which creates a shared instance of the node and enters an event loop that keeps it active. +The ``spin()`` function processes all incoming callbacks, including those from timers, subscriptions, and services, and continues running until the node is explicitly shut down (for example, when ``Ctrl+C`` is pressed). Finally, ``rclcpp::shutdown();`` is called to stop all ROS 2 activity, clean up allocated resources, and ensure that the program exits gracefully. From 086326c0dce78db4f2e34cb1f5e6057dbd9c2586 Mon Sep 17 00:00:00 2001 From: Katherine Scott Date: Mon, 8 Dec 2025 11:38:43 -0800 Subject: [PATCH 3/8] Update source/Tutorials/Beginner-Client-Libraries/Writing-A-Simple-Cpp-Publisher-And-Subscriber.rst Signed-off-by: Katherine Scott --- .../Writing-A-Simple-Cpp-Publisher-And-Subscriber.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/Tutorials/Beginner-Client-Libraries/Writing-A-Simple-Cpp-Publisher-And-Subscriber.rst b/source/Tutorials/Beginner-Client-Libraries/Writing-A-Simple-Cpp-Publisher-And-Subscriber.rst index c32395a668e..d203ae6ec61 100644 --- a/source/Tutorials/Beginner-Client-Libraries/Writing-A-Simple-Cpp-Publisher-And-Subscriber.rst +++ b/source/Tutorials/Beginner-Client-Libraries/Writing-A-Simple-Cpp-Publisher-And-Subscriber.rst @@ -199,7 +199,7 @@ In the bottom of the class is the declaration of the timer, publisher, and count size_t count_; Following the ``MinimalPublisher`` class is ``main``, where the node actually executes. -``rclcpp::init`` initializes ROS 2, and ``rclcpp::spin`` starts processing data from the node, including callbacks from the timer. The ``main()`` function begins by calling ``rclcpp::init(argc, argv);`` which initializes the ROS 2 client library. +``rclcpp::init`` initializes ROS 2, and ``rclcpp::spin`` starts processing data from the node, including callbacks from the timer. The ``main()`` function begins by calling ``rclcpp::init(argc, argv);`` which initializes the ROS 2 client library. This step prepares the system to handle communication and parses any command-line arguments for remapping, parameters, or logging configuration. It is important to call this function before creating any nodes. From 92c3805fb61553ee8e2952b0baf75d8c8d364be5 Mon Sep 17 00:00:00 2001 From: Katherine Scott Date: Mon, 8 Dec 2025 11:38:50 -0800 Subject: [PATCH 4/8] Update source/Tutorials/Beginner-Client-Libraries/Writing-A-Simple-Cpp-Publisher-And-Subscriber.rst Signed-off-by: Katherine Scott --- .../Writing-A-Simple-Cpp-Publisher-And-Subscriber.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/Tutorials/Beginner-Client-Libraries/Writing-A-Simple-Cpp-Publisher-And-Subscriber.rst b/source/Tutorials/Beginner-Client-Libraries/Writing-A-Simple-Cpp-Publisher-And-Subscriber.rst index d203ae6ec61..8da56bd0da9 100644 --- a/source/Tutorials/Beginner-Client-Libraries/Writing-A-Simple-Cpp-Publisher-And-Subscriber.rst +++ b/source/Tutorials/Beginner-Client-Libraries/Writing-A-Simple-Cpp-Publisher-And-Subscriber.rst @@ -200,7 +200,7 @@ In the bottom of the class is the declaration of the timer, publisher, and count Following the ``MinimalPublisher`` class is ``main``, where the node actually executes. ``rclcpp::init`` initializes ROS 2, and ``rclcpp::spin`` starts processing data from the node, including callbacks from the timer. The ``main()`` function begins by calling ``rclcpp::init(argc, argv);`` which initializes the ROS 2 client library. -This step prepares the system to handle communication and parses any command-line arguments for remapping, parameters, or logging configuration. +This step prepares the system to handle communication and parses any command-line arguments for remapping, parameters, or logging configuration. It is important to call this function before creating any nodes. Next, the node is executed using ``rclcpp::spin(std::make_shared());`` which creates a shared instance of the node and enters an event loop that keeps it active. From 72c58341306f60b2023dd231aaa209f51b81ddbd Mon Sep 17 00:00:00 2001 From: Katherine Scott Date: Mon, 8 Dec 2025 11:39:44 -0800 Subject: [PATCH 5/8] Update source/Tutorials/Beginner-Client-Libraries/Writing-A-Simple-Cpp-Publisher-And-Subscriber.rst Signed-off-by: Katherine Scott --- .../Writing-A-Simple-Cpp-Publisher-And-Subscriber.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/Tutorials/Beginner-Client-Libraries/Writing-A-Simple-Cpp-Publisher-And-Subscriber.rst b/source/Tutorials/Beginner-Client-Libraries/Writing-A-Simple-Cpp-Publisher-And-Subscriber.rst index 8da56bd0da9..3ba95eab128 100644 --- a/source/Tutorials/Beginner-Client-Libraries/Writing-A-Simple-Cpp-Publisher-And-Subscriber.rst +++ b/source/Tutorials/Beginner-Client-Libraries/Writing-A-Simple-Cpp-Publisher-And-Subscriber.rst @@ -201,7 +201,7 @@ In the bottom of the class is the declaration of the timer, publisher, and count Following the ``MinimalPublisher`` class is ``main``, where the node actually executes. ``rclcpp::init`` initializes ROS 2, and ``rclcpp::spin`` starts processing data from the node, including callbacks from the timer. The ``main()`` function begins by calling ``rclcpp::init(argc, argv);`` which initializes the ROS 2 client library. This step prepares the system to handle communication and parses any command-line arguments for remapping, parameters, or logging configuration. -It is important to call this function before creating any nodes. +It is important to call this function before creating any nodes. Next, the node is executed using ``rclcpp::spin(std::make_shared());`` which creates a shared instance of the node and enters an event loop that keeps it active. The ``spin()`` function processes all incoming callbacks, including those from timers, subscriptions, and services, and continues running until the node is explicitly shut down (for example, when ``Ctrl+C`` is pressed). From 6ff71ba11214bdff169a399e862b031344149059 Mon Sep 17 00:00:00 2001 From: Katherine Scott Date: Mon, 8 Dec 2025 11:39:57 -0800 Subject: [PATCH 6/8] Update source/Tutorials/Beginner-Client-Libraries/Writing-A-Simple-Cpp-Publisher-And-Subscriber.rst Signed-off-by: Katherine Scott --- .../Writing-A-Simple-Cpp-Publisher-And-Subscriber.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/Tutorials/Beginner-Client-Libraries/Writing-A-Simple-Cpp-Publisher-And-Subscriber.rst b/source/Tutorials/Beginner-Client-Libraries/Writing-A-Simple-Cpp-Publisher-And-Subscriber.rst index 3ba95eab128..a3fdea769db 100644 --- a/source/Tutorials/Beginner-Client-Libraries/Writing-A-Simple-Cpp-Publisher-And-Subscriber.rst +++ b/source/Tutorials/Beginner-Client-Libraries/Writing-A-Simple-Cpp-Publisher-And-Subscriber.rst @@ -203,7 +203,7 @@ Following the ``MinimalPublisher`` class is ``main``, where the node actually ex This step prepares the system to handle communication and parses any command-line arguments for remapping, parameters, or logging configuration. It is important to call this function before creating any nodes. -Next, the node is executed using ``rclcpp::spin(std::make_shared());`` which creates a shared instance of the node and enters an event loop that keeps it active. +Next, the node is executed using ``rclcpp::spin(std::make_shared());`` which creates a shared instance of the node and enters an event loop that keeps it active. The ``spin()`` function processes all incoming callbacks, including those from timers, subscriptions, and services, and continues running until the node is explicitly shut down (for example, when ``Ctrl+C`` is pressed). Finally, ``rclcpp::shutdown();`` is called to stop all ROS 2 activity, clean up allocated resources, and ensure that the program exits gracefully. From 60445fe05cfb3bf5df1d256e04689f541f0c5230 Mon Sep 17 00:00:00 2001 From: Katherine Scott Date: Mon, 8 Dec 2025 11:40:05 -0800 Subject: [PATCH 7/8] Update source/Tutorials/Beginner-Client-Libraries/Writing-A-Simple-Cpp-Publisher-And-Subscriber.rst Signed-off-by: Katherine Scott --- .../Writing-A-Simple-Cpp-Publisher-And-Subscriber.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/Tutorials/Beginner-Client-Libraries/Writing-A-Simple-Cpp-Publisher-And-Subscriber.rst b/source/Tutorials/Beginner-Client-Libraries/Writing-A-Simple-Cpp-Publisher-And-Subscriber.rst index a3fdea769db..e0ff0633aa7 100644 --- a/source/Tutorials/Beginner-Client-Libraries/Writing-A-Simple-Cpp-Publisher-And-Subscriber.rst +++ b/source/Tutorials/Beginner-Client-Libraries/Writing-A-Simple-Cpp-Publisher-And-Subscriber.rst @@ -204,7 +204,7 @@ This step prepares the system to handle communication and parses any command-lin It is important to call this function before creating any nodes. Next, the node is executed using ``rclcpp::spin(std::make_shared());`` which creates a shared instance of the node and enters an event loop that keeps it active. -The ``spin()`` function processes all incoming callbacks, including those from timers, subscriptions, and services, and continues running until the node is explicitly shut down (for example, when ``Ctrl+C`` is pressed). +The ``spin()`` function processes all incoming callbacks, including those from timers, subscriptions, and services, and continues running until the node is explicitly shut down (for example, when ``Ctrl+C`` is pressed). Finally, ``rclcpp::shutdown();`` is called to stop all ROS 2 activity, clean up allocated resources, and ensure that the program exits gracefully. From 6dfc530310db73e1cd56c9ffab5ecd0f0b5a109d Mon Sep 17 00:00:00 2001 From: Katherine Scott Date: Mon, 8 Dec 2025 11:44:11 -0800 Subject: [PATCH 8/8] Update source/Tutorials/Beginner-Client-Libraries/Writing-A-Simple-Cpp-Publisher-And-Subscriber.rst Signed-off-by: Katherine Scott --- .../Writing-A-Simple-Cpp-Publisher-And-Subscriber.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/source/Tutorials/Beginner-Client-Libraries/Writing-A-Simple-Cpp-Publisher-And-Subscriber.rst b/source/Tutorials/Beginner-Client-Libraries/Writing-A-Simple-Cpp-Publisher-And-Subscriber.rst index e0ff0633aa7..ada7c9bc9aa 100644 --- a/source/Tutorials/Beginner-Client-Libraries/Writing-A-Simple-Cpp-Publisher-And-Subscriber.rst +++ b/source/Tutorials/Beginner-Client-Libraries/Writing-A-Simple-Cpp-Publisher-And-Subscriber.rst @@ -199,7 +199,8 @@ In the bottom of the class is the declaration of the timer, publisher, and count size_t count_; Following the ``MinimalPublisher`` class is ``main``, where the node actually executes. -``rclcpp::init`` initializes ROS 2, and ``rclcpp::spin`` starts processing data from the node, including callbacks from the timer. The ``main()`` function begins by calling ``rclcpp::init(argc, argv);`` which initializes the ROS 2 client library. +``rclcpp::init`` initializes ROS 2, and ``rclcpp::spin`` starts processing data from the node, including callbacks from the timer. +The ``main()`` function begins by calling ``rclcpp::init(argc, argv);`` which initializes the ROS 2 client library. This step prepares the system to handle communication and parses any command-line arguments for remapping, parameters, or logging configuration. It is important to call this function before creating any nodes.