Skip to content

Commit

Permalink
copy ros.env if for some reason don't exist
Browse files Browse the repository at this point in the history
  • Loading branch information
DominikN committed Jul 11, 2024
1 parent a155633 commit 5e90e80
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 10 deletions.
2 changes: 1 addition & 1 deletion snap/hooks/configure
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ $SNAP/usr/bin/configure_hook_ros.sh

# restart services with new ROS 2 config
for service in daemon; do
if snapctl services ${SNAP_NAME}.${service} | grep -qw active; then
if snapctl services ${SNAP_NAME}.${service} | grep -qw enabled; then
snapctl restart ${SNAP_NAME}.${service}
log "Restarted ${SNAP_NAME}.${service}"
fi
Expand Down
10 changes: 3 additions & 7 deletions snap/hooks/install
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
#!/bin/bash -e

# Define a function to log messages
log() {
local message="$1"
# Log the message with logger
logger -t "${SNAP_NAME}" "install hook: $message"
}
# Define a function to log and echo messages
source $SNAP/usr/bin/utils.sh

$SNAP/usr/bin/install_hook_ros.sh

Expand All @@ -29,7 +25,7 @@ if ! snapctl is-connected raw-usb; then
fi

# copy params
cp -r $SNAP/usr/share/husarion-depthai/config/*.yaml ${SNAP_COMMON}/
cp -r ${SNAP}/usr/share/${SNAP_NAME}/config/*.yaml ${SNAP_COMMON}/

# # # copy meshes to shared folder
# log "copy meshes to '${SNAP_COMMON}/ros2_ws/'"
Expand Down
6 changes: 6 additions & 0 deletions snap/local/local-ros/ros.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export ROS_DOMAIN_ID=0
export ROS_LOCALHOST_ONLY=0
unset ROS_NAMESPACE
unset CYCLONEDDS_URI
export RMW_IMPLEMENTATION=rmw_fastrtps_cpp
export FASTRTPS_DEFAULT_PROFILES_FILE=/var/snap/rosbot-xl/common/udp.xml
17 changes: 15 additions & 2 deletions snap/local/local-ros/ros_setup.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
#!/bin/bash -e

source $SNAP_COMMON/ros.env
source $SNAP/usr/bin/utils.sh

exec $@
# Path to the ros.env file
ROS_ENV_FILE="$SNAP_COMMON/ros.env"

# Check if the ros.env file exists
if [[ ! -f "$ROS_ENV_FILE" ]]; then
log "Copying ros.env file to $SNAP_COMMON"
cp -r ${SNAP}/usr/share/${SNAP_NAME}/config/ros.env ${SNAP_COMMON}/
fi

# Source the ros.env file
source "$ROS_ENV_FILE"

# Execute the passed command
exec "$@"
1 change: 1 addition & 0 deletions snap/snapcraft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ parts:
organize:
'*.sh': usr/bin/
'*.xml': usr/share/husarion-depthai/config/
'ros.env': usr/share/husarion-depthai/config/

local-files:
plugin: dump
Expand Down

0 comments on commit 5e90e80

Please sign in to comment.