`EventHandlerBase::get_number_of_ready_events()` does not compute number of ready events

Open
#2,716 1 comment 0 reactions 2 assignees View on GitHub

Maintainers usually reply within 1 day

@Yadunund is already working on this.

Since Jan 9, 2025.

Assessment

This issue has not been assessed yet.

Description

Feature request

Feature description

The current implementation of EventHandlerBase::get_number_of_ready_events() always returns 1. This function was originally introduced in https://github.com/ros2/rclcpp/pull/695 and is only used in rclcpp/test_qos_event.

However, having an accurate implementation of this function could benefit other tests like test_publisher:run_event_handlers which is calling take_data() without checking if the event is ready (ie, not calling is_ready()) or if get_number_of_ready_events > 0.

Implementation considerations

To correctly compute the number of ready events, we would likely need to

  • Add a method to rmw/event.h to retrieve the count of events for a given rmw_event_type_t.
  • Add a methods to rcl/event.h to retrieve number of ready events of publishers and subscriptions resp. given an rcl_event_t handle. This method will in turn invoke the newly introduced rmw method above.

Then the implementation for EventHandlerBase::get_number_of_ready_events() can be updated to invoke the appropriate rcl methods added above.

If this approach sounds ok, I can work on the implementations.

Dominant language
C++
Stars
829
Forks
587
Avg merge
4d 6h
Merged PRs (30d)
30

Getting set up

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.

More from ros2/rclcpp

All issues in ros2/rclcpp

Similar issues

More C++ issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.