generate_microRTPS_bridge: make sure that the ROS2 version of FastRTPS is grabbed in a colcon build

This commit is contained in:
TSC21 2020-07-28 18:53:31 +01:00 committed by Nuno Marques
parent 311a8144e1
commit acc3866ac9
1 changed files with 13 additions and 3 deletions

View File

@ -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-<ros_distro>-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