|
| 1 | +################################################################################ |
| 2 | +# (c) 2021 Copyright, Real-Time Innovations, Inc. (RTI) |
| 3 | +# |
| 4 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | +# you may not use this file except in compliance with the License. |
| 6 | +# You may obtain a copy of the License at |
| 7 | +# |
| 8 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | +# |
| 10 | +# Unless required by applicable law or agreed to in writing, software |
| 11 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | +# See the License for the specific language governing permissions and |
| 14 | +# limitations under the License. |
| 15 | +################################################################################ |
| 16 | +# |
| 17 | +# This file was automatically generated from template |
| 18 | +# `rmw_connextdds/env_hook/rmw_connextdds_resources.sh.in` |
| 19 | +# |
| 20 | +# The script will perform the following environment customizations: |
| 21 | +# |
| 22 | +# - Extend variable NDDS_QOS_PROFILES to load `ros2_qos_profiles.xml`. |
| 23 | +# |
| 24 | +################################################################################ |
| 25 | + |
| 26 | +################################################################################ |
| 27 | +# Determine path to rmw_connextdds' share/ directory |
| 28 | +################################################################################ |
| 29 | +_rmw_connextdds_find_sharedir() |
| 30 | +{ |
| 31 | + ( |
| 32 | + IFS=":" |
| 33 | + for pfx_dir in ${AMENT_PREFIX_PATH}; do |
| 34 | + sharedir="${pfx_dir}/share/rmw_connextdds" |
| 35 | + if [ -d "${sharedir}" ]; then |
| 36 | + cd "${sharedir}" && pwd |
| 37 | + break |
| 38 | + fi |
| 39 | + done |
| 40 | + ) |
| 41 | +} |
| 42 | + |
| 43 | +_rmw_connextdds_dir="$(_rmw_connextdds_find_sharedir)" |
| 44 | +_rmw_connextdds_xml_dir="${_rmw_connextdds_dir}/xml" |
| 45 | + |
| 46 | +_ros2_qos_profiles="${_rmw_connextdds_xml_dir}/ros2_qos_profiles.xml" |
| 47 | + |
| 48 | +################################################################################ |
| 49 | +# Update NDDS_QOS_PROFILES |
| 50 | +################################################################################ |
| 51 | +_rmw_connextdds_append_profile() |
| 52 | +{ |
| 53 | + local already_added=$( |
| 54 | + IFS=";" |
| 55 | + for qos_profile_pfx in ${NDDS_QOS_PROFILES}; do |
| 56 | + qos_profile="${qos_profile_pfx#file://}" |
| 57 | + qos_profile_dir=$(dirname ${qos_profile}) |
| 58 | + qos_profile_name=$(basename ${qos_profile}) |
| 59 | + cd ${qos_profile_dir} || continue |
| 60 | + if [ "$(pwd)" = "${_rmw_connextdds_xml_dir}" -a \ |
| 61 | + "${qos_profile_name}" = "ros2_qos_profiles.xml" ]; then |
| 62 | + printf "%s" "${qos_profile}" |
| 63 | + break; |
| 64 | + fi |
| 65 | + done |
| 66 | + ) 2>/dev/null |
| 67 | + |
| 68 | + if [ -z "${NDDS_QOS_PROFILES}" ]; then |
| 69 | + export NDDS_QOS_PROFILES="file://${_ros2_qos_profiles}" |
| 70 | + elif [ -z "${already_added}" ]; then |
| 71 | + export NDDS_QOS_PROFILES="${NDDS_QOS_PROFILES};file://${_ros2_qos_profiles}" |
| 72 | + fi |
| 73 | +} |
| 74 | + |
| 75 | +if [ ! -f "${_ros2_qos_profiles}" ]; then |
| 76 | + printf "[@PROJECT_NAME@][WARNING] file ros2_qos_profiles.xml NOT FOUND\n" 1>&2 |
| 77 | + printf "[@PROJECT_NAME@][WARNING] Custom built-in QoS profiles will not be available, unless you manually load them into the enviroment with variable NDDS_QOS_PROFILES.\n" 1>&2 |
| 78 | +else |
| 79 | + _rmw_connextdds_append_profile |
| 80 | +fi |
| 81 | + |
| 82 | +################################################################################ |
| 83 | +# Clean up environment |
| 84 | +################################################################################ |
| 85 | +unset _rmw_connextdds_dir \ |
| 86 | + _rmw_connextdds_xml_dir \ |
| 87 | + _ros2_qos_profiles \ |
| 88 | + _rmw_connextdds_append_profile \ |
| 89 | + _rmw_connextdds_find_sharedir |
0 commit comments