Ask Your Question

Very simple ROS2 Launch xml file, but i get syntxt error at '<launch>'

asked 2021-06-26 13:26:43 -0600

Casmer gravatar image

updated 2021-06-27 16:06:49 -0600

i am trying to run ros2 laucnh ./test.launch My test launch file looks likes this:

  <node pkg="lalosoft_robot_drive_host" exec="drive_host" output="screen" />
  <node pkg="lalosoft_robot_ptz_host" exec="ptz_host" output="screen" />
  <node pkg="lalosoft_robot_jazzy_drive_host" exec="drive_host" output="screen" />

The output is this:

[DEBUG] [launch.launch_context]: emitting event synchronously: ''
[DEBUG] [launch.launch_context]: emitting event synchronously: ''
[INFO] [launch]: All log files can be found below /root/.ros/log/2021-06-26-18-24-46-457671-cotsbotrott-19643
[INFO] [launch]: Default logging verbosity is set to DEBUG
[DEBUG] [launch]: processing event: '< object at 0xb61b2c50>'
[DEBUG] [launch]: processing event: '< object at 0xb61b2c50>' ✓ '<launch.event_handlers.on_include_launch_description.OnIncludeLaunchDescription object at 0xb69f7790>'
Executing <Task finished coro=<LaunchService._process_one_event() done, defined at /opt/ros/dashing/lib/python3.6/site-packages/launch/> result=None created at /opt/ros/dashing/lib/python3.6/site-packages/launch/> took 0.230 seconds
[DEBUG] [launch]: processing event: '< object at 0xb298bf30>'
[DEBUG] [launch]: processing event: '< object at 0xb298bf30>' ✓ '<launch.event_handlers.on_include_launch_description.OnIncludeLaunchDescription object at 0xb69f7790>'
[DEBUG] [launch]: Traceback (most recent call last):
  File "/opt/ros/dashing/lib/python3.6/site-packages/launch/", line 354, in run
  File "/usr/lib/python3.6/asyncio/", line 484, in run_until_complete
    return future.result()
  File "/opt/ros/dashing/lib/python3.6/site-packages/launch/", line 244, in __run_loop
    await process_one_event_task
  File "/usr/lib/python3.6/asyncio/", line 126, in send
    return self.gen.send(value)
  File "/opt/ros/dashing/lib/python3.6/site-packages/launch/", line 181, in _process_one_event
    await self.__process_event(next_event)
  File "/usr/lib/python3.6/asyncio/", line 110, in __next__
    return self.gen.send(None)
  File "/opt/ros/dashing/lib/python3.6/site-packages/launch/", line 201, in __process_event
    visit_all_entities_and_collect_futures(entity, self.__context))
  File "/opt/ros/dashing/lib/python3.6/site-packages/launch/utilities/", line 45, in visit_all_entities_and_collect_futures
    futures_to_return += visit_all_entities_and_collect_futures(sub_entity, context)
  File "/opt/ros/dashing/lib/python3.6/site-packages/launch/utilities/", line 45, in visit_all_entities_and_collect_futures
    futures_to_return += visit_all_entities_and_collect_futures(sub_entity, context)
  File "/opt/ros/dashing/lib/python3.6/site-packages/launch/utilities/", line 38, in visit_all_entities_and_collect_futures
    sub_entities = entity.visit(context)
  File "/opt/ros/dashing/lib/python3.6/site-packages/launch/", line 59, in visit
    return self.execute(context)
  File "/opt/ros/dashing/lib/python3.6/site-packages/launch/actions/", line 103, in execute
    launch_description = self.__launch_description_source.get_launch_description(context)
  File "/opt/ros/dashing/lib/python3.6/site-packages/launch/", line 84, in get_launch_description
  File "/opt/ros/dashing/lib/python3.6/site-packages/launch/launch_description_sources/", line 62, in get_launch_description_from_python_launch_file
    launch_file_module = load_python_launch_file_as_module(python_launch_file_path)
  File "/opt/ros/dashing/lib/python3.6/site-packages/launch/launch_description_sources/", line 37, in load_python_launch_file_as_module
  File "<frozen importlib._bootstrap_external>", line 674, in exec_module
  File "<frozen importlib._bootstrap_external>", line 781, in get_code
  File "<frozen importlib._bootstrap_external>", line 741, in source_to_code
  File "<frozen importlib._bootstrap>", line ...
edit retag flag offensive close merge delete

2 Answers

Sort by » oldest newest most voted

answered 2021-06-29 05:38:16 -0600

pvl gravatar image

updated 2021-06-29 05:49:01 -0600

It appears as if ros2 launch uses the default python format instead of XML. There are different formats to use for ROS2 launch files, namely Python (default), YAML and XML. Each format has an required extension:, .launch.xml & launch.yaml.

I had to dive into the code to be sure. The following snippet confirmed this hypothesis:

is_launch_file.extensions = [
    'launch.' + extension for extension in Parser.get_available_extensions()
is_launch_file.extensions = tuple(is_launch_file.extensions)

Source - ros2launch repo - line 84-88

edit flag offensive delete link more


Yes, interesting. However, I created an XML launch file named example.launch and I could successfully run it using ros2 launch ./example.launch.
I tested in ROS2 Foxy though, while OP seems to be using Dashing. The referenced repo in your answer is the master branch, I believe. Could it have changed since the time of Dashing?

trunc8 gravatar image trunc8  ( 2021-06-29 06:12:24 -0600 )edit

it seems to have changed significantly since Dashing, but renaming the file to test.launch.xml should work in Dashing. Otherwise, since Dashing is end-of-life, the other solution is to use a non-EOL distro

christophebedard gravatar image christophebedard  ( 2021-06-29 10:02:17 -0600 )edit

answered 2021-06-29 05:52:48 -0600

For some reason, it seems to be reading the XML file as a python launch file. Can you try running this launch file?

from launch import LaunchDescription
from launch_ros.actions import Node

def generate_launch_description():
  return LaunchDescription([
edit flag offensive delete link more



Renaming it to test.launch.xml did not work? (See my answer)

pvl gravatar image pvl  ( 2021-06-29 06:00:23 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2021-06-26 13:26:43 -0600

Seen: 165 times

Last updated: Jun 29 '21