ros2_rust
ros2_rust copied to clipboard
Add support for node composition
See https://docs.ros.org/en/rolling/Concepts/About-Composition.html and https://docs.ros.org/en/rolling/Tutorials/Composition.html
This one might be a bit tricky, but doable anyway. The tricky part is that in rclcpp and rclpy, nodes inherit from Node, which obviously we can't in Rust. The way I solved this in rcljava is by creating an interface called ComposableNode, which contains a reference to the Node base class.
For Rust, we can have a similar trait, with a default implementation, e.g.
pub trait Node {
fn create_publisher(&self, ...) {}
}
impl Node for MyNode {
fn do_stuff(&self) {
let publisher = self.create_publisher(...);
}
}
This issue hinges on #126.
One thing I realized is that if we don't use a global context, component nodes will have to communicate across participants, which might be more expensive, not sure.