0
$\begingroup$

Rosanswers logo

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?


Originally posted by bartonp on ROS Answers with karma: 3 on 2022-06-30

Post score: 0

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

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/issues/407. Apparently it has to do with the way ament_python handles the "symlinking" (it does not actually use symlinks): https://github.com/colcon/colcon-core/issues/482. 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.


Originally posted by vecf with karma: 26 on 2022-07-18

This answer was ACCEPTED on the original site

Post score: 1

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.