From 2e83c3a4658c6efa51d809801f4fcc7fce19fa33 Mon Sep 17 00:00:00 2001 From: Beniamino Pozzan Date: Wed, 14 Sep 2022 11:43:56 +0200 Subject: [PATCH] Fixed fastrtps version reading in microRTPS generation Issue addressed: ROS2 is built from source and no system-wide version of fastrtps is installed Signed-off-by: Beniamino Pozzan --- msg/tools/generate_microRTPS_bridge.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/msg/tools/generate_microRTPS_bridge.py b/msg/tools/generate_microRTPS_bridge.py index 057770066d..a1a0b31519 100644 --- a/msg/tools/generate_microRTPS_bridge.py +++ b/msg/tools/generate_microRTPS_bridge.py @@ -212,8 +212,14 @@ else: "dpkg -s ros-" + ros2_distro + "-fastrtps 2>/dev/null | grep -i version", shell=True).decode("utf-8").strip()).group(1) except subprocess.CalledProcessError: # if ROS2 was installed from sources the command above fails, get the system-wide version instead - fastrtps_version = subprocess.check_output( - "ldconfig -v 2>/dev/null | grep libfastrtps", shell=True).decode("utf-8").strip().split('so.')[-1] + try: + fastrtps_version = subprocess.check_output( + "ldconfig -v 2>/dev/null | grep libfastrtps", shell=True).decode("utf-8").strip().split('so.')[-1] + except subprocess.CalledProcessError: + # if no system-wide version is found, look for the one provided by the source-installed ROS2 + fastrtps_path = re.search(r'(?!\:)[^\:]*fastrtps\/lib(?=\:)', os.environ.get('LD_LIBRARY_PATH')).group(0) + fastrtps_version = subprocess.check_output( + "ls " + fastrtps_path, shell=True).decode("utf-8").strip().split('so.')[-1] # If nothing specified it's generated both