ros2 / ros2/rclcpp

Node traits

Open
#2,875 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
C++
Stars
805
Forks
564
Avg merge
1d 17h
Merged PRs (30d)
27

Description

Description

I would find handy to have in rclcpp C++ traits like (draft):

rclcpp::is_node<typename T>
rclcpp::is_node_v<typename T>
rclcpp::is_lifecycle_node<typename T>
rclcpp::is_lifecycle_node_v<typename T>

they can be easily implemented via std::is_base_of.

the is_node trait may be ambiguous. We can:

  • return true for both rclcpp::Node and rclcpp::LifecycleNode (and use the is_lifecycle_node to further discriminate among the two)
  • return true ONLY for rclcpp::Node

I see there are traits for other things like subscriptions and so on in the library, but before drafting a PR I'd like some feedback (or tell me if it is something it's better not to put in rclcpp).

Motivation

Mainly, this would help distinguish between normal nodes and lifecycle nodes, write better templates and so on.

Design / Implementation Considerations

No response

Additional Information

No response

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

Review the existing rclcpp traits for subscriptions and the definitions of Node and LifecycleNode. Resolve whether is_node should include lifecycle nodes, then determine the appropriate public trait location and coverage. Done means the trait behavior is unambiguous and the requested normal-node and lifecycle-node distinctions are supported.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
backend-api-design
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.