Hello together, I am trying to snap ros2 foxy as a stand-alone ros-base. Iβve done that by building ros2 foxy using the colcon plugin and snapping the install folder, using the following snapcraft file.
name: ros-base
version: '0.1'
summary: Basic ROS2 listener component
description: |
Basic ROS2 listener component based on core20
grade: stable
confinement: strict
base: core20
parts:
dump:
plugin: colcon
stage-packages: [
ros-foxy-ros2launch,
ros-foxy-ros-core,]
build-environment:
- ROS_VERSION: '2'
- ROS_DISTRO: foxy
slots:
ros-base:
interface: content
content: executables
read: [/]
private: false
After that I tried to build an overlay snap (simple Hello World talker node) using the following snapcraft file,
name: overlay
version: '0.1'
summary: Basic ROS2 listener component
description: |
Basic ROS2 listener component based on core20
grade: stable
confinement: strict
base: core20
parts:
dump:
plugin: colcon
source: src
build-packages: [make, gcc, g++]
stage-packages: [ros-foxy-ros2launch, ros-foxy-common-interfaces]
override-build: |
snapcraftctl build
build-environment:
- ROS_VERSION: '2'
- ROS_DISTRO: foxy
wrapper-scripts:
plugin: dump
source: ./wrappers/
organize:
./motion_joint.wrapper.sh : usr/bin/ros2-custom-ws
apps:
app4:
command: usr/bin/ros2-custom-ws
plugs:
ros-base:
interface: content
content: executables
target: $SNAP/mohamed
private: false
My wrapper file looks like that:
#!/bin/bash
ROS_BASE=$SNAP/mohamed
export PYTHONPATH=$PYTHONPATH:$ROS_BASE/usr/lib/python3.8/dist-packages:$PYTHONPATH
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ROS_BASE/lib
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ROS_BASE/lib/
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ROS_BASE/usr/lib/$SNAPCRAFT_ARCH_TRIPLET/blas
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ROS_BASE/usr/lib/$SNAPCRAFT_ARCH_TRIPLET/lapack
source $SNAP/mohamed/opt/ros/foxy/setup.bash
$SNAP/opt/ros/snap/lib/py_pubsub/talker
After connecting both snaps slots and plugs I can run the overlay snap using the following command: overlay.app4 Howevere, when doing so, I get the following error:
/bin/bash: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
Traceback (most recent call last):
File "/snap/overlay/x1/opt/ros/snap/lib/py_pubsub/talker", line 6, in <module>
from pkg_resources import load_entry_point
File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 3254, in <module>
def _initialize_master_working_set():
File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 3237, in _call_aside
f(*args, **kwargs)
File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 3266, in _initialize_master_working_set
working_set = WorkingSet._build_master()
File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 584, in _build_master
ws.require(__requires__)
File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 901, in require
needed = self.resolve(parse_requirements(requirements))
File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 787, in resolve
raise DistributionNotFound(req, requirers)
pkg_resources.DistributionNotFound: The 'py-pubsub==0.0.0' distribution was not found and is required by the application
My workspace for my overlay ros snap looks like that:
βββ snap
β βββ snapcraft.yaml
βββ src
β βββ py_pubsub
β βββ launch
β β βββ publisher_launch.py
β βββ package.xml
β βββ py_pubsub
β β βββ __init__.py
β β βββ publisher_member_function.py
β βββ resource
β β βββ py_pubsub
β βββ setup.cfg
β βββ setup.py
β βββ test
β βββ test_copyright.py
β βββ test_flake8.py
β βββ test_pep257.py
βββ wrappers
βββ motion_joint.wrapper.sh