From 444653d23417609db549a4cbada7e7961d76b830 Mon Sep 17 00:00:00 2001 From: stmoon Date: Thu, 30 Jan 2020 14:55:01 +0900 Subject: [PATCH 1/5] change how to get ros2 version (rosverion -> ROS_DISTRO) --- msg/tools/generate_microRTPS_bridge.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/msg/tools/generate_microRTPS_bridge.py b/msg/tools/generate_microRTPS_bridge.py index 251eb936bc4a..31d1563b1ec0 100644 --- a/msg/tools/generate_microRTPS_bridge.py +++ b/msg/tools/generate_microRTPS_bridge.py @@ -252,7 +252,7 @@ def check_rtps_id_uniqueness(classifier): # get ROS 2 version, if exists ros2_distro = "" try: - rosversion_out = subprocess.check_output(["rosversion", "-d"]) + rosversion_out = os.environ['ROS_DISTRO'] rosversion_out = rosversion_out.rstrip() if rosversion_out not in ["", "kinetic", "lunar", "melodic"]: ros2_distro = rosversion_out From 7f0c0616d8da1b927aa5da130ef70c2b9841a90a Mon Sep 17 00:00:00 2001 From: stmoon Date: Thu, 30 Jan 2020 22:18:29 +0900 Subject: [PATCH 2/5] check ROS_DISTRO environment variable before using rosversion --- msg/tools/generate_microRTPS_bridge.py | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/msg/tools/generate_microRTPS_bridge.py b/msg/tools/generate_microRTPS_bridge.py index 31d1563b1ec0..d97676d93920 100644 --- a/msg/tools/generate_microRTPS_bridge.py +++ b/msg/tools/generate_microRTPS_bridge.py @@ -250,18 +250,19 @@ def check_rtps_id_uniqueness(classifier): "FastRTPSGen not found. Specify the location of fastrtpsgen with the -f flag") # get ROS 2 version, if exists -ros2_distro = "" -try: - rosversion_out = os.environ['ROS_DISTRO'] - rosversion_out = rosversion_out.rstrip() - if rosversion_out not in ["", "kinetic", "lunar", "melodic"]: - ros2_distro = rosversion_out -except OSError as e: - if e.errno == errno.ENOENT: - if args.ros2_distro != None: - ros2_distro = args.ros2_distro - else: - raise +ros2_distro = os.environ.get('ROS_DISTRO') +if ros2_distro is None : + try: + rosversion_out = subprocess.check_output(["rosversion", "-d"]) + rosversion_out = rosversion_out.rstrip() + if rosversion_out not in ["", "kinetic", "lunar", "melodic"]: + ros2_distro = rosversion_out + except OSError as e: + if e.errno == errno.ENOENT: + if args.ros2_distro != None: + ros2_distro = args.ros2_distro + else: + raise # If nothing specified it's generated both if agent == False and client == False: From 32150652dc0e6c21c8e1a3d404ffc2ab2b5241cb Mon Sep 17 00:00:00 2001 From: stmoon Date: Sat, 1 Feb 2020 13:53:03 +0900 Subject: [PATCH 3/5] ros2_distro = "", if ros2_distro is not found finally --- msg/tools/generate_microRTPS_bridge.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/msg/tools/generate_microRTPS_bridge.py b/msg/tools/generate_microRTPS_bridge.py index d97676d93920..4ec3d3ad9900 100644 --- a/msg/tools/generate_microRTPS_bridge.py +++ b/msg/tools/generate_microRTPS_bridge.py @@ -257,6 +257,8 @@ def check_rtps_id_uniqueness(classifier): rosversion_out = rosversion_out.rstrip() if rosversion_out not in ["", "kinetic", "lunar", "melodic"]: ros2_distro = rosversion_out + else : + ros2_distro = "" except OSError as e: if e.errno == errno.ENOENT: if args.ros2_distro != None: From dbf061cb045804bcd6810675286fff41c7a90ffc Mon Sep 17 00:00:00 2001 From: stmoon Date: Sat, 1 Feb 2020 14:08:45 +0900 Subject: [PATCH 4/5] fix the bug about format error --- src/modules/commander/commander_params.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/commander/commander_params.c b/src/modules/commander/commander_params.c index a610f4889e85..c57ba293a1d9 100644 --- a/src/modules/commander/commander_params.c +++ b/src/modules/commander/commander_params.c @@ -632,7 +632,7 @@ PARAM_DEFINE_INT32(COM_ARM_MAG_STR, 1); /** * Enable RC stick override of auto and/or offboard modes * - * When RC stick override is enabled, moving the RC sticks immediately gives control back + * When RC stick override is enabled, moving the RC sticks immediately gives control back * to the pilot (switches to manual position mode): * bit 0: Enable for auto modes (except for in critical battery reaction), * bit 1: Enable for offboard mode. From 79a0b0c73d494a9b0392b3296c92b8d9b4cd3a2a Mon Sep 17 00:00:00 2001 From: stmoon Date: Sun, 15 Mar 2020 11:49:51 +0900 Subject: [PATCH 5/5] use ROS_VERSION and ROS_DISTRO to check ros2 version --- msg/tools/generate_microRTPS_bridge.py | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/msg/tools/generate_microRTPS_bridge.py b/msg/tools/generate_microRTPS_bridge.py index 4ec3d3ad9900..39acef9183f0 100644 --- a/msg/tools/generate_microRTPS_bridge.py +++ b/msg/tools/generate_microRTPS_bridge.py @@ -250,21 +250,15 @@ def check_rtps_id_uniqueness(classifier): "FastRTPSGen not found. Specify the location of fastrtpsgen with the -f flag") # get ROS 2 version, if exists -ros2_distro = os.environ.get('ROS_DISTRO') -if ros2_distro is None : - try: - rosversion_out = subprocess.check_output(["rosversion", "-d"]) - rosversion_out = rosversion_out.rstrip() - if rosversion_out not in ["", "kinetic", "lunar", "melodic"]: - ros2_distro = rosversion_out - else : - ros2_distro = "" - except OSError as e: - if e.errno == errno.ENOENT: - if args.ros2_distro != None: - ros2_distro = args.ros2_distro - else: - raise +ros2_distro = '' +ros_version = os.environ.get('ROS_VERSION') +if ros_version == '2' : + if args.ros2_distro != '': + ros2_distro = args.ros2_distro + else : + ros2_distro = os.environ.get('ROS_DISTRO') +else : + raise ValueError # If nothing specified it's generated both if agent == False and client == False: