ros-geographic-info/open_street_map

Launch file working on ROS2 ?

Opened this issue · 1 comments

Hi,
I've installed open_street_map and try to load a map. I have a strange error message when lauching viz_osm using hte following command: ros2 launch osm_cartography viz_osm.launch.py url:=file://absolute/path/map.osm.
So my questions are :

  • Is this the correct command ?
  • Is the launch file supposed to work, meaning the problem comes from me, or is it deprecated ?

I'm using ROS2 foxy, and my full error log is here:

[INFO] [launch]: All log files can be found below /home/ben/.ros/log/2021-01-08-19-09-03-205910-ben-VirtualBox-23584
[INFO] [launch]: Default logging verbosity is set to INFO
Task exception was never retrieved
future: <Task finished name='Task-2' coro=<LaunchService._process_one_event() done, defined at /opt/ros/foxy/lib/python3.8/site-packages/launch/launch_service.py:271> exception=InvalidLaunchFileError('py')>
Traceback (most recent call last):
  File "/opt/ros/foxy/lib/python3.8/site-packages/launch/launch_description_sources/any_launch_file_utilities.py", line 53, in get_launch_description_from_any_launch_file
    return loader(launch_file_path)
  File "/opt/ros/foxy/lib/python3.8/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/foxy/lib/python3.8/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 783, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/media/sf_dev/bilberry/install/osm_cartography/share/osm_cartography/launch/viz_osm.launch.py", line 20, in <module>
    from launch_ros import actions, get_default_launch_description
ImportError: cannot import name 'get_default_launch_description' from 'launch_ros' (/opt/ros/foxy/lib/python3.8/site-packages/launch_ros/__init__.py)

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/opt/ros/foxy/lib/python3.8/site-packages/launch/launch_service.py", line 273, in _process_one_event
    await self.__process_event(next_event)
  File "/opt/ros/foxy/lib/python3.8/site-packages/launch/launch_service.py", line 293, in __process_event
    visit_all_entities_and_collect_futures(entity, self.__context))
  File "/opt/ros/foxy/lib/python3.8/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/foxy/lib/python3.8/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/foxy/lib/python3.8/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/foxy/lib/python3.8/site-packages/launch/action.py", line 108, in visit
    return self.execute(context)
  File "/opt/ros/foxy/lib/python3.8/site-packages/launch/actions/include_launch_description.py", line 125, in execute
    launch_description = self.__launch_description_source.get_launch_description(context)
  File "/opt/ros/foxy/lib/python3.8/site-packages/launch/launch_description_source.py", line 84, in get_launch_description
    self._get_launch_description(self.__expanded_location)
  File "/opt/ros/foxy/lib/python3.8/site-packages/launch/launch_description_sources/any_launch_description_source.py", line 53, in _get_launch_description
    return get_launch_description_from_any_launch_file(location)
  File "/opt/ros/foxy/lib/python3.8/site-packages/launch/launch_description_sources/any_launch_file_utilities.py", line 56, in get_launch_description_from_any_launch_file
    raise InvalidLaunchFileError(extension, likely_errors=exceptions)
launch.invalid_launch_file_error.InvalidLaunchFileError: Caught exception when trying to load file of format [py]: cannot import name 'get_default_launch_description' from 'launch_ros' (/opt/ros/foxy/lib/python3.8/site-packages/launch_ros/__init__.py)

All the best,

Note : with a launcher looking like the one described in tutorials, it seems to work:

from launch import LaunchDescription
from launch_ros.actions import Node

from ament_index_python.packages import get_package_share_directory
import os
import sys

def generate_launch_description():
    """
    Launch file for visualizing OSM data
    """
    map_url = "file://"+os.path.join(get_package_share_directory("osm_cartography"), "tests", "prc.osm")

    return LaunchDescription([
        Node(
            package='osm_cartography',
            namespace='osm_cartography',
            executable='osm_server',
            name='osm_server',
            output="screen",
        ),
        Node(
            package='osm_cartography',
            namespace='osm_cartography',
            executable='viz_osm',
            name='viz_osm',
            output="screen",
            emulate_tty=True,
            parameters=[
                {"map_url": map_url}
            ]
        )
    ])