1
$\begingroup$

I am trying to get my ROS2 project into working order. Here are the details of my setup:
Building in docker based on osrf/ros:humble-desktop-full
my package is laid out like this

├── CMakeLists.txt
├── LICENSE
├── launch
│   ├── __pycache__
│   │   └── brobot.launch.cpython-310.pyc
│   └── brobot.launch.py
├── package.xml
├── setup.cfg
├── setup.py
└── src
    ├── brobot_image_acquisition.py
    ├── config
    │   └── camera_parameters.yaml
    ├── control_panel.py
    ├── joy_driver2.py
    ├── roboclaw_driver.py
    ├── spinPics
    │   ├── leftCam
    │   └── rightCam
    └── utils
        └── roboclaw_python
            ├── __pycache__
            │   ├── roboclaw.cpython-310.pyc
            │   └── roboclaw_3.cpython-310.pyc
            ├── read_motor_data.py
            ├── roboclaw.py
            ├── roboclaw.pyc
            ├── roboclaw_3.py
            ├── roboclaw_bareminimum.py
            ├── roboclaw_mixedpwm.py
            ├── roboclaw_mixedspeedaccel.py
            ├── roboclaw_position.py
            ├── roboclaw_read.py
            ├── roboclaw_readeeprom.py
            ├── roboclaw_readversion.py
            ├── roboclaw_simplepwm.py
            ├── roboclaw_speed.py
            ├── roboclaw_speedaccel.py
            ├── roboclaw_speedacceldistance.py
            ├── roboclaw_speeddistance.py
            └── roboclaw_writeeeprom.py

10 directories, 31 files

To give a general description, this robot is supposed to be driven through a corn field and take pictures of the nodal roots just above the soil. Anyways I took these steps:

  1. build a clean workspace
mkdir -p ros2_ws/src
cd ros2_ws && colcon build
  1. copied in the brobot package

Now the Workspace looks like this:

.
├── build
│   └── COLCON_IGNORE
├── install
│   ├── COLCON_IGNORE
│   ├── _local_setup_util_ps1.py
│   ├── _local_setup_util_sh.py
│   ├── local_setup.bash
│   ├── local_setup.ps1
│   ├── local_setup.sh
│   ├── local_setup.zsh
│   ├── setup.bash
│   ├── setup.ps1
│   ├── setup.sh
│   └── setup.zsh
├── log
│   ├── COLCON_IGNORE
│   ├── build_2024-02-02_19-13-08
│   │   ├── events.log
│   │   └── logger_all.log
│   ├── latest -> latest_build
│   └── latest_build -> build_2024-02-02_19-13-08
└── src
    └── brobot
        ├── CMakeLists.txt
        ├── LICENSE
        ├── launch
        │   ├── __pycache__
        │   │   └── brobot.launch.cpython-310.pyc
        │   └── brobot.launch.py
        ├── package.xml
        ├── setup.cfg
        ├── setup.py
        └── src
            ├── brobot_image_acquisition.py
            ├── config
            │   └── camera_parameters.yaml
            ├── control_panel.py
            ├── joy_driver2.py
            ├── roboclaw_driver.py
            ├── spinPics
            │   ├── leftCam
            │   └── rightCam
            └── utils
                └── roboclaw_python
                    ├── __pycache__
                    │   ├── roboclaw.cpython-310.pyc
                    │   └── roboclaw_3.cpython-310.pyc
                    ├── read_motor_data.py
                    ├── roboclaw.py
                    ├── roboclaw.pyc
                    ├── roboclaw_3.py
                    ├── roboclaw_bareminimum.py
                    ├── roboclaw_mixedpwm.py
                    ├── roboclaw_mixedspeedaccel.py
                    ├── roboclaw_position.py
                    ├── roboclaw_read.py
                    ├── roboclaw_readeeprom.py
                    ├── roboclaw_readversion.py
                    ├── roboclaw_simplepwm.py
                    ├── roboclaw_speed.py
                    ├── roboclaw_speedaccel.py
                    ├── roboclaw_speedacceldistance.py
                    ├── roboclaw_speeddistance.py
                    └── roboclaw_writeeeprom.py

18 directories, 46 files
  1. now I build the workspace again
cd ros2_ws
source install/setup.sh
colcon build
source install/setup.sh

Package builds fine. but when I try to run ros2 launch brobot brobot.launch.py I get this error: file 'brobot.launch.py' was not found in the share directory of package 'brobot' which is at '/source/ros2_ws/install/brobot/share/brobot'

