From 58c01e0fc974db207e2d6034dd5559bb46b60124 Mon Sep 17 00:00:00 2001 From: andrewbest-tri <43861892+andrewbest-tri@users.noreply.github.com> Date: Thu, 4 Aug 2022 07:34:16 -0700 Subject: [PATCH] Limit bridge threads (#3) --- carla_ros_bridge/src/carla_ros_bridge/bridge.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/carla_ros_bridge/src/carla_ros_bridge/bridge.py b/carla_ros_bridge/src/carla_ros_bridge/bridge.py index 5e2e2b21f..02560983f 100755 --- a/carla_ros_bridge/src/carla_ros_bridge/bridge.py +++ b/carla_ros_bridge/src/carla_ros_bridge/bridge.py @@ -10,7 +10,7 @@ Class that handle communication between CARLA and ROS """ - +import multiprocessing import os import pkg_resources try: @@ -38,6 +38,10 @@ from rosgraph_msgs.msg import Clock +# Cyclone DDS on large core counts will not play nicely. Limit process to 16 cores. +WORKER_THREADS = 0 if multiprocessing.cpu_count() < 16 else 16 + + class CarlaRosBridge(CompatibleNode): """ @@ -418,7 +422,9 @@ def main(args=None): try: carla_client = carla.Client( host=parameters['host'], - port=parameters['port']) + port=parameters['port'], + worker_threads=WORKER_THREADS + ) carla_client.set_timeout(parameters['timeout']) # check carla version