ROS2 Colcon Plugin - Can't depend on packages across parts

I am working on a front-end to ros project that use the ros2 qml plugin. Here is my problem. I have dependancy on another github project that contain two ros packages. As I have to build this snap with --use-lxd I need to add each package as a part and then go from there. I just can’t figure out how to resolve the rosdep.

snapcraft.yaml

base: core20 # the base snap is the execution environment for this snap
version: '0.1' # just for humans, typically '1.2+git' or '1.3.2'
  For more information see README.md
grade: stable # must be 'stable' to release into candidate/stable channels
confinement: strict # use 'strict' once you have the right plugs and slots

parts:
  ros2-babel-fish-test-msgs:
    source: https://github.com/LOEWE-emergenCity/ros2_babel_fish.git
    source-subdir: ros2_babel_fish_test_msgs
    plugin: colcon
    build-packages: 
      - make
      - gcc
      - g++
      - ros-foxy-rclcpp
      - ros-foxy-rcpputils
      - ros-foxy-action-tutorials-interfaces
    stage-packages:  
      - ros-foxy-ros2run
      - ros-foxy-ros2launch

  ros2-babel-fish:
    source: https://github.com/LOEWE-emergenCity/ros2_babel_fish.git
    source-subdir: ros2_babel_fish
    plugin: colcon
    colcon-packages:
      - ros2_babel_fish_test_msgs
    build-packages: 
      - make
      - gcc
      - g++
      - ros-foxy-rclcpp
      - ros-foxy-rcpputils
      - ros-foxy-action-tutorials-interfaces
    stage-packages:  
      - ros-foxy-ros2run
      - ros-foxy-ros2launch
    after:
      - ros2-babel-fish-test-msgs

  qml-ros2-plugin:
    source: https://github.com/StefanFabian/qml_ros2_plugin.git
    plugin: colcon
    build-packages: 
      - make
      - gcc
      - g++
      - ros-foxy-rclcpp
      - ros-foxy-rclcpp-action
      - ros-foxy-image-transport
      - libqt5core5a
      - libqt5multimedia5
      - libqt5qml5
      - libqt5quick5
      - qtbase5-dev
      - qtdeclarative5-dev
      - qtmultimedia5-dev
    colcon-packages:
      - ros2_babel_fish
      - ros2_babel_fish_test_msgs
    stage-packages:  
      - ros-foxy-ros2run
      - ros-foxy-ros2launch
    after: [ros2-babel-fish] 

Resulting error

updated cache in /root/.ros/rosdep/sources.cache
+ rosdep install --default-yes --ignore-packages-from-source --from-paths /root/parts/ros2-babel-fish/src/ros2_babel_fish
ERROR: the following packages/stacks could not have their rosdep keys resolved
to system dependencies:
ros2_babel_fish: Cannot locate rosdep definition for [ros2_babel_fish_test_msgs]
Failed to build 'ros2-babel-fish'.

Recommended resolution:
Check the build logs and ensure the part's configuration and sources are correct.

Hi @PKTorrild,

A quick look at rosdep distribution file for foxy shows that indeed these packages are not released, thus rosdep cannot find them there. However you are building them from source. The problem here is that you are building them in separate parts and parts are isolated from one another. Thus they are not (ROS) sourced from one another and ultimately rosdep fails to find the local package.

You could try here to have one single part that builds all these packages at once. Something along the lines of,

ros2-workspace:
  source: .
  plugin: colcon
  build-packages:
    - git
    ...
  override-pull: |
      snapcraftctl pull
      git clone https://github.com/LOEWE-emergenCity/ros2_babel_fish.git
      git clone https://github.com/StefanFabian/qml_ros2_plugin.git
1 Like

Thank you for taking the time to look at the problem!