ROS2/C++ Creating multiple Nodes or Publisher dynamically?
Hello! Follwing minimal example:
My ReceiverNode subscribes to a list with multiple objects, each Object has a Timestamp + Positon + Velocity + Orienation For each Object I wan to create a publisher which publishes its current Position.
What is the best way to create these multiple Publisher?
My Ideas
- Create somehow a node for each object? Can I create multiple Nodes from my ReceiverNode, I only know hot to start a ros node in the main using:
rclcpp::init(argc, argv); rclcpp::spin(std::make_shared<test::ReceiverNode()); rclcpp::shutdown();
- Create a publisher for every Object inside my ReceiverNode? Since I am using classes I need to use a vector of publisher as a class member? And a vector of timer? Does that work?
What is the best way here?