Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,15 @@ 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.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

single sentence per line.

Suggested change
``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.

Next, the node is executed using ``rclcpp::spin(std::make_shared<MinimalPublisher>());`` 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++

Expand Down
Loading