Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for launching nodes not in a package #82

Merged
merged 2 commits into from
Oct 7, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions launch_ros/launch_ros/actions/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand All @@ -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.
Expand Down Expand Up @@ -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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the line where nightly/CI is failing.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that's wrong. I'll fix it and check why it didn't fail before.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool thanks, I've got it as part of this issue, so if you fix it could you comment there too? ros2/build_farmer#244

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:
Expand Down
Empty file.
4 changes: 0 additions & 4 deletions launch_testing_ros/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
],
ivanpauno marked this conversation as resolved.
Show resolved Hide resolved
'pytest11': ['launch_ros = launch_testing_ros.pytest.hooks'],
},
install_requires=['setuptools'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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__)
ivanpauno marked this conversation as resolved.
Show resolved Hide resolved

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')]
)
Expand Down