ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
1

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

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

Casmer gravatar image

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

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

<launch>
  <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" />
</launch>

The output is this:

[DEBUG] [launch.launch_context]: emitting event synchronously: 'launch.events.IncludeLaunchDescription'
[DEBUG] [launch.launch_context]: emitting event synchronously: 'launch.events.IncludeLaunchDescription'
[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: '<launch.events.include_launch_description.IncludeLaunchDescription object at 0xb61b2c50>'
[DEBUG] [launch]: processing event: '<launch.events.include_launch_description.IncludeLaunchDescription 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/launch_service.py:179> result=None created at /opt/ros/dashing/lib/python3.6/site-packages/launch/launch_service.py:222> took 0.230 seconds
[DEBUG] [launch]: processing event: '<launch.events.include_launch_description.IncludeLaunchDescription object at 0xb298bf30>'
[DEBUG] [launch]: processing event: '<launch.events.include_launch_description.IncludeLaunchDescription 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/launch_service.py", line 354, in run
    self.__loop_from_run_thread.run_until_complete(run_loop_task)
  File "/usr/lib/python3.6/asyncio/base_events.py", line 484, in run_until_complete
    return future.result()
  File "/opt/ros/dashing/lib/python3.6/site-packages/launch/launch_service.py", line 244, in __run_loop
    await process_one_event_task
  File "/usr/lib/python3.6/asyncio/coroutines.py", line 126, in send
    return self.gen.send(value)
  File "/opt/ros/dashing/lib/python3.6/site-packages/launch/launch_service.py", line 181, in _process_one_event
    await self.__process_event(next_event)
  File "/usr/lib/python3.6/asyncio/coroutines.py", line 110, in __next__
    return self.gen.send(None)
  File "/opt/ros/dashing/lib/python3.6/site-packages/launch/launch_service.py", 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/visit_all_entities_and_collect_futures_impl.py", 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/visit_all_entities_and_collect_futures_impl.py", 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/visit_all_entities_and_collect_futures_impl.py", line 38, in visit_all_entities_and_collect_futures
    sub_entities = entity.visit(context)
  File "/opt/ros/dashing/lib/python3.6/site-packages/launch/action.py", line 59, in visit
    return self.execute(context)
  File "/opt/ros/dashing/lib/python3.6/site-packages/launch/actions/include_launch_description.py", line 103, in execute
    launch_description = self.__launch_description_source.get_launch_description(context)
  File "/opt/ros/dashing/lib/python3.6/site-packages/launch/launch_description_source.py", line 84, in get_launch_description
    self._get_launch_description(self.__expanded_location)
  File "/opt/ros/dashing/lib/python3.6/site-packages/launch/launch_description_sources/python_launch_file_utilities.py", 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/python_launch_file_utilities.py", line 37, in load_python_launch_file_as_module
    loader.exec_module(mod)
  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 ...
(more)
edit retag flag offensive close merge delete

3 Answers

Sort by » oldest newest most voted
2

answered 2021-06-29 10:02:17 -0500

updated 2021-06-29 10:02:57 -0500

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

edit flag offensive delete link more
0

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

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

test.launch.py

from launch import LaunchDescription
from launch_ros.actions import Node

def generate_launch_description():
  return LaunchDescription([
    Node(
      package="lalosoft_robot_drive_host",
      executable="drive_host",
      output="screen"
      ),
    Node(
      package="lalosoft_robot_ptz_host",
      executable="ptz_host",
      output="screen"
      ),
    Node(
      package="lalosoft_robot_jazzy_drive_host",
      executable="drive_host",
      output="screen"
      ),
    ])
edit flag offensive delete link more

Comments

1

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

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

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

pvl gravatar image

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

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.py, .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.append('launch.py')
is_launch_file.extensions = tuple(is_launch_file.extensions)

Source - ros2launch repo - line 84-88

edit flag offensive delete link more

Comments

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 -0500 )edit

Question Tools

1 follower

Stats

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

Seen: 1,094 times

Last updated: Jun 29 '21