I will include my full package.xml, setup.py, and setup.cfg at the bottom of this post so that you can view. I'm assuming I am making a mistake in my setup.py in the data_files entry:

data_files=[
        # Install marker file in the package index
        ('share/ament_index/resource_index/packages', ['resource/' + package_name]),
        # Include our package.xml file
        (os.path.join('share', package_name), ['package.xml']),
        # Include all launch files.
        ('share/' + package_name, ['launch/brobot.launch.py']),
    ],

I have tried a number of ways to change it, including:

  1. writing out the absolute path of the launch files in my package and the destination ros seems to be looking in
  2. the standard entry that is given in the tutorial (os.path.join('share', package_name, 'launch'), glob(os.path.join('launch', '*.launch.py')))
  3. This other entry that comes from the launch tutorials (os.path.join('share', package_name, 'launch'), glob(os.path.join('launch', '*launch.[pxy][yma]*')))

Is there something I'm missing? How do I get the launch file from ros2_ws/src/brobot/ launch into the proper place?

Thanks in advance for any help! I'll be forced to use `ros2 launch until then.

Code Files:

setup.py

import os
from glob import glob
from setuptools import setup

package_name = 'brobot'

setup(
    name=package_name,
    version='0.1.9',
    # Packages to export
    packages=[package_name],
    # Files we want to install, specifically launch files
    data_files=[
        # Install marker file in the package index
        ('share/ament_index/resource_index/packages', ['resource/' + package_name]),
        # Include our package.xml file
        (os.path.join('share', package_name), ['package.xml']),
        # Include all launch files.
        ('share/' + package_name, ['launch/brobot.launch.py']),
    ],
    # This is important as well
    install_requires=['setuptools'],
    zip_safe=True,
    author='kopiousKaro',
    author_email='[email protected]',
    maintainer='KopiousKarp',
    maintainer_email='[email protected]',
    keywords=['brace', 'root'],
    classifiers=[
        'Intended Audience :: Developers',
        'License :: Apache 2.0',
        'Programming Language :: Python',
        'Topic :: Agricultural Robotics',
    ],
    description='Brace root phenotyping robot',
    license='Apache 2.0',
    # Like the CMakeLists add_executable macro, you can add your python
    # scripts here.
    entry_points={
        'console_scripts': [
            'my_script = my_package.my_script:main'
        ],
    },
)

setup.cfg

[develop]
script_dir=$base/lib/brobot
[install]
install_scripts=$base/lib/brobot

package.xml

<?xml version="1.0"?>
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
<package format="3">
  <name>brobot</name>
  <version>0.1.9</version>
  <description>Brace root phenotyping robot</description>
  <maintainer email="[email protected]">root</maintainer>
  <license>Apache-2.0</license>

  <buildtool_depend>ament_cmake</buildtool_depend>

  <depend>spinnaker_camera_driver</depend>

  <test_depend>ament_lint_auto</test_depend>
  <test_depend>ament_lint_common</test_depend>

  <export>
    <build_type>ament_cmake</build_type>
  </export>
</package>

CMakeLists.txt

cmake_minimum_required(VERSION 3.8)
project(brobot)

if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
  add_compile_options(-Wall -Wextra -Wpedantic)
endif()

# find dependencies
find_package(ament_cmake REQUIRED)
find_package(spinnaker_camera_driver REQUIRED)

if(BUILD_TESTING)
  find_package(ament_lint_auto REQUIRED)
  # the following line skips the linter which checks for copyrights
  # comment the line when a copyright and license is added to all source files
  set(ament_cmake_copyright_FOUND TRUE)
  # the following line skips cpplint (only works in a git repo)
  # comment the line when this package is in a git repo and when
  # a copyright and license is added to all source files
  set(ament_cmake_cpplint_FOUND TRUE)
  ament_lint_auto_find_test_dependencies()
endif()

ament_package()
$\endgroup$

1 Answer 1

1
$\begingroup$

As you can see, no files from your package seem to be installed in the install folder. This is because your package.xml specifies relying on ament_cmake, and thus only the CMakeLists.txt file is used to compile / install your package.

The two Python-related files, setup.cfg and setup.py, are never read by colcon, and could (should) be deleted without colcon complaining.

I would advise using CMake indeed, but then you have to add the install steps to CMakeLists.txt. A reason to use CMake even if you only install files is that it supports symbolic install while Python does not.

You can find in any CMake-based ROS 2 package, what the syntax is to install files or directories.

$\endgroup$

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.