From 935338455f114c15bca1a244b09a9a71826879a6 Mon Sep 17 00:00:00 2001 From: artivis Date: Thu, 24 Aug 2023 19:34:31 +0200 Subject: [PATCH 01/13] add snap packaging Signed-off-by: artivis --- snap/hooks/configure | 64 +++++++++++ snap/hooks/install | 3 + snap/local/launch.sh | 37 +++++++ snap/local/reset_config.sh | 22 ++++ snap/snapcraft.yaml | 218 +++++++++++++++++++++++++++++++++++++ 5 files changed, 344 insertions(+) create mode 100644 snap/hooks/configure create mode 100644 snap/hooks/install create mode 100755 snap/local/launch.sh create mode 100755 snap/local/reset_config.sh create mode 100644 snap/snapcraft.yaml diff --git a/snap/hooks/configure b/snap/hooks/configure new file mode 100644 index 0000000..4c608ad --- /dev/null +++ b/snap/hooks/configure @@ -0,0 +1,64 @@ +#!/bin/bash -e + +# Here we can assert that the parameters value set by the user are proper. + +# Get the parameters values. +# They may be 'unset' as per the install hook. +port="$(snapctl get port)" +address="$(snapctl get address)" +tls="$(snapctl get tls)" +certfile="$(snapctl get certfile)" +keyfile="$(snapctl get keyfile)" +topic_whitelist="$(snapctl get topic-whitelist)" +param_whitelist="$(snapctl get param-whitelist)" +service_whitelist="$(snapctl get service-whitelist)" +client_topic_whitelist="$(snapctl get client-topic-whitelist)" +min_qos_depth="$(snapctl get min-qos-depth)" +max_qos_depth="$(snapctl get max-qos-depth)" +num_threads="$(snapctl get num-threads)" +send_buffer_limit="$(snapctl get send-buffer-limit)" +use_sim_time="$(snapctl get use-sim-time)" +capabilities="$(snapctl get capabilities)" +include_hidden="$(snapctl get include-hidden)" +asset_uri_allowlist="$(snapctl get asset-uri-allowlist)" + +# If the parameter has been explicitely set by the user +if [ -n "${port}" ]; then + # Check that it is a valid value + if ! expr "${port}" : '^[0-9]\+$' > /dev/null; then + logger -t ${SNAP_NAME} "'${opt}' is not a valid port value." + echo "'${port}' is not a valid port value" >&2 + return 1 + fi +fi + +for opt in max_qos_depth num_threads send_buffer_limit; do + if [ -n "${!opt}" ]; then + # Check that it is a valid value + if ! expr "${!opt}" : '^[0-9]\+$' > /dev/null; then + logger -t ${SNAP_NAME} "'${!opt}' is not a valid value for ${opt}." + echo "'${!opt}' is not a valid value for ${opt}." >&2 + return 1 + fi +fi +done + +for opt in tls include_hidden use_sim_time; do + if [ -n "${!opt}" ]; then + case "${!opt}" in + true) ;; + false) ;; + *) + logger -t ${SNAP_NAME} "'${!opt}' is not a valid boolean for ${opt}. Please use 'true' or 'false'." + echo "'${!opt}' is not a valid boolean for ${opt}. Please use 'true' or 'false'." >&2 + return 1 + ;; + esac + fi +done + +# @todo assert the rest of the parameters. + +# Service was already enabled, just restart it +# to make sure the new config values are picked up +snapctl restart ${SNAP_NAME}.${SNAP_NAME} 2>&1 || true diff --git a/snap/hooks/install b/snap/hooks/install new file mode 100644 index 0000000..1f7cab8 --- /dev/null +++ b/snap/hooks/install @@ -0,0 +1,3 @@ +#!/bin/sh -e + +. $SNAP/usr/bin/reset_config.sh diff --git a/snap/local/launch.sh b/snap/local/launch.sh new file mode 100755 index 0000000..48d75ed --- /dev/null +++ b/snap/local/launch.sh @@ -0,0 +1,37 @@ +#!/usr/bin/sh -e + +LAUNCH_OPTIONS="" + +OPTIONS="port +address +tls +certfile +keyfile +topic-whitelist +param-whitelist +service-whitelist +client-topic-whitelist +min-qos-depth +max-qos-depth +num-threads +send-buffer-limit +use-sim-time +capabilities +include-hidden +asset-uri-allowlist" + +for OPTION in ${OPTIONS}; do + VALUE="$(snapctl get ${OPTION})" + if [ -n "${VALUE}" ]; then + LAUNCH_OPTIONS+="${OPTION}:=${VALUE} " + fi +done + +# Replace '-' with '_' +LAUNCH_OPTIONS=$(echo ${LAUNCH_OPTIONS} | tr - _) + +if [ "${LAUNCH_OPTIONS}" ]; then + logger -t ${SNAP_NAME} "Running with options: ${LAUNCH_OPTIONS}" +fi + +ros2 launch foxglove_bridge foxglove_bridge_launch.xml ${LAUNCH_OPTIONS} diff --git a/snap/local/reset_config.sh b/snap/local/reset_config.sh new file mode 100755 index 0000000..bdb03c3 --- /dev/null +++ b/snap/local/reset_config.sh @@ -0,0 +1,22 @@ +#!/bin/sh -e + +# All parameters are unset +# leaving the default values up to the launchfile. + +snapctl set port! +snapctl set address! +snapctl set tls! +snapctl set certfile! +snapctl set keyfile! +snapctl set topic_whitelist! +snapctl set param_whitelist! +snapctl set service_whitelist! +snapctl set client_topic_whitelist! +snapctl set min_qos_depth! +snapctl set max_qos_depth! +snapctl set num_threads! +snapctl set send_buffer_limit! +snapctl set use_sim_time! +snapctl set capabilities! +snapctl set include_hidden! +snapctl set asset_uri_allowlist! diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml new file mode 100644 index 0000000..9a86f98 --- /dev/null +++ b/snap/snapcraft.yaml @@ -0,0 +1,218 @@ +name: foxglove-bridge +adopt-info: foxglove-bridge +license: MIT +summary: The foxglove-bridge snap +description: | + The foxglove-bridge. + +grade: stable +confinement: strict +base: core22 + +issues: https://github.com/foxglove/ros-foxglove-bridge/issues +website: https://foxglove.dev/ + +architectures: + - build-on: amd64 + - build-on: arm64 + +apps: + foxglove-bridge: + command: usr/bin/launch.sh + daemon: simple + plugs: [network, network-bind] + extensions: [ros2-humble] + + reset-config: + command: usr/bin/reset_config.sh + +parts: + foxglove-bridge: + plugin: colcon + colcon-cmake-args: + - -DCMAKE_BUILD_TYPE=Release + - -DBUILD_TESTING=OFF + source: . + override-pull: | + craftctl default + + version="$(git describe --always --tags| sed -e 's/^v//;s/-/+git/;y/-/./')" + [ -n "$(echo $version | grep "+git")" ] && grade=devel || grade=stable + craftctl set version="$version" + craftctl set grade="$grade" + stage-packages: + - ros-humble-ros2launch + # Messages definition are required to bridge them. + # No custom message is going to be support for now + - ros-humble-ackermann-msgs + - ros-humble-action-msgs + - ros-humble-actionlib-msgs + - ros-humble-actuator-msgs + - ros-humble-apriltag-msgs + - ros-humble-aruco-msgs + - ros-humble-aruco-opencv-msgs + - ros-humble-automotive-autonomy-msgs + - ros-humble-automotive-navigation-msgs + - ros-humble-automotive-platform-msgs + - ros-humble-autoware-auto-msgs + - ros-humble-can-msgs + - ros-humble-cartographer-ros-msgs + - ros-humble-cascade-lifecycle-msgs + - ros-humble-clearpath-msgs + - ros-humble-clearpath-platform-msgs + - ros-humble-control-msgs + - ros-humble-controller-manager-msgs + - ros-humble-create-msgs + - ros-humble-dataspeed-dbw-msgs + - ros-humble-dataspeed-ulc-msgs + - ros-humble-dbw-fca-msgs + - ros-humble-dbw-ford-msgs + - ros-humble-dbw-polaris-msgs + - ros-humble-delphi-esr-msgs + - ros-humble-delphi-mrr-msgs + - ros-humble-delphi-srr-msgs + - ros-humble-depthai-ros-msgs + - ros-humble-derived-object-msgs + - ros-humble-diagnostic-msgs + - ros-humble-dwb-msgs + - ros-humble-dynamixel-workbench-msgs + - ros-humble-event-camera-msgs + - ros-humble-flexbe-msgs + - ros-humble-flir-camera-msgs + - ros-humble-foros-msgs + - ros-humble-four-wheel-steering-msgs + - ros-humble-foxglove-msgs + - ros-humble-gazebo-msgs + - ros-humble-geographic-msgs + - ros-humble-geometry-msgs + - ros-humble-gps-msgs + - ros-humble-graph-msgs + - ros-humble-grasping-msgs + - ros-humble-grbl-msgs + - ros-humble-grid-map-msgs + - ros-humble-ibeo-msgs + - ros-humble-irobot-create-msgs + - ros-humble-kartech-linear-actuator-msgs + - ros-humble-leo-msgs + - ros-humble-lgsvl-msgs + - ros-humble-lifecycle-msgs + - ros-humble-map-msgs + - ros-humble-marker-msgs + - ros-humble-marti-can-msgs + - ros-humble-marti-common-msgs + - ros-humble-marti-dbw-msgs + - ros-humble-marti-introspection-msgs + - ros-humble-marti-nav-msgs + - ros-humble-marti-perception-msgs + - ros-humble-marti-sensor-msgs + - ros-humble-marti-status-msgs + - ros-humble-marti-visualization-msgs + - ros-humble-marvelmind-ros2-msgs + - ros-humble-mavros-msgs + - ros-humble-micro-ros-diagnostic-msgs + - ros-humble-micro-ros-msgs + - ros-humble-microstrain-inertial-msgs + - ros-humble-mobileye-560-660-msgs + - ros-humble-moveit-msgs + - ros-humble-mrpt-msgs + - ros-humble-nao-command-msgs + - ros-humble-nao-sensor-msgs + - ros-humble-nav-2d-msgs + - ros-humble-nav-msgs + - ros-humble-nav2-msgs + - ros-humble-neobotix-usboard-msgs + - ros-humble-nmea-msgs + - ros-humble-novatel-gps-msgs + - ros-humble-novatel-oem7-msgs + - ros-humble-object-recognition-msgs + - ros-humble-octomap-msgs + - ros-humble-ouster-msgs + - ros-humble-pal-statistics-msgs + - ros-humble-pcl-msgs + - ros-humble-pendulum-msgs + - ros-humble-phidgets-msgs + - ros-humble-plansys2-msgs + - ros-humble-play-motion2-msgs + - ros-humble-plotjuggler-msgs + - ros-humble-polygon-msgs + - ros-humble-radar-msgs + - ros-humble-raspimouse-msgs + - ros-humble-rc-common-msgs + - ros-humble-rc-reason-msgs + - ros-humble-rclpy-message-converter-msgs + - ros-humble-rcss3d-agent-msgs + - ros-humble-realsense2-camera-msgs + - ros-humble-rmf-api-msgs + - ros-humble-rmf-building-map-msgs + - ros-humble-rmf-charger-msgs + - ros-humble-rmf-dispenser-msgs + - ros-humble-rmf-door-msgs + - ros-humble-rmf-fleet-msgs + - ros-humble-rmf-ingestor-msgs + - ros-humble-rmf-lift-msgs + - ros-humble-rmf-obstacle-msgs + - ros-humble-rmf-scheduler-msgs + - ros-humble-rmf-site-map-msgs + - ros-humble-rmf-task-msgs + - ros-humble-rmf-traffic-msgs + - ros-humble-rmf-visualization-msgs + - ros-humble-rmf-workcell-msgs + - ros-humble-robot-calibration-msgs + - ros-humble-robot-controllers-msgs + - ros-humble-rosapi-msgs + - ros-humble-rosbridge-msgs + - ros-humble-rosbridge-test-msgs + - ros-humble-rosgraph-msgs + - ros-humble-rqt-image-overlay + - ros-humble-rtabmap-msgs + - ros-humble-rtcm-msgs + - ros-humble-rviz-2d-overlay-msgs + - ros-humble-sensor-msgs + - ros-humble-shape-msgs + - ros-humble-smacc2-msgs + - ros-humble-smach-msgs + - ros-humble-soccer-object-msgs + - ros-humble-soccer-vision-2d-msgs + - ros-humble-soccer-vision-3d-msgs + - ros-humble-soccer-vision-attribute-msgs + - ros-humble-social-nav-msgs + - ros-humble-statistics-msgs + - ros-humble-std-msgs + - ros-humble-stereo-msgs + - ros-humble-stubborn-buddies-msgs + - ros-humble-system-modes-msgs + - ros-humble-teleop-tools-msgs + - ros-humble-test-msgs + - ros-humble-tf2-geometry-msgs + - ros-humble-tf2-msgs + - ros-humble-tf2-sensor-msgs + - ros-humble-trajectory-msgs + - ros-humble-turtlebot3-msgs + - ros-humble-turtlebot4-msgs + - ros-humble-tuw-airskin-msgs + - ros-humble-tuw-geometry-msgs + - ros-humble-tuw-msgs + - ros-humble-tuw-multi-robot-msgs + - ros-humble-tuw-nav-msgs + - ros-humble-tuw-object-msgs + - ros-humble-twist-mux-msgs + - ros-humble-ublox-msgs + - ros-humble-ublox-ubx-msgs + - ros-humble-udp-msgs + - ros-humble-unique-identifier-msgs + - ros-humble-ur-dashboard-msgs + - ros-humble-ur-msgs + - ros-humble-urg-node-msgs + - ros-humble-velodyne-msgs + - ros-humble-vision-msgs + - ros-humble-visualization-msgs + - ros-humble-webots-ros2-msgs + - ros-humble-wiimote-msgs + - ros-humble-wireless-msgs + + # copy local scripts to the snap usr/bin + local-files: + plugin: dump + source: snap/local/ + organize: + '*.sh': usr/bin/ From 55e7f4ab55b6adaa61b38fadb35e96189d1152a1 Mon Sep 17 00:00:00 2001 From: artivis Date: Thu, 12 Oct 2023 10:28:59 +0200 Subject: [PATCH 02/13] stage spdlog-vendor Signed-off-by: artivis --- snap/snapcraft.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml index 9a86f98..894c1c8 100644 --- a/snap/snapcraft.yaml +++ b/snap/snapcraft.yaml @@ -41,6 +41,7 @@ parts: craftctl set version="$version" craftctl set grade="$grade" stage-packages: + - ros-humble-spdlog-vendor - ros-humble-ros2launch # Messages definition are required to bridge them. # No custom message is going to be support for now From dc918887211bd5566f7a3f9801d7352c0e8604ea Mon Sep 17 00:00:00 2001 From: Kotochleb Date: Mon, 16 Oct 2023 09:51:12 +0200 Subject: [PATCH 03/13] Fix launch.sh and configure scripts --- snap/hooks/configure | 4 ++-- snap/local/launch.sh | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/snap/hooks/configure b/snap/hooks/configure index 4c608ad..f72dace 100644 --- a/snap/hooks/configure +++ b/snap/hooks/configure @@ -46,8 +46,8 @@ done for opt in tls include_hidden use_sim_time; do if [ -n "${!opt}" ]; then case "${!opt}" in - true) ;; - false) ;; + True) ;; + False) ;; *) logger -t ${SNAP_NAME} "'${!opt}' is not a valid boolean for ${opt}. Please use 'true' or 'false'." echo "'${!opt}' is not a valid boolean for ${opt}. Please use 'true' or 'false'." >&2 diff --git a/snap/local/launch.sh b/snap/local/launch.sh index 48d75ed..d464eb8 100755 --- a/snap/local/launch.sh +++ b/snap/local/launch.sh @@ -23,7 +23,7 @@ asset-uri-allowlist" for OPTION in ${OPTIONS}; do VALUE="$(snapctl get ${OPTION})" if [ -n "${VALUE}" ]; then - LAUNCH_OPTIONS+="${OPTION}:=${VALUE} " + LAUNCH_OPTIONS="${LAUNCH_OPTIONS} ${OPTION}:=${VALUE}" fi done From f2a3022af0640986ed7a3ceae942e585e25d9b46 Mon Sep 17 00:00:00 2001 From: Kotochleb Date: Mon, 16 Oct 2023 18:04:35 +0200 Subject: [PATCH 04/13] FIx missing spdlog on build --- snap/snapcraft.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml index 894c1c8..58f6350 100644 --- a/snap/snapcraft.yaml +++ b/snap/snapcraft.yaml @@ -40,6 +40,8 @@ parts: [ -n "$(echo $version | grep "+git")" ] && grade=devel || grade=stable craftctl set version="$version" craftctl set grade="$grade" + build-packages: + - ros-humble-spdlog-vendor stage-packages: - ros-humble-spdlog-vendor - ros-humble-ros2launch From 13284b03964d860a38d26fd805545b27725ad813 Mon Sep 17 00:00:00 2001 From: Kotochleb Date: Mon, 16 Oct 2023 18:42:48 +0200 Subject: [PATCH 05/13] Add use-compression parameter --- snap/hooks/configure | 3 ++- snap/local/launch.sh | 1 + snap/local/reset_config.sh | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/snap/hooks/configure b/snap/hooks/configure index f72dace..4288d6c 100644 --- a/snap/hooks/configure +++ b/snap/hooks/configure @@ -18,6 +18,7 @@ max_qos_depth="$(snapctl get max-qos-depth)" num_threads="$(snapctl get num-threads)" send_buffer_limit="$(snapctl get send-buffer-limit)" use_sim_time="$(snapctl get use-sim-time)" +use_compression="$(snapctl get use-compression)" capabilities="$(snapctl get capabilities)" include_hidden="$(snapctl get include-hidden)" asset_uri_allowlist="$(snapctl get asset-uri-allowlist)" @@ -43,7 +44,7 @@ for opt in max_qos_depth num_threads send_buffer_limit; do fi done -for opt in tls include_hidden use_sim_time; do +for opt in tls include_hidden use_sim_time use_compression; do if [ -n "${!opt}" ]; then case "${!opt}" in True) ;; diff --git a/snap/local/launch.sh b/snap/local/launch.sh index d464eb8..a661af6 100755 --- a/snap/local/launch.sh +++ b/snap/local/launch.sh @@ -16,6 +16,7 @@ max-qos-depth num-threads send-buffer-limit use-sim-time +use-compression capabilities include-hidden asset-uri-allowlist" diff --git a/snap/local/reset_config.sh b/snap/local/reset_config.sh index bdb03c3..792648d 100755 --- a/snap/local/reset_config.sh +++ b/snap/local/reset_config.sh @@ -17,6 +17,7 @@ snapctl set max_qos_depth! snapctl set num_threads! snapctl set send_buffer_limit! snapctl set use_sim_time! +snapctl set use-compression! snapctl set capabilities! snapctl set include_hidden! snapctl set asset_uri_allowlist! From 40da7c4c76328992022b04e8d664b74ba802d381 Mon Sep 17 00:00:00 2001 From: Kotochleb Date: Mon, 16 Oct 2023 20:01:35 +0200 Subject: [PATCH 06/13] Replace _ with - in reset --- snap/local/reset_config.sh | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/snap/local/reset_config.sh b/snap/local/reset_config.sh index 792648d..cc066fb 100755 --- a/snap/local/reset_config.sh +++ b/snap/local/reset_config.sh @@ -8,16 +8,16 @@ snapctl set address! snapctl set tls! snapctl set certfile! snapctl set keyfile! -snapctl set topic_whitelist! -snapctl set param_whitelist! -snapctl set service_whitelist! -snapctl set client_topic_whitelist! -snapctl set min_qos_depth! -snapctl set max_qos_depth! -snapctl set num_threads! -snapctl set send_buffer_limit! -snapctl set use_sim_time! +snapctl set topic-whitelist! +snapctl set param-whitelist! +snapctl set service-whitelist! +snapctl set client-topic-whitelist! +snapctl set min-qos-depth! +snapctl set max-qos-depth! +snapctl set num-threads! +snapctl set send-buffer-limit! +snapctl set use-sim-time! snapctl set use-compression! snapctl set capabilities! -snapctl set include_hidden! -snapctl set asset_uri_allowlist! +snapctl set include-hidden! +snapctl set asset-uri-allowlist! From 057c4b79659f2d5b1f9453902513a40ed8f79160 Mon Sep 17 00:00:00 2001 From: Kotochleb Date: Thu, 2 Nov 2023 15:13:48 +0100 Subject: [PATCH 07/13] Fix incorrect config log --- snap/hooks/configure | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/snap/hooks/configure b/snap/hooks/configure index 4288d6c..09b229f 100644 --- a/snap/hooks/configure +++ b/snap/hooks/configure @@ -50,8 +50,8 @@ for opt in tls include_hidden use_sim_time use_compression; do True) ;; False) ;; *) - logger -t ${SNAP_NAME} "'${!opt}' is not a valid boolean for ${opt}. Please use 'true' or 'false'." - echo "'${!opt}' is not a valid boolean for ${opt}. Please use 'true' or 'false'." >&2 + logger -t ${SNAP_NAME} "'${!opt}' is not a valid boolean for ${opt}. Please use 'True' or 'False'." + echo "'${!opt}' is not a valid boolean for ${opt}. Please use 'True' or 'False'." >&2 return 1 ;; esac From dfa38847f22f1e961a75bdf3a289193bba9f4f17 Mon Sep 17 00:00:00 2001 From: Guillaumebeuzeboc Date: Wed, 3 Apr 2024 14:57:01 +0200 Subject: [PATCH 08/13] feat(content-snap-config): configure the bridge from the content snap --- snap/hooks/configure | 61 +----------------- snap/hooks/connect-plug-configuration-read | 12 ++++ snap/hooks/disconnect-plug-configuration-read | 5 ++ snap/local/config_from_content_snap.sh | 15 +++++ snap/local/validate_config.sh | 62 +++++++++++++++++++ snap/snapcraft.yaml | 12 ++++ 6 files changed, 108 insertions(+), 59 deletions(-) create mode 100755 snap/hooks/connect-plug-configuration-read create mode 100755 snap/hooks/disconnect-plug-configuration-read create mode 100755 snap/local/config_from_content_snap.sh create mode 100755 snap/local/validate_config.sh diff --git a/snap/hooks/configure b/snap/hooks/configure index 09b229f..60eb5b5 100644 --- a/snap/hooks/configure +++ b/snap/hooks/configure @@ -1,65 +1,8 @@ #!/bin/bash -e -# Here we can assert that the parameters value set by the user are proper. - -# Get the parameters values. -# They may be 'unset' as per the install hook. -port="$(snapctl get port)" -address="$(snapctl get address)" -tls="$(snapctl get tls)" -certfile="$(snapctl get certfile)" -keyfile="$(snapctl get keyfile)" -topic_whitelist="$(snapctl get topic-whitelist)" -param_whitelist="$(snapctl get param-whitelist)" -service_whitelist="$(snapctl get service-whitelist)" -client_topic_whitelist="$(snapctl get client-topic-whitelist)" -min_qos_depth="$(snapctl get min-qos-depth)" -max_qos_depth="$(snapctl get max-qos-depth)" -num_threads="$(snapctl get num-threads)" -send_buffer_limit="$(snapctl get send-buffer-limit)" -use_sim_time="$(snapctl get use-sim-time)" -use_compression="$(snapctl get use-compression)" -capabilities="$(snapctl get capabilities)" -include_hidden="$(snapctl get include-hidden)" -asset_uri_allowlist="$(snapctl get asset-uri-allowlist)" - -# If the parameter has been explicitely set by the user -if [ -n "${port}" ]; then - # Check that it is a valid value - if ! expr "${port}" : '^[0-9]\+$' > /dev/null; then - logger -t ${SNAP_NAME} "'${opt}' is not a valid port value." - echo "'${port}' is not a valid port value" >&2 - return 1 - fi -fi - -for opt in max_qos_depth num_threads send_buffer_limit; do - if [ -n "${!opt}" ]; then - # Check that it is a valid value - if ! expr "${!opt}" : '^[0-9]\+$' > /dev/null; then - logger -t ${SNAP_NAME} "'${!opt}' is not a valid value for ${opt}." - echo "'${!opt}' is not a valid value for ${opt}." >&2 - return 1 - fi -fi -done - -for opt in tls include_hidden use_sim_time use_compression; do - if [ -n "${!opt}" ]; then - case "${!opt}" in - True) ;; - False) ;; - *) - logger -t ${SNAP_NAME} "'${!opt}' is not a valid boolean for ${opt}. Please use 'True' or 'False'." - echo "'${!opt}' is not a valid boolean for ${opt}. Please use 'True' or 'False'." >&2 - return 1 - ;; - esac - fi -done - -# @todo assert the rest of the parameters. +$SNAP/usr/bin/validate_config.sh # Service was already enabled, just restart it # to make sure the new config values are picked up snapctl restart ${SNAP_NAME}.${SNAP_NAME} 2>&1 || true + diff --git a/snap/hooks/connect-plug-configuration-read b/snap/hooks/connect-plug-configuration-read new file mode 100755 index 0000000..4bcbe78 --- /dev/null +++ b/snap/hooks/connect-plug-configuration-read @@ -0,0 +1,12 @@ +#!/bin/sh -e + +CONFIGURATION_FILE_PATH=$SNAP_COMMON/configuration/foxglove-bridge.yaml + +if [ ! -f "$CONFIGURATION_FILE_PATH" ]; then + echo "Configuration file '$CONFIGURATION_FILE_PATH' does not exist." + exit 1 +fi + +snapctl start --enable ${SNAP_NAME}.config-from-content-snap 2>&1 +snapctl restart ${SNAP_NAME} 2>&1 || true + diff --git a/snap/hooks/disconnect-plug-configuration-read b/snap/hooks/disconnect-plug-configuration-read new file mode 100755 index 0000000..8bf79c8 --- /dev/null +++ b/snap/hooks/disconnect-plug-configuration-read @@ -0,0 +1,5 @@ +#!/bin/sh -e + +snapctl stop --disable ${SNAP_NAME}.config-from-content-snap 2>&1 +snapctl restart ${SNAP_NAME} 2>&1 || true + diff --git a/snap/local/config_from_content_snap.sh b/snap/local/config_from_content_snap.sh new file mode 100755 index 0000000..8d23362 --- /dev/null +++ b/snap/local/config_from_content_snap.sh @@ -0,0 +1,15 @@ +#!/bin/bash -e + +CONFIGURATION_FILE_PATH=$SNAP_COMMON/configuration/foxglove-bridge.yaml + +if [ ! -f "$CONFIGURATION_FILE_PATH" ]; then + echo "Configuration file '$CONFIGURATION_FILE_PATH' does not exist." + exit 1 +fi + +snapctl set port=$(yq '.port // 54321' $CONFIGURATION_FILE_PATH) +snapctl set address=$(yq '.address // "0.0.0.0"' $CONFIGURATION_FILE_PATH) +snapctl set topic-whitelist=$(yq '.topic-whitelist // "*"' $CONFIGURATION_FILE_PATH) + +$SNAP/usr/bin/validate_config.sh + diff --git a/snap/local/validate_config.sh b/snap/local/validate_config.sh new file mode 100755 index 0000000..d154df0 --- /dev/null +++ b/snap/local/validate_config.sh @@ -0,0 +1,62 @@ +#!/bin/bash -e + +# Here we can assert that the parameters value set by the user are proper. + +# Get the parameters values. +# They may be 'unset' as per the install hook. +port="$(snapctl get port)" +address="$(snapctl get address)" +tls="$(snapctl get tls)" +certfile="$(snapctl get certfile)" +keyfile="$(snapctl get keyfile)" +topic_whitelist="$(snapctl get topic-whitelist)" +param_whitelist="$(snapctl get param-whitelist)" +service_whitelist="$(snapctl get service-whitelist)" +client_topic_whitelist="$(snapctl get client-topic-whitelist)" +min_qos_depth="$(snapctl get min-qos-depth)" +max_qos_depth="$(snapctl get max-qos-depth)" +num_threads="$(snapctl get num-threads)" +send_buffer_limit="$(snapctl get send-buffer-limit)" +use_sim_time="$(snapctl get use-sim-time)" +use_compression="$(snapctl get use-compression)" +capabilities="$(snapctl get capabilities)" +include_hidden="$(snapctl get include-hidden)" +asset_uri_allowlist="$(snapctl get asset-uri-allowlist)" + +# If the parameter has been explicitely set by the user +if [ -n "${port}" ]; then + # Check that it is a valid value + if ! expr "${port}" : '^[0-9]\+$' > /dev/null; then + logger -t ${SNAP_NAME} "'${opt}' is not a valid port value." + echo "'${port}' is not a valid port value" >&2 + return 1 + fi +fi + +for opt in max_qos_depth num_threads send_buffer_limit; do + if [ -n "${!opt}" ]; then + # Check that it is a valid value + if ! expr "${!opt}" : '^[0-9]\+$' > /dev/null; then + logger -t ${SNAP_NAME} "'${!opt}' is not a valid value for ${opt}." + echo "'${!opt}' is not a valid value for ${opt}." >&2 + return 1 + fi + fi +done + +for opt in tls include_hidden use_sim_time use_compression; do + if [ -n "${!opt}" ]; then + case "${!opt}" in + True) ;; + False) ;; + *) + logger -t ${SNAP_NAME} "'${!opt}' is not a valid boolean for ${opt}. Please use 'True' or 'False'." + echo "'${!opt}' is not a valid boolean for ${opt}. Please use 'True' or 'False'." >&2 + return 1 + ;; + esac + fi +done + +# @todo assert the rest of the parameters. + diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml index 58f6350..4f67f4b 100644 --- a/snap/snapcraft.yaml +++ b/snap/snapcraft.yaml @@ -16,7 +16,17 @@ architectures: - build-on: amd64 - build-on: arm64 +plugs: + configuration-read: + interface: content + target: $SNAP_COMMON/configuration + apps: + config-from-content-snap: + command: usr/bin/config_from_content_snap.sh + daemon: oneshot + install-mode: disable + before: [foxglove-bridge] foxglove-bridge: command: usr/bin/launch.sh daemon: simple @@ -42,6 +52,8 @@ parts: craftctl set grade="$grade" build-packages: - ros-humble-spdlog-vendor + stage-snaps: + - yq stage-packages: - ros-humble-spdlog-vendor - ros-humble-ros2launch From 2fbec02dcc07755eb82bb510bd27114d18e03055 Mon Sep 17 00:00:00 2001 From: Guillaumebeuzeboc Date: Thu, 4 Apr 2024 18:44:37 +0200 Subject: [PATCH 09/13] feat(ci): build and publish the snap --- .github/workflows/snap.yaml | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 .github/workflows/snap.yaml diff --git a/.github/workflows/snap.yaml b/.github/workflows/snap.yaml new file mode 100644 index 0000000..235d9bc --- /dev/null +++ b/.github/workflows/snap.yaml @@ -0,0 +1,25 @@ +name: snap +on: + push: + branches: + - feature/snap + pull_request: + branches: + - feature/snap + workflow_dispatch: + workflow_call: + inputs: + branch-name: + required: false + type: string + default: '' + +jobs: + snap: + uses: ubuntu-robotics/snap_workflows/.github/workflows/snap.yaml@main + secrets: + store-login: ${{ secrets.STORE_LOGIN }} + with: + branch-name: ${{ inputs.branch-name == '' && github.ref || inputs.branch-name }} + snap-name: foxglove-bridge + publish: ${{ github.event_name == 'push' || ( github.event_name == 'workflow_dispatch' && inputs.branch-name != '' ) }} From d866eb9efc65417bcc73ba5c9c2993842e7952d3 Mon Sep 17 00:00:00 2001 From: Guillaumebeuzeboc Date: Fri, 5 Apr 2024 11:11:20 +0200 Subject: [PATCH 10/13] ci(monthly): add a monthly build --- .github/workflows/monthly.yaml | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 .github/workflows/monthly.yaml diff --git a/.github/workflows/monthly.yaml b/.github/workflows/monthly.yaml new file mode 100644 index 0000000..8864caa --- /dev/null +++ b/.github/workflows/monthly.yaml @@ -0,0 +1,11 @@ +name: Monthly +on: + schedule: + - cron: '0 0 1 * *' + workflow_dispatch: + +jobs: + main: + uses: canonical/ros-foxglove-bridge/.github/workflows/snap.yaml@main + with: + branch-name: "main" From 12b0ff5eb8bf82928898bc35b2289979fff51ea1 Mon Sep 17 00:00:00 2001 From: Guillaumebeuzeboc Date: Fri, 5 Apr 2024 17:18:25 +0200 Subject: [PATCH 11/13] fix(ci): simplify publication condition --- .github/workflows/snap.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/snap.yaml b/.github/workflows/snap.yaml index 235d9bc..1fea76e 100644 --- a/.github/workflows/snap.yaml +++ b/.github/workflows/snap.yaml @@ -22,4 +22,4 @@ jobs: with: branch-name: ${{ inputs.branch-name == '' && github.ref || inputs.branch-name }} snap-name: foxglove-bridge - publish: ${{ github.event_name == 'push' || ( github.event_name == 'workflow_dispatch' && inputs.branch-name != '' ) }} + publish: ${{ github.event_name == 'push' || github.event_name == 'workflow_dispatch' }} From 80168325af1db7a3dc55d09a4e39fb7a5fd68fe0 Mon Sep 17 00:00:00 2001 From: Guillaumebeuzeboc Date: Mon, 8 Apr 2024 11:46:59 +0200 Subject: [PATCH 12/13] fix(ci): reusable workflow path --- .github/workflows/monthly.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/monthly.yaml b/.github/workflows/monthly.yaml index 8864caa..849ec11 100644 --- a/.github/workflows/monthly.yaml +++ b/.github/workflows/monthly.yaml @@ -6,6 +6,6 @@ on: jobs: main: - uses: canonical/ros-foxglove-bridge/.github/workflows/snap.yaml@main + uses: ubuntu-robotics/ros-foxglove-bridge/.github/workflows/snap.yaml@main with: branch-name: "main" From 02a34d1af6284b484f0edc94e79fba5692d2f805 Mon Sep 17 00:00:00 2001 From: Guillaumebeuzeboc Date: Mon, 3 Jun 2024 15:36:31 +0200 Subject: [PATCH 13/13] fix(snap): ros-humble-dataspeed-dbw-msgs got removed https://discourse.ros.org/t/new-packages-and-patch-release-for-humble-hawksbill-2024-05-23/37872#removed-packages-4-4 --- snap/snapcraft.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml index 4f67f4b..20080a1 100644 --- a/snap/snapcraft.yaml +++ b/snap/snapcraft.yaml @@ -78,7 +78,6 @@ parts: - ros-humble-control-msgs - ros-humble-controller-manager-msgs - ros-humble-create-msgs - - ros-humble-dataspeed-dbw-msgs - ros-humble-dataspeed-ulc-msgs - ros-humble-dbw-fca-msgs - ros-humble-dbw-ford-msgs