diff --git a/.github/workflows/snap.yaml b/.github/workflows/snap.yaml new file mode 100644 index 0000000..c0963b1 --- /dev/null +++ b/.github/workflows/snap.yaml @@ -0,0 +1,60 @@ +name: snap +on: + push: + tags: + - '*' + branches: + - foxy + pull_request: + branches: + - foxy + workflow_dispatch: + +jobs: + build: + runs-on: ubuntu-latest + outputs: + snap-file: ${{ steps.build-snap.outputs.snap }} + strategy: + matrix: + architecture: + - linux/amd64 + - linux/arm64 + steps: + - uses: actions/checkout@v2 + - uses: snapcore/action-build@v1 + id: build-snap + with: + snapcraft-args: '--enable-experimental-extensions' + + # Make sure the snap is installable + - run: | + sudo snap install --dangerous ${{ steps.build-snap.outputs.snap }} + + # @todo Do some testing with the snap + - run: | + micro-ros-agent udp4 + - uses: actions/upload-artifact@v3 + with: + name: micro-ros-agent-snap + path: ${{ steps.build-snap.outputs.snap }} + + publish: + if: github.ref == 'refs/heads/foxy' || startsWith(github.ref, 'refs/tags/') + runs-on: ubuntu-latest + needs: build + strategy: + matrix: + architecture: + - linux/amd64 + - linux/arm64 + steps: + - uses: actions/download-artifact@v3 + with: + name: micro-ros-agent-snap + path: . + - uses: snapcore/action-publish@v1 + with: + store_login: ${{ secrets.STORE_LOGIN }} + snap: ${{needs.build.outputs.snap-file}} + release: ${{ startsWith(github.ref, 'refs/tags/') && 'candidate' || 'edge'}} diff --git a/README.md b/README.md index 800b58b..fb12aa4 100644 --- a/README.md +++ b/README.md @@ -55,4 +55,4 @@ see the file [3rd-party-licenses.txt](3rd-party-licenses.txt). Please notice the following issues/limitations: * There is an unknown issue when dealing with serial ports shared with the micro-ROS agent running inside a Docker. Sometimes it works with a remarkable packet loss. -* There is an known issues with serial port communication on micro-ros-agent snap version. It is recommended to use the dockerized version or build it from source. \ No newline at end of file + diff --git a/snap/hooks/configure b/snap/hooks/configure index d51603c..d0729c7 100755 --- a/snap/hooks/configure +++ b/snap/hooks/configure @@ -101,4 +101,4 @@ case "$daemon" in echo "'$daemon' is not a valid boolean for daemon" >&2 return 1 ;; -esac \ No newline at end of file +esac diff --git a/snap/local/fastdds_no_shared_memory.xml b/snap/local/fastdds_no_shared_memory.xml new file mode 100644 index 0000000..a4f0105 --- /dev/null +++ b/snap/local/fastdds_no_shared_memory.xml @@ -0,0 +1,19 @@ + + + + + CustomUdpTransport + UDPv4 + + + + + + + CustomUdpTransport + + + false + + + diff --git a/snap/local/micro-ros-agent-daemon b/snap/local/micro-ros-agent-daemon index 1ec437e..32dc832 100755 --- a/snap/local/micro-ros-agent-daemon +++ b/snap/local/micro-ros-agent-daemon @@ -24,4 +24,4 @@ if [ -n "$p2p_port" ]; then set -- --p2p "$p2p_port" "$@" fi -exec "$SNAP/lib/micro_ros_agent/micro_ros_agent" "$transport" "$@" +exec "$SNAP/opt/ros/snap/lib/micro_ros_agent/micro_ros_agent" "$transport" "$@" diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml index 21a0138..8adeb60 100644 --- a/snap/snapcraft.yaml +++ b/snap/snapcraft.yaml @@ -4,9 +4,7 @@ version: git summary: Bridge between Micro ROS client applications and ROS 2 description: | Micro-ROS, whose default implementation is based on eProsima's - Micro XRCE-DDS middleware, is composed of client applications - which interact with the ROS 2 world by means of an Agent. - This agent keeps tracks of the entities created by means of + Micro XRCE-DDS middleware, is composed of client applications which interact with the ROS 2 world by means of an Agent. This agent keeps tracks of the entities created by means of requests performed on the microcontroller side, and uses them to communicate with the ROS 2 dataspace. @@ -71,16 +69,6 @@ description: | $ snap set micro-ros-agent device="device path" - If connecting the micro-ROS Agent using an IP based connection mode, - that is, `udp4`, `udp6`, `tcp4` or `tcp6`, care must be taken to - connect first the `micro-ros-agent-shm-netplug` plug. - This is due to the fact that ROS 2 Foxy is using Fast-DDS as the - default DDS middleware, and Fast-DDS comes with *shared memory transport*. - Thus, this plugin must be enabled, in order to gain access to the - `/dev/shm` folder from the snap image, prior to running it: - - $ sudo snap connect micro-ros-agent:micro-ros-agent-shm-netplug - When using the snap with a serial device, some steps need to be taken in order to establish a successful connection: @@ -121,21 +109,20 @@ architectures: - build-on: ppc64el parts: - uros-agent: plugin: colcon source: . - override-build: | - set +u - git clone https://github.com/eProsima/Micro-XRCE-DDS-Agent.git -b $ROS_DISTRO - git clone https://github.com/eProsima/Micro-CDR.git -b $ROS_DISTRO - git clone https://github.com/micro-ROS/micro_ros_msgs.git -b $ROS_DISTRO - git clone https://github.com/micro-ROS/rosidl_typesupport_microxrcedds.git -b $ROS_DISTRO - git clone https://github.com/micro-ROS/rmw-microxrcedds.git -b $ROS_DISTRO - git clone https://github.com/micro-ROS/micro-ROS-Agent.git -b $ROS_DISTRO - . /opt/ros/$ROS_DISTRO/setup.sh - colcon build --merge-install --install-base $SNAPCRAFT_PRIME --cmake-args "-DUAGENT_BUILD_EXECUTABLE=OFF -DUAGENT_USE_SYSTEM_FASTDDS=ON" --packages-up-to micro_ros_agent - set -u + colcon-cmake-args: + - -DMICROROSAGENT_SUPERBUILD=ON + - --cmake-force-configure + override-pull: | + snapcraftctl pull + + version="$(git describe --always --tags| sed -e 's/^v//;s/-/+git/;y/-/./')" + [ -n "$(echo $version | grep "+git")" ] && grade=devel || grade=stable + snapcraftctl set-version "$version" + snapcraftctl set-grade "$grade" + build-packages: [make, gcc, g++] stage-packages: [ros-foxy-ros2launch] @@ -143,26 +130,22 @@ parts: plugin: dump source: snap/local/ organize: - '*': usr/bin/ - -plugs: - micro-ros-agent-shm-netplug: - interface: system-files - allow-auto-connection: true - write: - - /dev/shm + 'micro-ros-agent-daemon': usr/bin/ + 'fastdds_no_shared_memory.xml': usr/share/ apps: micro-ros-agent: - command: lib/micro_ros_agent/micro_ros_agent + command: opt/ros/snap/lib/micro_ros_agent/micro_ros_agent environment: - LD_LIBRARY_PATH: "$LD_LIBRARY_PATH:$SNAP/lib" - plugs: [network, network-bind, serial-port, micro-ros-agent-shm-netplug] + FASTRTPS_DEFAULT_PROFILES_FILE: ${SNAP}/usr/share/fastdds_no_shared_memory.xml + plugs: [network, network-bind, serial-port] extensions: [ros2-foxy] daemon: command: usr/bin/micro-ros-agent-daemon environment: - LD_LIBRARY_PATH: "$LD_LIBRARY_PATH:$SNAP/lib" + FASTRTPS_DEFAULT_PROFILES_FILE: ${SNAP}/usr/share/fastdds_no_shared_memory.xml daemon: simple - plugs: [network, network-bind, serial-port, micro-ros-agent-shm-netplug] + plugs: [network, network-bind, serial-port] + extensions: [ros2-foxy] +