Closed Chris7462 closed 9 months ago
This PR isn't inherently bad, but we think a better approach can be taken: rather than receiving a Node*
or Node::SharedPtr
, it would be better to receive a template type NodeT
and receive a pointer/shared pointer to that. This would allow any node type that meets the interface requirements to be passed in.
Thanks. I have modified the constructor based on the suggestion. I also moved the struct ImageTransport::Impl
from the .cpp file to the header file accordingly.
The
image_transport::ImageTransport
has the only constructor with input argumentrclcpp::Node::SharedPtr
, and we have to write bothrclcpp::Node::SharedPtr node = rclcpp::Node::make_shared("image_publisher", options);
andimage_transport::ImageTransport it(node);
inside the main function, which is not recommended by ROS2 style.By adding another constructor, we now can move all the declarations into the class and follow the recommended structure to write the node: create a class which inherits from
rclcpp::Node
.A minimal subscriber example:
A minimal publisher example: