0
$\begingroup$

Rosanswers logo

Hi I am trying to publish a camera stream using the "uvc_camera" (http://wiki.ros.org/uvc_camera) package. All works well, but I get a low framerate on high resolution. This seems to be due to cpu overload. When I check the cpu usage with "htop", only one core seems to be used by ROS and all the capacity is used. On the other cores however, only avout 20% capacity is used.

Is there any way to make ROS run this node using multiple cpu cores?


Originally posted by eirikaso on ROS Answers with karma: 108 on 2018-05-16

Post score: 1

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

No. Not unless the node itself already uses/supports multithreading.

Note that this is not a ROS limitation, but a basic OS/process scheduling constraint: there is no way to split workloads in the way you ask for by the OS if the program has not been created with multi-core support already.


Edit: something to check: if you built the pkg from source, be sure to build with optimisations enabled. Use a CMake build type that turns those on (ie: Release or RelWithDebInfo). Packages released through and installed from the ROS buildfarm already come with optimisations.


Originally posted by gvdhoorn with karma: 86574 on 2018-05-16

This answer was ACCEPTED on the original site

Post score: 2


Original comments

Comment by parzival on 2021-04-10:
Interesting! Could you share a link to learn how to write such code? Or perhaps keywords I should search to find such resources? Thanks

Comment by gvdhoorn on 2021-04-10:\

Could you share a link to learn how to write such code?

what sort of code?

Comment by parzival on 2021-04-10:
multithreading/multiprocessing

Comment by gvdhoorn on 2021-04-10:
That wouldn't really be ROS specific. Standard multi-threading can be used.

In ROS 1, one thing to keep in mind is that using a MultiThreaded or Async spinner will not automatically make callback processing multithreaded.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.