Is it possible to get the number of all existing ROS_Nodes or to shut down all Nodes except one?
I'm trying to shut down all Nodes except 1 within a C++ program. Therefore I want to count the number of ROS_Nodes and kill n-2 nodes. ( My_Node and roscore shall still exist). Or is there any other way to do so?
Thanks for your Help
To avoid an xy-problem, it might be good if you could clarify why you want to do this. It might not be necessary.
I need it, because I have to restart Gazebo with another enviroment. But the Linux-Computer is remote controlled to this. Therefore I have to shut down every ROS_Node, except the one which handles the remote.
If you can manage the state of "your node", then would deployment using Docker perhaps be an option? Reusing
roscore
instances is not necessarily always very stable (left over parameters, etc).