ros2 / ros2/examples

Add minimal_timer example for rclpy to demonstrate periodic execution using create_timer()

Open
#436 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C++
Stars
970
Forks
365
Avg merge
12d 20h
Merged PRs (30d)
1

Description

Description

The rclcpp examples repository contains minimal timer demonstrations (e.g., examples_rclcpp_minimal_timer), which help beginners understand how to execute periodic callbacks using ROS 2 timers.

However, the rclpy examples currently include:

  • minimal_publisher
  • minimal_subscriber
  • pointcloud_publisher

but there is no minimal example demonstrating the use of create_timer() in Python.

Since timers are a fundamental mechanism in ROS 2 for running periodic tasks (such as sensor polling, monitoring loops, or periodic logging), a minimal Python example could help beginners understand this concept more easily.

Proposed Addition

Add a simple example under:

rclpy/topics/minimal_timer/

Possible structure:

rclpy/timer/minimal_timer/
 ├── minimal_timer.py
 └── README.md

The example could demonstrate:

  • Creating a ROS 2 node
  • Creating a timer using create_timer()
  • Executing a periodic callback
  • Logging output at fixed intervals

Motivation

This would:

  • Improve parity between rclcpp and rclpy examples
  • Help beginners understand periodic execution in ROS 2
  • Provide a simple reference implementation for timers in Python

If this addition is considered useful, I would be happy to implement the example and submit a PR.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Compare the existing rclcpp minimal timer demonstrations and the current rclpy examples, especially minimal_publisher and minimal_subscriber. Then add the proposed rclpy/timer/minimal_timer example with minimal_timer.py and README.md, covering node creation, create_timer(), a periodic callback, and fixed-interval logging. Done means the example is runnable and provides the requested beginner reference.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
robotics
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.