ros2的准备工作就是:setup.bash内容等价于setup.sh
文件存放路径:/opt/ros/humble/
# generated from ament_package/template/prefix_level/local_setup.sh.in# since a plain shell script can't determine its own path when being sourced
# either use the provided AMENT_CURRENT_PREFIX
# or fall back to the build time prefix (if it exists)
_ament_prefix_sh_AMENT_CURRENT_PREFIX="/opt/ros/humble"
if [ -z "$AMENT_CURRENT_PREFIX" ]; thenif [ ! -d "$_ament_prefix_sh_AMENT_CURRENT_PREFIX" ]; thenecho "The build time path \"$_ament_prefix_sh_AMENT_CURRENT_PREFIX\" doesn't exist. Either source a script for a different shell or set the environment variable \"AMENT_CURRENT_PREFIX\" explicitly." 1>&2unset _ament_prefix_sh_AMENT_CURRENT_PREFIXreturn 1fi
else_ament_prefix_sh_AMENT_CURRENT_PREFIX="$AMENT_CURRENT_PREFIX"
fi# set type of shell if not already set
: ${AMENT_SHELL:=sh}# use the Python executable known at configure time
_ament_python_executable="/usr/bin/python3.10"
# allow overriding it with a custom location
if [ -n "$AMENT_PYTHON_EXECUTABLE" ]; then_ament_python_executable="$AMENT_PYTHON_EXECUTABLE"
fi
# if the Python executable doesn't exist try another fall back
if [ ! -f "$_ament_python_executable" ]; thenif /usr/bin/env python3 --version > /dev/nullthen_ament_python_executable=`/usr/bin/env python3 -c "import sys; print(sys.executable)"`elseecho error: unable to find fallback python3 executablereturn 1fi
fi# function to source another script with conditional trace output
# first argument: the path of the script
_ament_prefix_sh_source_script() {if [ -f "$1" ]; thenif [ -n "$AMENT_TRACE_SETUP_FILES" ]; thenecho "# . \"$1\""fi. "$1"elseecho "not found: \"$1\"" 1>&2fi
}# function to prepend non-duplicate values to environment variables
# using colons as separators and avoiding trailing separators
ament_prepend_unique_value() {# arguments_listname="$1"_value="$2"#echo "listname $_listname"#eval echo "list value \$$_listname"#echo "value $_value"# check if the list contains the valueeval _values=\"\$$_listname\"_duplicate=_ament_prepend_unique_value_IFS=$IFSIFS=":"if [ "$AMENT_SHELL" = "zsh" ]; thenament_zsh_to_array _valuesfifor _item in $_values; do# ignore empty stringsif [ -z "$_item" ]; thencontinuefiif [ "$_item" = "$_value" ]; then_duplicate=1fidoneunset _item# prepend only non-duplicatesif [ -z "$_duplicate" ]; then# avoid trailing separatorif [ -z "$_values" ]; theneval export $_listname=\"$_value\"#eval echo "set list \$$_listname"else# field separator must not be a colonunset IFSeval export $_listname=\"$_value:\$$_listname\"#eval echo "prepend list \$$_listname"fifiIFS=$_ament_prepend_unique_value_IFSunset _ament_prepend_unique_value_IFSunset _duplicateunset _valuesunset _valueunset _listname
}# get all commands in topological order
_ament_additional_extension=""
if [ "$AMENT_SHELL" != "sh" ]; then_ament_additional_extension="${AMENT_SHELL}"
fi
_ament_ordered_commands="$($_ament_python_executable "$_ament_prefix_sh_AMENT_CURRENT_PREFIX/_local_setup_util.py" sh $_ament_additional_extension)"
unset _ament_additional_extension
unset _ament_python_executable
if [ -n "$AMENT_TRACE_SETUP_FILES" ]; thenecho "_ament_prefix_sh_source_script() {if [ -f \"\$1\" ]; thenif [ -n \"\$AMENT_TRACE_SETUP_FILES\" ]; thenecho \"# . \\\"\$1\\\"\"fi. \"\$1\"elseecho \"not found: \\\"\$1\\\"\" 1>&2fi}"echo "# Execute generated script:"echo "# <<<"echo "${_ament_ordered_commands}"echo "# >>>"echo "unset _ament_prefix_sh_source_script"
fi
eval "${_ament_ordered_commands}"
unset _ament_ordered_commandsunset _ament_prefix_sh_source_scriptunset _ament_prefix_sh_AMENT_CURRENT_PREFIX