Skip to content

Node traits #2875

@roncapat

Description

@roncapat

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions