Ask Your Question
0

Launching a simple launchfile on ros2:foxy failed

asked 2021-01-10 03:08:30 -0600

I am trying to launch a simple launch file from ros2 foxy. The command is executed on a docker machine. I got the following error messages. Why?

root@9da72d8e03df:~# ros2 launch launch_testing_ros talker_listener_launch_test.py

[INFO] [launch]: All log files can be found below /root/.ros/log/2021-01-10-08-55-55-547178-9da72d8e03df-6260
[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 64, in get_launch_description_from_python_launch_file
    raise InvalidPythonLaunchFileError(
launch.launch_description_sources.python_launch_file_utilities.InvalidPythonLaunchFileError: launch file at '/opt/ros/foxy/share/launch_testing_ros/examples/talker_listener_launch_test.py' does not contain the required function 'generate_launch_description()'

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]: launch file at '/opt/ros/foxy/share/launch_testing_ros/examples/talker_listener_launch_test.py' does not contain the required function 'generate_launch_description()'
edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
0

answered 2021-04-19 00:25:58 -0600

achille gravatar image

In my case this was happening because I had two workspaces and was editing the file in the wrong workspace.

edit flag offensive delete link more
0

answered 2021-01-10 06:33:44 -0600

gvdhoorn gravatar image

updated 2021-01-10 06:33:55 -0600

You've probably checked, but:

launch.launch_description_sources.python_launch_file_utilities.InvalidPythonLaunchFileError: launch file at '/opt/ros/foxy/share/launch_testing_ros/examples/talker_listener_launch_test.py' does not contain the required function 'generate_launch_description()'

does /opt/ros/foxy/share/launch_testing_ros/examples/talker_listener_launch_test.py contain the required generate_launch_description()?

edit flag offensive delete link more

Comments

Thanks Gijs. The file did not contain that function. It has a function of a similar name generate_test_description().

Zhoulai Fu gravatar image Zhoulai Fu  ( 2021-01-10 14:37:44 -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

Stats

Asked: 2021-01-10 03:08:30 -0600

Seen: 511 times

Last updated: Apr 19