From 3b6bf45b7ebd355e336e4c4e83a8559579b14529 Mon Sep 17 00:00:00 2001 From: Michel Hidalgo Date: Fri, 4 Oct 2019 15:59:14 -0300 Subject: [PATCH 1/2] Add support for launching nodes not installed by a package. By making the package argument in launch_ros.actions.Node action optional. Signed-off-by: Michel Hidalgo --- launch_ros/launch_ros/actions/node.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/launch_ros/launch_ros/actions/node.py b/launch_ros/launch_ros/actions/node.py index 5109c723..7b36cb44 100644 --- a/launch_ros/launch_ros/actions/node.py +++ b/launch_ros/launch_ros/actions/node.py @@ -59,8 +59,8 @@ class Node(ExecuteProcess): def __init__( self, *, - package: SomeSubstitutionsType, node_executable: SomeSubstitutionsType, + package: Optional[SomeSubstitutionsType] = None, node_name: Optional[SomeSubstitutionsType] = None, node_namespace: SomeSubstitutionsType = '', parameters: Optional[SomeParameters] = None, @@ -115,8 +115,9 @@ def __init__( passed in in order to the node (where the last definition of a parameter takes effect). + :param: node_executable the name of the executable to find if a package + is provided or otherwise a path to the executable to run. :param: package the package in which the node executable can be found - :param: node_executable the name of the executable to find :param: node_name the name of the node :param: node_namespace the ros namespace for this Node :param: parameters list of names of yaml files with parameter rules, @@ -125,7 +126,10 @@ def __init__( passed to the node as ROS remapping rules :param: arguments list of extra arguments for the node """ - cmd = [ExecutableInPackage(package=package, executable=node_executable)] + if package is not None: + cmd = [ExecutableInPackage(package=package, executable=node_executable)] + else: + cmd = [node_executable] cmd += [] if arguments is None else arguments # Reserve space for ros specific arguments. # The substitutions will get expanded when the action is executed. @@ -235,7 +239,9 @@ def parse(cls, entity: Entity, parser: Parser): node_name = entity.get_attr('node-name', optional=True) if node_name is not None: kwargs['node_name'] = node_name - kwargs['package'] = parser.parse_substitution(entity.get_attr('pkg')) + package = parser.parse_substitution(entity.get_attr('pkg'), optional=True) + if package is not None: + kwargs['package'] = package kwargs['node_executable'] = parser.parse_substitution(entity.get_attr('exec')) ns = entity.get_attr('namespace', optional=True) if ns is not None: From 9e7292e161da77ced8bf4ad9d5c122b0ee5d3f30 Mon Sep 17 00:00:00 2001 From: Michel Hidalgo Date: Fri, 4 Oct 2019 16:00:48 -0300 Subject: [PATCH 2/2] Stop installing launch_testing_ros test fixture nodes. Signed-off-by: Michel Hidalgo --- .../launch_testing_ros/examples/__init__.py | 0 launch_testing_ros/setup.py | 4 ---- .../examples/listener.py | 0 .../{launch_testing_ros => test}/examples/talker.py | 0 .../test/examples/talker_listener_launch_test.py | 12 ++++++++---- 5 files changed, 8 insertions(+), 8 deletions(-) delete mode 100644 launch_testing_ros/launch_testing_ros/examples/__init__.py rename launch_testing_ros/{launch_testing_ros => test}/examples/listener.py (100%) rename launch_testing_ros/{launch_testing_ros => test}/examples/talker.py (100%) diff --git a/launch_testing_ros/launch_testing_ros/examples/__init__.py b/launch_testing_ros/launch_testing_ros/examples/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/launch_testing_ros/setup.py b/launch_testing_ros/setup.py index 4069402f..5bb8b53f 100644 --- a/launch_testing_ros/setup.py +++ b/launch_testing_ros/setup.py @@ -13,10 +13,6 @@ ('share/launch_testing_ros/examples', glob.glob('test/examples/[!_]*.*')), ], entry_points={ - 'console_scripts': [ - 'example_talker = launch_testing_ros.examples.talker:main', - 'example_listener = launch_testing_ros.examples.listener:main' - ], 'pytest11': ['launch_ros = launch_testing_ros.pytest.hooks'], }, install_requires=['setuptools'], diff --git a/launch_testing_ros/launch_testing_ros/examples/listener.py b/launch_testing_ros/test/examples/listener.py similarity index 100% rename from launch_testing_ros/launch_testing_ros/examples/listener.py rename to launch_testing_ros/test/examples/listener.py diff --git a/launch_testing_ros/launch_testing_ros/examples/talker.py b/launch_testing_ros/test/examples/talker.py similarity index 100% rename from launch_testing_ros/launch_testing_ros/examples/talker.py rename to launch_testing_ros/test/examples/talker.py diff --git a/launch_testing_ros/test/examples/talker_listener_launch_test.py b/launch_testing_ros/test/examples/talker_listener_launch_test.py index 6e9be13d..34eb7ab9 100644 --- a/launch_testing_ros/test/examples/talker_listener_launch_test.py +++ b/launch_testing_ros/test/examples/talker_listener_launch_test.py @@ -12,6 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. +import os +import sys import time import unittest import uuid @@ -32,16 +34,18 @@ def generate_test_description(ready_fn): # 'chatter' topic, but we want to show how to use remappings to munge the data so we # will remap these topics when we launch the nodes and insert our own node that can # change the data as it passes through + path_to_test = os.path.dirname(__file__) + talker_node = launch_ros.actions.Node( - package='launch_testing_ros', - node_executable='example_talker', + node_executable=sys.executable, + arguments=[os.path.join(path_to_test, 'talker.py')], additional_env={'PYTHONUNBUFFERED': '1'}, remappings=[('chatter', 'talker_chatter')] ) listener_node = launch_ros.actions.Node( - package='launch_testing_ros', - node_executable='example_listener', + node_executable=sys.executable, + arguments=[os.path.join(path_to_test, 'listener.py')], additional_env={'PYTHONUNBUFFERED': '1'}, remappings=[('chatter', 'listener_chatter')] )