ROS2 Colcon Plugin - Failed to load entry point

Hello,
I’m new to snaps and I would like to get some experience with it. Therefore, I’m trying to turn a Raspberry Pi into a small robot using ROS2.

I created the following snap to test on my laptop first (the complete code can be found here):

name: ros2-pibot-motor-fabolhak
version: '0.1'
summary: ROS2 Motor module for my PiBot
description: |
  This package provides the hardware driver to the PiBots motor.

confinement: devmode
base: core18

parts:
  ros2-motor-driver:
    plugin: colcon
    source: .
    source-branch: master
    colcon-rosdistro: dashing
    colcon-source-space: pibot_motor
    stage-packages: [ros-dashing-ros-core,python3-numpy,libatlas3-base,libblas3] 


apps:
  run:
    command: opt/ros/dashing/bin/ros2 run ros2_pibot_motor service
    plugs:
       - network
       - network-bind

architectures:
  - build-on: amd64

It builds successfully, I can run it and send a service request to the ROS2 node successfully. However, it displays some error messages (see below) when starting the snap. For some reason numpy is not finding the libblas.so.3, although it is installed as a stage package.

ros@vm:~/Documents/ros2_ws/src/ros2_pibot_motor$ ros2-pibot-motor-fabolhak.run 
Failed to load entry point 'info': 
Importing the multiarray numpy extension module failed.  Most
likely you are trying to import a failed build of numpy.
If you're working with a numpy git repo, try `git clean -xdf` (removes all
files not under version control).  Otherwise reinstall numpy.

Original error was: libblas.so.3: cannot open shared object file: No such file or directory

Failed to load entry point 'list': 
Importing the multiarray numpy extension module failed.  Most
likely you are trying to import a failed build of numpy.
If you're working with a numpy git repo, try `git clean -xdf` (removes all
files not under version control).  Otherwise reinstall numpy.

Original error was: libblas.so.3: cannot open shared object file: No such file or directory

Failed to load entry point 'send_goal': 
Importing the multiarray numpy extension module failed.  Most
likely you are trying to import a failed build of numpy.
If you're working with a numpy git repo, try `git clean -xdf` (removes all
files not under version control).  Otherwise reinstall numpy.

Original error was: libblas.so.3: cannot open shared object file: No such file or directory

Failed to load entry point 'show': 
Importing the multiarray numpy extension module failed.  Most
likely you are trying to import a failed build of numpy.
If you're working with a numpy git repo, try `git clean -xdf` (removes all
files not under version control).  Otherwise reinstall numpy.

Original error was: libblas.so.3: cannot open shared object file: No such file or directory

Failed to load entry point 'call': 
Importing the multiarray numpy extension module failed.  Most
likely you are trying to import a failed build of numpy.
If you're working with a numpy git repo, try `git clean -xdf` (removes all
files not under version control).  Otherwise reinstall numpy.

Original error was: libblas.so.3: cannot open shared object file: No such file or directory

Failed to load entry point 'echo': 
Importing the multiarray numpy extension module failed.  Most
likely you are trying to import a failed build of numpy.
If you're working with a numpy git repo, try `git clean -xdf` (removes all
files not under version control).  Otherwise reinstall numpy.

Original error was: libblas.so.3: cannot open shared object file: No such file or directory

Failed to load entry point 'pub': 
Importing the multiarray numpy extension module failed.  Most
likely you are trying to import a failed build of numpy.
If you're working with a numpy git repo, try `git clean -xdf` (removes all
files not under version control).  Otherwise reinstall numpy.

Original error was: libblas.so.3: cannot open shared object file: No such file or directory

[INFO] [motor]: Trigger Motor!

The output of snappy-debug is:

~$ sudo snappy-debug
INFO: Following '/var/log/syslog'. If have dropped messages, use:
INFO: $ sudo journalctl --output=short --follow --all | sudo snappy-debug
kernel.printk_ratelimit = 0
= AppArmor =
Time: Sep 23 13:09:44
Log: apparmor="ALLOWED" operation="open" profile="snap.ros2-pibot-motor-fabolhak.run" name="/proc/2866/mounts" pid=2866 comm="python3" requested_mask="r" denied_mask="r" fsuid=1000 ouid=1000
File: /proc/2866/mounts (read)
Suggestions:
* adjust program to not access '@{PROC}/@{pid}/mounts'
* add one of 'mount-observe, network-control' to 'plugs'

It turns out some searching for the correct terms gives some useful results:


I will investigate further.

I got it working by adding two links manually in the prime step:

name: ros2-pibot-motor-fabolhak
version: '0.1'
summary: ROS2 Motor module for my PiBot
description: |
  This package provides the hardware driver to the PiBots motor.

confinement: devmode
base: core18

parts:
  ros2-motor-driver:
    plugin: colcon
    source: .
    source-branch: master
    colcon-rosdistro: dashing
    colcon-source-space: pibot_motor
    stage-packages: [ros-dashing-ros-core,libblas3,liblapack3]
    override-prime: | 
      snapcraftctl prime
      cd $SNAPCRAFT_PRIME/usr/lib/$SNAPCRAFT_ARCH_TRIPLET
      ln -s blas/libblas.so.3 libblas.so.3
      ln -s lapack/liblapack.so.3 liblapack.so.3



apps:
  run:
    command: opt/ros/dashing/bin/ros2 run ros2_pibot_motor service
    plugs:
       - network
       - network-bind

architectures:
  - build-on: amd64

an alternative would be this:

name: ros2-pibot-motor-fabolhak
version: '0.1'
summary: ROS2 Motor module for my PiBot
description: |
  This package provides the hardware driver to the PiBots motor.

confinement: strict
base: core18

parts:
  ros2-motor-driver:
    plugin: colcon
    source: .
    source-branch: gpio
    colcon-rosdistro: dashing
    colcon-source-space: pibot_motor
    stage-packages: [ros-dashing-ros-core,libblas3,liblapack3]
      
  gpio-lib:
    plugin: python
    python-version: python3
    python-packages: [RPi.GPIO]

apps:
  run:
    command: opt/ros/dashing/bin/ros2 run ros2_pibot_motor service
    environment: 
      LD_LIBRARY_PATH: "$LD_LIBRARY_PATH:$SNAP/usr/lib/$SNAPCRAFT_ARCH_TRIPLET/blas:$SNAP/usr/lib/$SNAPCRAFT_ARCH_TRIPLET/lapack"
    plugs:
       - network
       - network-bind
       - gpio-memory-control

architectures:
  - build-on: arm64
1 Like