Architecture: how do you split large nodes

asked 2022-11-28 11:43:07 -0600

PatoInso gravatar image

Hi,

I often encounter a situation where I'd like to split the code of a node into several files. Typical case: in a node responsible for system monitoring, I'd like to put the subscriptions and callbacks related to lidar in one pair of .cpp/.h/class, and the ones related to odometry monitoring in another pair of pair of .cpp/.h/class. In case of issue detected by one of these separated classes, an emergency stop service must be called.

In these separated classes, I then need to create suscriptions, timer, etc, sot to access a kind of "parent node" with common functionalities (eg. the parent node has a client to call an emergency stop service). But I always struggle to pass this parent node (can't pass 'this' from the node constructor, struggle with shared_from_this(), circular dependency issues...)

How do you usually split your large nodes ? (pass a parent node, just a node interface, inherit from a parent node...)

edit retag flag offensive close merge delete