From e268e692655407cde2bf46743b37d386f26ac3b4 Mon Sep 17 00:00:00 2001 From: Agata Barcis Date: Fri, 9 Sep 2022 16:00:23 +0400 Subject: [PATCH] Fixed fastrtps version reading in microRTPS generation for ROS2 built from sources --- msg/tools/generate_microRTPS_bridge.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/msg/tools/generate_microRTPS_bridge.py b/msg/tools/generate_microRTPS_bridge.py index 67b1b6ae2d..057770066d 100644 --- a/msg/tools/generate_microRTPS_bridge.py +++ b/msg/tools/generate_microRTPS_bridge.py @@ -206,9 +206,14 @@ if not ros2_distro: fastrtps_version = subprocess.check_output( "ldconfig -v 2>/dev/null | grep libfastrtps", shell=True).decode("utf-8").strip().split('so.')[-1] else: - # grab the version of the ros--fastrtps package - fastrtps_version = re.search(r'Version:\s*([\dd.]+)', subprocess.check_output( - "dpkg -s ros-" + ros2_distro + "-fastrtps 2>/dev/null | grep -i version", shell=True).decode("utf-8").strip()).group(1) + try: + # grab the version of the ros--fastrtps package + fastrtps_version = re.search(r'Version:\s*([\dd.]+)', subprocess.check_output( + "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] # If nothing specified it's generated both