ros2_rust icon indicating copy to clipboard operation
ros2_rust copied to clipboard

Add support for node composition

Open nnmm opened this issue 3 years ago • 3 comments

See https://docs.ros.org/en/rolling/Concepts/About-Composition.html and https://docs.ros.org/en/rolling/Tutorials/Composition.html

nnmm avatar Apr 30 '22 12:04 nnmm

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(...);
  }
}

esteve avatar May 02 '22 08:05 esteve

This issue hinges on #126.

nnmm avatar Jun 05 '22 12:06 nnmm

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.

nnmm avatar Aug 20 '22 12:08 nnmm