-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor ComponentInterface to use node interfaces #33
Refactor ComponentInterface to use node interfaces #33
Conversation
Remove template class NodeT Change ComponentInterface constructor arguments to get all the node interfaces
cee18d7
to
62d22cb
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's been sitting for a while and I've looked over a couple of times, finally I gave it some proper thought. Great start! Will be good to get this moving again. For the derived component classes, were you planning do something along the following lines?
// declare double inheritance
class Component : public rclcpp::Node, public ComponentInterface {
...
}
// construct the ComponentInterface after the Node, using the Node methods that are already constructed
Component::Component(const rclcpp::NodeOptions& node_options, const std::string& fallback_name) :
rclcpp::Node(utilities::parse_node_name(node_options, fallback_name), node_options), ComponentInterface(
std::make_shared<rclcpp::node_interfaces::NodeInterfaces<ALL_RCLCPP_NODE_INTERFACES>>(
rclcpp::Node::get_node_base_interface(), rclcpp::Node::get_node_clock_interface(),
rclcpp::Node::get_node_graph_interface(), rclcpp::Node::get_node_logging_interface(),
rclcpp::Node::get_node_parameters_interface(), rclcpp::Node::get_node_services_interface(),
rclcpp::Node::get_node_time_source_interface(), rclcpp::Node::get_node_timers_interface(),
rclcpp::Node::get_node_topics_interface(), rclcpp::Node::get_node_waitables_interface())), started_(false) {
this->add_predicate("is_finished", false);
}
I believe that would work!
Yes indeed, see here Branch |
Description
This is kind of a long shot and has low priority, but I wanted to write it down while it's fresh.
Even though the changes are big, they are not as complex in my opinion. What you need to do is get a pointer to all node interfaces
rclcpp::node_interfaces::NodeInterfaces<ALL_RCLCPP_NODE_INTERFACES>
to be able to replace all occurrences ofNodeT::foo
.So basically, most of the changes are in the style of
this->get_logger()
that becomesthis->node_logging_->get_logger()
(same for parameters, clock). Services and subscriptions are slightly more complicated, you have to doi.e. you have to work with the
node_parameters_
andnode_topics_
interfaces.Another nice consequence is that the
PublisherType
does not have to be a class attribute anymore, but can just be passed as an argument tocreate_output
. Apart from that, I just updated the tests (that got much simpler without these if else blocks based on theTypeParam
).The CI will not build obviously though.
Review guidelines
Estimated Time of Review: 20 minutes
Review by commit