change how to get ros2 version

This commit is contained in:
stmoon
2020-03-15 21:43:16 +09:00
committed by Nuno Marques
parent 5f86ea71bc
commit aaa72b2a25
+9 -12
View File
@@ -264,18 +264,15 @@ fastrtps_version = subprocess.check_output(
"ldconfig -v | grep libfastrtps", shell=True).decode("utf-8").strip().split('so.')[-1] "ldconfig -v | grep libfastrtps", shell=True).decode("utf-8").strip().split('so.')[-1]
# get ROS 2 version, if exists # get ROS 2 version, if exists
ros2_distro = "" ros2_distro = ''
try: ros_version = os.environ.get('ROS_VERSION')
rosversion_out = subprocess.check_output(["rosversion", "-d"]) if ros_version == '2' :
rosversion_out = rosversion_out.rstrip().decode('utf-8') if args.ros2_distro != '':
if rosversion_out not in ["<unknown>", "kinetic", "lunar", "melodic"]: ros2_distro = args.ros2_distro
ros2_distro = rosversion_out else :
except OSError as e: ros2_distro = os.environ.get('ROS_DISTRO')
if e.errno == errno.ENOENT: else :
if args.ros2_distro != None: raise ValueError
ros2_distro = args.ros2_distro
else:
raise
# If nothing specified it's generated both # If nothing specified it's generated both
if agent == False and client == False: if agent == False and client == False: