ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

Hello everyone, I am running multiple nodes in different executables and I would like to use MultiThreadedExecutor. However, how to know which cores are my nodes using ?

asked 2023-05-31 16:14:21 -0500

Juan Carlos gravatar image

The main idea is verify which nodes are working on which computer cores and then after use rclcpp::executors::MultiThreadedExecutor check if they were used in different cores.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2023-06-01 06:37:42 -0500

Mike Scheutzow gravatar image

how to know which cores are my nodes using ?

This is decided by your operating system, and usually the cpu cores change from one second to the next. So this is not really a useful question.

If you are trying to compare the behavior of SingleThreadedExecutor to MultiThreadedExecutor, and determine the number of threads that exist for a particular linux process, then (on linux) you can use the /bin/ps command. If the Process Id (PID) of your ros node is 29969, then:

$ /bin/ps -p 29969 -L -f
UID      PID    PPID LWP    C NLWP STIME TTY          TIME CMD
mike     29969  2820 29969  0    3 07:24 pts/0    00:00:00 /usr/bin/python /opt/ros/melodi
mike     29969  2820 29990  0    3 07:24 pts/0    00:00:00 /usr/bin/python /opt/ros/melodi
mike     29969  2820 29991  0    3 07:24 pts/0    00:00:00 /usr/bin/python /opt/ros/melodi

Process 29969 is running 3 threads (the main thread, plus 2 more.)

edit flag offensive delete link more

Comments

Thank you for your answer. However, do you know if there is a way to relate ros2 nodes with the process Id. Because as you show me, that is the task and one single task can run two or more nodes.

Juan Carlos gravatar image Juan Carlos  ( 2023-06-01 10:47:32 -0500 )edit

Question Tools

2 followers

Stats

Asked: 2023-05-31 16:14:21 -0500

Seen: 89 times

Last updated: Jun 01 '23