From acc3866ac93a180301984a54fc6ba6959e7b23ef Mon Sep 17 00:00:00 2001 From: TSC21 Date: Tue, 28 Jul 2020 18:53:31 +0100 Subject: [PATCH] generate_microRTPS_bridge: make sure that the ROS2 version of FastRTPS is grabbed in a colcon build --- msg/tools/generate_microRTPS_bridge.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/msg/tools/generate_microRTPS_bridge.py b/msg/tools/generate_microRTPS_bridge.py index 81d6f3a702..91e6475a17 100644 --- a/msg/tools/generate_microRTPS_bridge.py +++ b/msg/tools/generate_microRTPS_bridge.py @@ -47,6 +47,7 @@ from uorb_rtps_classifier import Classifier import subprocess import glob import errno +import re try: from six.moves import input @@ -259,9 +260,6 @@ else: raise Exception( "FastRTPSGen not found. Specify the location of fastrtpsgen with the -f flag") -# get FastRTPS version -fastrtps_version = subprocess.check_output( - "ldconfig -v 2>/dev/null | grep libfastrtps", shell=True).decode("utf-8").strip().split('so.')[-1] # get ROS 2 version, if exists ros2_distro = '' @@ -272,6 +270,18 @@ if ros_version == '2' : else : ros2_distro = os.environ.get('ROS_DISTRO') +# get FastRTPS version +fastrtps_version = '' +if not ros2_distro: + # grab the version installed system wise + 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) + + # If nothing specified it's generated both if agent == False and client == False: agent = True