Skip to content

Conversation

@EsipovPA
Copy link
Contributor

Description

Added a tutorial for Cache message filter class for C++ programming language.

fixes partially #130. Does not close the issue

Is this user-facing behavior change?

Did you use Generative AI?

Additional Information

@EsipovPA EsipovPA mentioned this pull request Jul 16, 2025
7 tasks
Copy link
Contributor

@ahcorde ahcorde left a comment

Choose a reason for hiding this comment

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

Thank you for working on the documentation


Prerequisites
~~~~~~~~~~~~~
This tutorial assumes you have a working knowledge of ROS 2
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
This tutorial assumes you have a working knowledge of ROS 2
This tutorial assumes you have a working knowledge of ROS 2.

Comment on lines 16 to 18
If you have not done so already `create a workspace <https://docs.ros.org/en/rolling/Tutorials/Beginner-Client-Libraries/Creating-A-Workspace/Creating-A-Workspace.html>`_ and `create a package <https://docs.ros.org/en/rolling/Tutorials/Beginner-Client-Libraries/Creating-Your-First-ROS2-Package.html>`_


1. Create a Basic Node with Includes
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
If you have not done so already `create a workspace <https://docs.ros.org/en/rolling/Tutorials/Beginner-Client-Libraries/Creating-A-Workspace/Creating-A-Workspace.html>`_ and `create a package <https://docs.ros.org/en/rolling/Tutorials/Beginner-Client-Libraries/Creating-Your-First-ROS2-Package.html>`_
1. Create a Basic Node with Includes
If you have not done so already `create a workspace <https://docs.ros.org/en/rolling/Tutorials/Beginner-Client-Libraries/Creating-A-Workspace/Creating-A-Workspace.html>`_ and `create a package <https://docs.ros.org/en/rolling/Tutorials/Beginner-Client-Libraries/Creating-Your-First-ROS2-Package.html>`_
1. Create a Basic Node with Includes

1. Create a Basic Node with Includes
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Let's assume, you've already created an empty ros package for C++.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
Let's assume, you've already created an empty ros package for C++.
Let's assume, you've already created an empty ROS package for C++.

Comment on lines 267 to 273
}


2. Update package.xml
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
}
2. Update package.xml
}
2. Update package.xml

Comment on lines 297 to 298
install(TARGETS cache_tutorial
DESTINATION lib/${PROJECT_NAME})
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
install(TARGETS cache_tutorial
DESTINATION lib/${PROJECT_NAME})
install(TARGETS cache_tutorial
DESTINATION lib/${PROJECT_NAME})


Now run the node using:

.. code-block:: bash
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
.. code-block:: bash
.. code-block:: console


The first message in the output is going to be

.. code-block:: bash
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
.. code-block:: bash
.. code-block:: console

As there were no messages published yet, and the cache is empty.
After that, the publisher will start populate the cache with messages:

.. code-block:: bash
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
.. code-block:: bash
.. code-block:: console

@EsipovPA EsipovPA force-pushed the add-cache-cpp-tutorial branch from 6d5669a to e4a1d0d Compare July 17, 2025 10:14
@EsipovPA
Copy link
Contributor Author

EsipovPA commented Jul 17, 2025

Thanks for the review @ahcorde!
I've fixed the places, you've commented on.
Could you please have another look at this PR?
Thank you! :)

@EsipovPA EsipovPA requested a review from ahcorde July 17, 2025 12:20
Comment on lines 1 to 2
Cache (C++):
---------------------------------------
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
Cache (C++):
---------------------------------------
Cache (C++):
------------

Copy link
Contributor

@CursedRock17 CursedRock17 left a comment

Choose a reason for hiding this comment

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

Tutorial looks great! That being said I left a couple nitpicking things to cover. Thanks!


Next we define a tutorial class.
In this case it is the ``CacheNode`` class.
For starters, let's take a look at a ``private`` section of this class:
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
For starters, let's take a look at a ``private`` section of this class:
For starters, let's take a look at the ``private`` section of this class:

}

