-
Notifications
You must be signed in to change notification settings - Fork 85
Add tutorial for Cache filter for Python #185
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Noticed the formatting issues in python code snippets. I've copied this examples from VSCode to Formiko editor part by part. In the editor it looked Ok, but turns out, it is not. Will fix asap. |
ahcorde
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add also a link in tutorials.rst
doc/Tutorials/Cache-Python.rst
Outdated
| Overview | ||
| ~~~~~~~~ | ||
|
|
||
| This tutorial demonstrates how to use the ``message_filters.Cache`` class in ROS 2 using Python. The ``Cache`` filter stores a time history of messages and allows querying based on timestamps. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One sentence per line
| This tutorial demonstrates how to use the ``message_filters.Cache`` class in ROS 2 using Python. The ``Cache`` filter stores a time history of messages and allows querying based on timestamps. | |
| This tutorial demonstrates how to use the ``message_filters.Cache`` class in ROS 2 using Python. | |
| The ``Cache`` filter stores a time history of messages and allows querying based on timestamps. |
| 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 an Example Node with Includes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| 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 an Example 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 an Example Node with Includes |
doc/Tutorials/Cache-Python.rst
Outdated
|
|
||
| 1. Create an Example Node with Includes | ||
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
| Let's assume, you've already created an empty ros package for Python. The next step is to create a new Python file inside your package, e.g., ``cache_tutorial.py``, and create an example node: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| Let's assume, you've already created an empty ros package for Python. The next step is to create a new Python file inside your package, e.g., ``cache_tutorial.py``, and create an example node: | |
| Let's assume, you've already created an empty ros package for Python. | |
| The next step is to create a new Python file inside your package, e.g., ``cache_tutorial.py``, and create an example node: |
doc/Tutorials/Cache-Python.rst
Outdated
| qos = QoSProfile(depth=10) | ||
|
|
||
| # Publisher and Subscriber | ||
| self.publisher = self.create_publisher(String, 'input', qos_profile) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
identation looks wrong
doc/Tutorials/Cache-Python.rst
Outdated
|
|
||
| .. code-block:: python | ||
|
|
||
| self.subscriber_filter = Subscriber( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
identation
doc/Tutorials/Cache-Python.rst
Outdated
| qos = QoSProfile(depth=10) | ||
|
|
||
| # Publisher and Subscriber | ||
| self.publisher = self.create_publisher(String, 'input', qos_profile) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
indentation
doc/Tutorials/Cache-Python.rst
Outdated
| .. code-block:: python | ||
|
|
||
| # Simulate publishing via timer | ||
| self.publisher_timer = self.create_timer( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
identation
doc/Tutorials/Cache-Python.rst
Outdated
|
|
||
| .. code-block:: python | ||
|
|
||
| def publisher_timer_callback(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
identation
328bd0b to
fcf4994
Compare
|
@ahcorde Thank you for providing a review so quickly! I've updated the code, fixed the indentations and added the other changes, you've recommended. It would be great if you could have another look at this PR at your convenience. |
doc/Tutorials/Cache-Python.rst
Outdated
| self.cahce_filter = Cache( | ||
| self.subscriber_filter, | ||
| cache_size=5, | ||
| allow_headerless=True, # To allow cahcing basic String message |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| allow_headerless=True, # To allow cahcing basic String message | |
| allow_headerless=True, # To allow caching basic String message |
doc/Tutorials/Cache-Python.rst
Outdated
| self.cahce_filter = Cache( | ||
| self.subscriber_filter, | ||
| cache_size=5, | ||
| allow_headerless=True, # To allow cahcing basic String message |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| allow_headerless=True, # To allow cahcing basic String message | |
| allow_headerless=True, # To allow caching basic String message |
doc/Tutorials/Cache-Python.rst
Outdated
| "/example/topic", | ||
| qos_profile=qos_profile, | ||
| ) | ||
| self.cahce_filter = Cache( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| self.cahce_filter = Cache( | |
| self.cache = Cache( |
doc/Tutorials/Cache-Python.rst
Outdated
| .. code-block:: bash | ||
|
|
||
| colcon build && . install/setup.bash | ||
|
|
||
| Or, if you're using ZSH: | ||
|
|
||
| .. code-block:: bash | ||
|
|
||
| colcon build && . install/setup.zsh |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| .. code-block:: bash | |
| colcon build && . install/setup.bash | |
| Or, if you're using ZSH: | |
| .. code-block:: bash | |
| colcon build && . install/setup.zsh | |
| .. tabs:: | |
| .. group-tab:: Linux | |
| .. code-block:: console | |
| $ colcon build && . install/setup.bash | |
| .. group-tab:: macOS | |
| .. code-block:: console | |
| $ colcon build && . install/setup.bash | |
| .. group-tab:: Windows | |
| .. code-block:: console | |
| $ colcon build | |
| $ call C:\dev\ros2\local_setup.bat |
|
@ahcorde Thanks again for updates! I've fixed the typos and changed the naming as you've suggested, and updated the |
doc/Tutorials/Cache-Python.rst
Outdated
|
|
||
| From the root of your workspace: | ||
|
|
||
| .. tab: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| .. tab: | |
| .. tabs: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I've noticed this right after pushing. Already fixed. :)
Signed-off-by: EsipovPA <esipov.p@mail.ru>
Signed-off-by: Alejandro Hernández Cordero <ahcorde@gmail.com>
|
Thank you / Спасибо @EsipovPA |
|
https://github.com/Mergifyio backport kilted jazzy humble |
✅ Backports have been created
|
Signed-off-by: EsipovPA <esipov.p@mail.ru> Signed-off-by: Alejandro Hernández Cordero <ahcorde@gmail.com> Co-authored-by: Alejandro Hernández Cordero <ahcorde@gmail.com> (cherry picked from commit 001129d)
Signed-off-by: EsipovPA <esipov.p@mail.ru> Signed-off-by: Alejandro Hernández Cordero <ahcorde@gmail.com> Co-authored-by: Alejandro Hernández Cordero <ahcorde@gmail.com> (cherry picked from commit 001129d)
Signed-off-by: EsipovPA <esipov.p@mail.ru> Signed-off-by: Alejandro Hernández Cordero <ahcorde@gmail.com> Co-authored-by: Alejandro Hernández Cordero <ahcorde@gmail.com> (cherry picked from commit 001129d)
(cherry picked from commit 001129d) Signed-off-by: EsipovPA <esipov.p@mail.ru> Signed-off-by: Alejandro Hernández Cordero <ahcorde@gmail.com> Co-authored-by: Pavel Esipov <38457822+EsipovPA@users.noreply.github.com> Co-authored-by: Alejandro Hernández Cordero <ahcorde@gmail.com>
(cherry picked from commit 001129d) Signed-off-by: EsipovPA <esipov.p@mail.ru> Signed-off-by: Alejandro Hernández Cordero <ahcorde@gmail.com> Co-authored-by: Pavel Esipov <38457822+EsipovPA@users.noreply.github.com> Co-authored-by: Alejandro Hernández Cordero <ahcorde@gmail.com>
(cherry picked from commit 001129d) Signed-off-by: EsipovPA <esipov.p@mail.ru> Signed-off-by: Alejandro Hernández Cordero <ahcorde@gmail.com> Co-authored-by: Pavel Esipov <38457822+EsipovPA@users.noreply.github.com> Co-authored-by: Alejandro Hernández Cordero <ahcorde@gmail.com>
Description
Added a tutorial for Cache message filter class for Python programming launguage.
Partially fixes #130
Did you use Generative AI?
Additional Information