Compiling ROS2 node with large nr of subscribers doesn't scale
Hello. I'm having some trouble creating a subscriber node that contains a large amount of messages. In terms of code structure, I'm implementing the same type of subscriber node as shown here: https://index.ros.org/doc/ros2/Tutori...
The issue, is that as the number of messages increases, each with a unique message type and callback, the module becomes impossible to compile due to memory constraints. At ~60 messages, the cc1plus process is consuming 6GB of RAM attempting to compile. This makes sense, as the single compilation unit is becoming quite large. Additionally, I believe that the underlying templates for the create_subscription are exploding the memory consumption. Setting the compile flag -ftemplate-depth=XX yields that a single subscription has a template depth greater than 50.
So... with that lead in, is there a more scale-able way to implement a subscriber node with custom callbacks and message types?
60 subscribers for a single node? Seems like you might want to make things more modular, which is the ROS-y way of doing things.
I do admit some level of ROS in-familiarity, but coming from other pure messaging frameworks 60 subscriptions seems rather low for some applications (I'm used to hundreds). I'm fine coming up with a scheme that limits node subscriptions, but am curious if there are ways to allow for N subscribers (generic run-time subscribe, etc).
hundreds of different subscriptions in a single node?
Could you give a (high-level) example of the type of system(s) you're creating?
Sure. For example, our ROS environment needs to interface with an external device, so a node is serving as a serializer of a set of ROS messages that need to be sent to the device, where that set of messages could be in the hundreds of unique messages.