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

Revision history [back]

click to hide/show revision 1
initial version

For some basic parallelism in ROS, you can use OpenMP (assuming parts of your code can be executed in parallel, that is).

In CMakeLists.txt add the following for your project (replacing the binary_name and source_code by their actual names)

rosbuild_add_executable(binary_name src/source_code.cpp)
rosbuild_add_openmp_flags(binary_name)

in your source code you can then use

#pragama omp parallel for

to execute for-loops in parallel. See this page for further reference, including restrictions on usage. Be careful with with shared variables such as counters that might be reset while another loop might still be using it.

For some basic parallelism in ROS, you can use OpenMP (assuming parts of your code can be executed in parallel, that is).

In CMakeLists.txt add the following for your project (replacing the binary_name and source_code by their actual names)

rosbuild_add_executable(binary_name src/source_code.cpp)
rosbuild_add_openmp_flags(binary_name)

in your source code you can then use

#pragama omp parallel for

to execute for-loops in parallel. See this page for further reference, including restrictions on usage. Be careful with with shared variables such as counters that might be reset while another loop might still be using it.

Also, check out the tutorial on multi-threaded callback processing under ros_tutorials for another example

opt/ros/electric/stacks/ros_tutorials/roscpp_tutorials/listener_threaded_spin

(default path in electric)