Skip to content

Commit

Permalink
rate docstring
Browse files Browse the repository at this point in the history
Signed-off-by: elian-WSL22H <elian.neppel@posteo.eu>
  • Loading branch information
2lian committed May 18, 2024
1 parent a0b5f48 commit f0bf624
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions rclpy/rclpy/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -1798,6 +1798,8 @@ def create_rate(
"""
Create a Rate object.
.. warning:: Users should call :meth:`.Node.destroy_rate` to destroy the Rate object.
:param frequency: The frequency the Rate runs at (Hz).
:param clock: The clock the Rate gets time from.
"""
Expand Down
8 changes: 8 additions & 0 deletions rclpy/rclpy/timer.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,10 @@ class Rate:
"""A utility for sleeping at a fixed rate."""

def __init__(self, timer: Timer, *, context):
"""
.. warning:: Users should not create a rate with this constructor, instead they
should call :meth:`.Node.create_rate`.
"""
# Rate is a wrapper around a timer
self._timer = timer
self._is_shutdown = False
Expand All @@ -147,6 +151,10 @@ def _on_shutdown(self):
self.destroy()

def destroy(self):
"""
.. warning:: Users should not destroy a rate with this method, instead they should
call :meth:`.Node.destroy_rate`.
"""
self._is_destroyed = True
self._event.set()

Expand Down

0 comments on commit f0bf624

Please sign in to comment.