Skip to content

Commit 2f09c64

Browse files
authored
Support non-interactive ros2 launch executions (#210)
Signed-off-by: Michel Hidalgo <[email protected]>
1 parent fc3d7de commit 2f09c64

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

ros2launch/ros2launch/api/api.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,9 +140,18 @@ def parse_launch_arguments(launch_arguments: List[Text]) -> List[Tuple[Text, Tex
140140
return parsed_launch_arguments.items()
141141

142142

143-
def launch_a_launch_file(*, launch_file_path, launch_file_arguments, debug=False):
143+
def launch_a_launch_file(
144+
*,
145+
launch_file_path,
146+
launch_file_arguments,
147+
noninteractive=False,
148+
debug=False
149+
):
144150
"""Launch a given launch file (by path) and pass it the given launch file arguments."""
145-
launch_service = launch.LaunchService(argv=launch_file_arguments, debug=debug)
151+
launch_service = launch.LaunchService(
152+
argv=launch_file_arguments,
153+
noninteractive=noninteractive,
154+
debug=debug)
146155
parsed_launch_arguments = parse_launch_arguments(launch_file_arguments)
147156
# Include the user provided launch file using IncludeLaunchDescription so that the
148157
# location of the current launch file is set.

ros2launch/ros2launch/command/launch.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
# limitations under the License.
1414

1515
import os
16+
import sys
1617

1718
from ament_index_python.packages import get_package_prefix
1819
from ament_index_python.packages import PackageNotFoundError
@@ -72,6 +73,9 @@ class LaunchCommand(CommandExtension):
7273

7374
def add_arguments(self, parser, cli_name):
7475
"""Add arguments to argparse."""
76+
parser.add_argument(
77+
'-n', '--noninteractive', default=not sys.stdin.isatty(), action='store_true',
78+
help='Run the launch system non-interactively, with no terminal associated')
7579
parser.add_argument(
7680
'-d', '--debug', default=False, action='store_true',
7781
help='Put the launch system in debug mode, provides more verbose output.')
@@ -155,5 +159,6 @@ def main(self, *, parser, args):
155159
return launch_a_launch_file(
156160
launch_file_path=path,
157161
launch_file_arguments=launch_arguments,
162+
noninteractive=args.noninteractive,
158163
debug=args.debug
159164
)

0 commit comments

Comments
 (0)