Malformed launch argument 'start_wall_following.launch.py'

Hi fellow ROS developer!

As described in the
“Course Project” of “ROS2 Basics in 5 Days” I have created:

  • a package named wall_follower
  • a lauch file named start_wall_following.launch.py
from launch import LaunchDescription
from launch_ros.actions import Node

def generate_launch_description():
	return LaunchDescription([
		Node(
			package='wall_follower',
			executable='wall_following',
			output='screen'),
	])

After building and launching …

source /opt/ros/foxy/setup.bash

colcon build --packages-select wall_follower

source ~/ros2_ws/install/setup.bash

ros2 launch wall_follower start_wall_following.launch.py

… I get the following error message

malformed launch argument 'start_wall_following.launch.py', expected format '<name>:=<value>'

What did I miss here?

Hi,

I don’t see anything wrong with the launch file itself, which is simple enough.

Just to check, try deleting the build/ and install install/ folder. An older incorrect configuration might be in one of those from a previous compilation:

cd ~/ros2_ws/ && rm -rf build/ install/ && colcon build && source install/setup.bash

Another thing you can try is running the node with ros2 run. If it runs, then the launch file is the issue

Thanks for your reply @roalgoal !

After applying your suggestion to delete folders build/ and install/, and again build and source, I tried running the launch file with the following prompt:

ros2 launch wall_follower start_wall_following.launch.py

This resulted in the following error message:

file 'start_wall_following.launch.py' was not found in the share directory of package 'wall_follower' which is at '/home/user/ros2_ws/install/wall_follower/share/wall_follower'

Navigating to the location of the launch file (cd ~/ros2_ws/launch/) and making the file “start_wall_following.launch.py” executable via chmod +x did also not work to launch - same error.

How can I ensure the command “ros2 launch” searches for the launch file in the proper folder?

Here the complete terminal output as an overview.

user:~$ cd ~/ros2_ws/ && rm -rf build/ install/ &
& colcon build && source install/setup.bash
Starting >>> wall_followerFinished <<< wall_follower [11.5s]

Summary: 1 package finished [13.4s]
user:~/ros2_ws$ ros2 launch wall_follower start_w
all_following.launch.py
file 'start_wall_following.launch.py' was not fou
nd in the share directory of package 'wall_follow
er' which is at '/home/user/ros2_ws/install/wall_
follower/share/wall_follower'

That probably means that the launch file wasn’t correctly added to setup.py. That is how the system finds the file in the package.

You must compile and source again for the changes to take effect.

Thanks for the hint @roalgoal !

I tried the following but wasn’t able to add the launch file to setup.py.

  1. add path to launch file in “data_files” → see error 1
  2. instead add path in separate variable “install_launch_files” → see error 2
  3. include “install_requires” → see error 3

Any idea what I’m missing here?

Also, “colcon build” creates folders outside of ros2_ws.

setup.py

from setuptools import setup
# from setuptools import find_packages
# from setuptools import Command
# from setuptools.command.develop import develop
# from setuptools.command.install import install
# from setuptools.command.egg_info import egg_info
# from distutils.dir_util import copy_tree
# from distutils.file_util import copy_file
# from glob import glob
# from os.path import join
# import os
# import shutil
# import subprocess

package_name = 'wall_follower'

setup(
    # install_requires=[
    #     'setuptools',
    #     # 'package_dependency1',
    #     # 'package_dependency2',
    #     # other dependencies
    # ],
    name=package_name,
    version='0.0.0',
    packages=[package_name],
    # install_launch_files=[
    #     # 'path/to/launch/file1.launch.py',
    #     ('~/ros2_ws/launch/', ['start_wall_following.launch.py']), 
    # ],
    data_files=[
        ('share/ament_index/resource_index/packages',
            ['resource/' + package_name]),
        ('share/' + package_name, ['package.xml']), 
        ('~/ros2_ws/launch/', ['start_wall_following.launch.py']),
        # (os.path.join('share', package_name), 
        # glob('launch/*.launch.py')),  # added
    ],
    install_requires=['setuptools'],
    zip_safe=True,
    maintainer='user',
    maintainer_email='user@todo.todo',
    description='TODO: Package description',
    license='TODO: License declaration',
    tests_require=['pytest'],
    entry_points={
        'console_scripts': [
            'wall_following = wall_follower.wall_following:main'
        ],
    },
)

error 1

