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

Support non-interactive ros2 launch executions #210

Merged
merged 1 commit into from
Dec 21, 2020
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
13 changes: 11 additions & 2 deletions ros2launch/ros2launch/api/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,18 @@ def parse_launch_arguments(launch_arguments: List[Text]) -> List[Tuple[Text, Tex
return parsed_launch_arguments.items()


def launch_a_launch_file(*, launch_file_path, launch_file_arguments, debug=False):
def launch_a_launch_file(
*,
launch_file_path,
launch_file_arguments,
noninteractive=False,
debug=False
):
"""Launch a given launch file (by path) and pass it the given launch file arguments."""
launch_service = launch.LaunchService(argv=launch_file_arguments, debug=debug)
launch_service = launch.LaunchService(
argv=launch_file_arguments,
noninteractive=noninteractive,
debug=debug)
parsed_launch_arguments = parse_launch_arguments(launch_file_arguments)
# Include the user provided launch file using IncludeLaunchDescription so that the
# location of the current launch file is set.
Expand Down
5 changes: 5 additions & 0 deletions ros2launch/ros2launch/command/launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# limitations under the License.

import os
import sys

from ament_index_python.packages import get_package_prefix
from ament_index_python.packages import PackageNotFoundError
Expand Down Expand Up @@ -72,6 +73,9 @@ class LaunchCommand(CommandExtension):

def add_arguments(self, parser, cli_name):
"""Add arguments to argparse."""
parser.add_argument(
'-n', '--noninteractive', default=not sys.stdin.isatty(), action='store_true',
help='Run the launch system non-interactively, with no terminal associated')
parser.add_argument(
'-d', '--debug', default=False, action='store_true',
help='Put the launch system in debug mode, provides more verbose output.')
Expand Down Expand Up @@ -155,5 +159,6 @@ def main(self, *, parser, args):
return launch_a_launch_file(
launch_file_path=path,
launch_file_arguments=launch_arguments,
noninteractive=args.noninteractive,
debug=args.debug
)