How to get process ID of ROS 2 nodes ?
I would like to get the process ID of ROS 2 nodes .
In ROS 1 , it could be achieved by Slave_API
In ROS 2 , I viewed rclcpp API and only could get just about nodes and topics name information.
Is there any way I can do it ?
Willing to take advice.
There isn't really a way to look for PIDs in the ROS 2 API. The main reason for this is that in ROS 2, a PID isn't a good indication of a single unit of work. That is, there can be multiple nodes in a single process by using composition.
What are you trying to accomplish? Maybe there is another way to do what you want.
Sorry for the late reply . I would like to profile nodes at runtime with perf. For the profiling result , I needed to mapping PIDs or process names to nodes.