user:~$ colcon build --packages-select wall_fhollower && source ~/ros2_ws/install/setup.bashStarting >>> wall_follower                   rovide a--- stderr: wall_follower                    aunch.pyerror: can't copy 'start_wall_following.launcwall_folh.py': doesn't exist or not a regular file---Failed   <<< wall_follower [2.39s, exited witg.launchh code 1]Summary: 0 packages finished [3.07s]         h code 1  1 package failed: wall_follower
  1 package had stderr output: wall_follower

error 2

user:~$ colcon build --packages-select wall_follower && source ~/ros2_ws/install/setup.bashStarting >>> wall_follower/usr/lib/python3.8/distutils/dist.py:274: UserWarning: Unknown distribution option: 'install_launch_files'  warnings.warn(msg)--- stderr: wall_follower
/usr/lib/python3.8/distutils/dist.py:274: Use
rWarning: Unknown distribution option: 'install_launch_files'
  warnings.warn(msg)
---
Finished <<< wall_follower [2.84s]

Summary: 1 package finished [3.43s]  1 package had stderr output: wall_follower

error 3

user:~$ colcon build --packages-select wall_follower && source ~/ros2_ws/install/setup.bashStarting >>> wall_followerTraceback (most recent call last):er - 1.2s]  File "<string>", line 1, in <module>  File "/usr/lib/python3.8/distutils/core.py", line 215, in run_setup    exec(f.read(), g)
  File "<string>", line 39
SyntaxError: keyword argument repeated--- stderr: wall_follower
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/colcon
_core/executor/__init__.py", line 91, in __ca
ll__
    rc = await self.task(*args, **kwargs)  File "/usr/lib/python3/dist-packages/colcon_core/task/__init__.py", line 93, in __call__    return await task_method(*args, **kwargs)  File "/usr/lib/python3/dist-packages/colcon_ros/task/ament_python/build.py", line 51, in build    setup_py_data = get_setup_data(self.context.pkg, env)  File "/usr/lib/python3/dist-packages/colcon_core/task/python/__init__.py", line 20, in get_setup_data    return dict(pkg.metadata[key](env))  File "/usr/lib/python3/dist-packages/colcon_ros/package_identification/ros.py", line 129, in getter    return get_setup_information(
  File "/usr/lib/python3/dist-packages/colcon_python_setup_py/package_identification/python_setup_py.py", line 241, in get_setup_information
    _setup_information_cache[hashable_env] =_get_setup_information(
  File "/usr/lib/python3/dist-packages/colcon_python_setup_py/package_identification/python_setup_py.py", line 281, in _get_setup_information
    result = subprocess.run(
  File "/usr/lib/python3.8/subprocess.py", line 516, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['/usr/bin/python3', '-c', "import sys;from setuptools.extern.packaging.specifiers import SpecifierSet;from distutils.core import run_setup;dist = run_setup(    'setup.py', script_args=('--dry-run',), stop_after='config');skip_keys = ('cmdclass', 'distclass', 'ext_modules','metadata');data = {    key: value for key, value in dist.__dict__.items()     if ( not key.startswith('_') and         not callable(value) and         key not in skip_keysand         key not in dist.display_option_names    )};data['metadata'] = {    k: v for k, v in dist.metadata.__dict__.items()     if k not in ('license_files', 'provides_extras')};sys.stdout.buffer.write(repr(data).encode('utf-8'))"]' returned non-zero exit status 1.
---
Failed   <<< wall_follower [1.34s, exited with code 1]

Summary: 0 packages finished [2.00s]
  1 package failed: wall_follower
  1 package had stderr output: wall_follower
Command '['/usr/bin/python3', '-c', "import sys;from setuptools.extern.packaging.specifiers import SpecifierSet;from distutils.core import run_setup;dist = run_setup(    'setup.py', script_args=('--dry-run',), stop_after='config');skip_keys = ('cmdclass', 'distclass', 'ext_modules', 'metadata');data = {    key: value for key, value in dist.__dict__.items()   if (        not key.startswith('_') and      not callable(value) and         key not in skip_keys and         key not in dist.display_option_names    )};data['metadata'] = {   k: v for k, v in dist.metadata.__dict__.items()     if k not in ('license_files', 'provides_extras')};sys.stdout.buffer.write(repr(data).encode('utf-8'))"]' returned non-zero exit status 1.

This suggests that you ran colcon build outside ros2_ws. You can delete those folders with

cd ~
rm -rf build/ install/ log/
cd ros2_ws
rm -rf build/ install/ log/

As for adding the launch file to setup.py, you have done it incorrectly in this case. Please do it according to the example in the course.

Then try compiling again, from the ros2_ws directory.

1 Like

Thanks for the hint @bayodesegun !
It works now :smile:

1 Like

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.