private:
rclcpp::Publisher<std_msgs::msg::String>::SharedPtr publisher_;
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
rclcpp::Publisher<std_msgs::msg::String>::SharedPtr publisher_;
rclcpp::Publisher<std_msgs::msg::String>::SharedPtr publisher_;

class CacheNode : public rclcpp::Node {
public:
CacheNode()
: Node("cahce_node")
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
: Node("cahce_node")
: Node("cache_node")

Overview
~~~~~~~~

This tutorial demonstrates how to use the ``message_filters.Cache`` class in ROS 2 using C++.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
This tutorial demonstrates how to use the ``message_filters.Cache`` class in ROS 2 using C++.
This tutorial demonstrates how to use the ``message_filters::Cache`` class in ROS 2 using C++.

using namespace std::chrono_literals;

We start by including ``chrono`` and ``functional`` headers.
The ``chrono`` header is required for ``chrono_literals`` namespace, and the ``functional`` header is required to use ``std::bind`` function to bind timer callbacks to timers.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
The ``chrono`` header is required for ``chrono_literals`` namespace, and the ``functional`` header is required to use ``std::bind`` function to bind timer callbacks to timers.
The ``chrono`` header is required for the ``chrono_literals`` namespace, necessary for creating timers.
The ``functional`` header is also required to use ``std::bind`` function to bind timer callbacks to timers.

@EsipovPA EsipovPA force-pushed the add-cache-cpp-tutorial branch from e4a1d0d to 55b991d Compare July 18, 2025 21:13
@EsipovPA
Copy link
Contributor Author

Thank you for the review @CursedRock17! I've fixed the places in the code, you've pointed to. May I ask you to have another look at this PR, when it is possible?

@EsipovPA EsipovPA requested review from CursedRock17 and ahcorde July 18, 2025 21:15
EsipovPA added 2 commits July 19, 2025 00:16
Signed-off-by: EsipovPA <esipov.p@mail.ru>
Signed-off-by: EsipovPA <esipov.p@mail.ru>
@EsipovPA EsipovPA force-pushed the add-cache-cpp-tutorial branch from 55b991d to 7318016 Compare July 18, 2025 21:16
Copy link
Contributor

@CursedRock17 CursedRock17 left a comment

Choose a reason for hiding this comment

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

LGTM

@ahcorde
Copy link
Contributor

ahcorde commented Jul 21, 2025

This is documentation, merging!

@ahcorde ahcorde merged commit c7821ef into ros2:rolling Jul 21, 2025
2 checks passed
@ahcorde
Copy link
Contributor

ahcorde commented Jul 21, 2025

https://github.com/Mergifyio backport kilted jazzy humble

@mergify
Copy link

mergify bot commented Jul 21, 2025

backport kilted jazzy humble

✅ Backports have been created

mergify bot pushed a commit that referenced this pull request Jul 21, 2025
Signed-off-by: EsipovPA <esipov.p@mail.ru>
(cherry picked from commit c7821ef)
mergify bot pushed a commit that referenced this pull request Jul 21, 2025
Signed-off-by: EsipovPA <esipov.p@mail.ru>
(cherry picked from commit c7821ef)
mergify bot pushed a commit that referenced this pull request Jul 21, 2025
Signed-off-by: EsipovPA <esipov.p@mail.ru>
(cherry picked from commit c7821ef)
ahcorde pushed a commit that referenced this pull request Jul 21, 2025
(cherry picked from commit c7821ef)

Signed-off-by: EsipovPA <esipov.p@mail.ru>
Co-authored-by: Pavel Esipov <38457822+EsipovPA@users.noreply.github.com>
ahcorde pushed a commit that referenced this pull request Jul 21, 2025
(cherry picked from commit c7821ef)

Signed-off-by: EsipovPA <esipov.p@mail.ru>
Co-authored-by: Pavel Esipov <38457822+EsipovPA@users.noreply.github.com>
ahcorde pushed a commit that referenced this pull request Jul 21, 2025
(cherry picked from commit c7821ef)

Signed-off-by: EsipovPA <esipov.p@mail.ru>
Co-authored-by: Pavel Esipov <38457822+EsipovPA@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants