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

How can I use yaml config files without having to build after changes in ROS2?

asked 2022-06-30 06:05:15 -0500

bartonp gravatar image

How can I use yaml config files without having to rebuild after changing the config file?

I am looking for a way to have the same behaviour as in ROS1 where config files could be changed without having to rebuild the package. According to this answer, it should be possible with the symlink install. However, I haven't been able to achieve this. Additionally, it suggests to use global paths rather than install paths, but I would like to keep my config files within the package they belong to.

My current setup and method is the following on ROS2 foxy Linux:

Directory structure:

  • my_package/
    • my_package/
    • config/
      • my_package.yaml
    • launch/
    • resource/
    • __init__.py
    • package.xml
    • setup.cfg
    • setup.py

setup.cfg:

[develop]
script-dir=$base/lib/caterra_motor_controller
[install]
install-scripts=$base/lib/caterra_motor_controller

setup.py:

## ! DO NOT MANUALLY INVOKE THIS setup.py, USE CATKIN INSTEAD

from setuptools import setup
import os
from glob import glob

package_name = 'my_package'

setup(
    name=package_name,
    version='0.0.0',
    packages=[package_name],
    data_files=[
        ('share/ament_index/resource_index/packages',
         ['resource/' + package_name]),
        ('share/' + package_name, ['package.xml']),
        (os.path.join('share', package_name, 'launch'), glob('launch/*')),
        (os.path.join('share', package_name, 'config'), glob('config/*.yaml')),
    ],
    install_requires=['setuptools'],
    zip_safe=True,
    maintainer='xxx',
    maintainer_email='xxx',
    description='xxx',
    license='TODO: License declaration',
    tests_require=['pytest'],
    entry_points={
        'console_scripts': [
            'node = my_package.my_node:main'
        ],
    },
)

I then compile the code with:

colcon build --symlink-install

This works fine for python files, but the yaml config files are still only updated after a rebuild.

What am I doing wrong?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2022-07-18 13:51:00 -0500

updated 2022-07-18 14:14:01 -0500

This is a bug with the build tools.

To verify, I created a ament_python and ament_cmake package as per the tutorials and did a colcon build --symlink-install. Looking at the install/ directory, the ament_cmake package has its launch files symlinked to the ones in my source tree, but for the ament_python package, there is a copy of the launch. In other words when you call colcon build --symlink-install, your .yaml files are just copied to the right place in the install/ directory.

Here are some other issue reports from github with the same complaint: https://github.com/colcon/colcon-core.... Apparently it has to do with the way ament_pythonhandles the "symlinking" (it does not actually use symlinks): https://github.com/colcon/colcon-core.... You can join the conversation there and try to resolve the issue if you are interested.

You could use ament_cmake instead of ament_python since this seems to be handling the linking in the expected way. Otherwise, depending on your needs, you could try to manually symlink the files in the install directory as a workaround. Take note that this will break every time you call colcon build.

edit flag offensive delete link more

Question Tools

Stats

Asked: 2022-06-30 06:05:15 -0500

Seen: 963 times

Last updated: Jul 18 '22