Skip to content

Commit

Permalink
[ros2] update env vars
Browse files Browse the repository at this point in the history
  • Loading branch information
MatthijsBurgh committed Apr 26, 2024
1 parent 587ead1 commit 83e8207
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 16 deletions.
16 changes: 9 additions & 7 deletions ros2/install.bash
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
#! /usr/bin/env bash
# shellcheck disable=SC1090

if [ -z "$TUE_ROS_DISTRO" ]
[[ -v TUE_ENV_ROS_DISTRO || -v TUE_ROS_DISTRO ]] || { TUE_ENV_ROS_DISTRO=${TUE_ROS_DISTRO}; tue-install-warning "Change the config of your environment to use 'TUE_ENV_ROS_DISTRO' instead of 'TUE_ROS_DISTRO'"; }
if [[ -z "${TUE_ENV_ROS_DISTRO}" ]]
then
tue-install-error "TUE_ROS_DISTRO was not set"
tue-install-error "TUE_ENV_ROS_DISTRO was not set"
return 1
fi

# Install basic ROS packages and eProsima DDS implementation.
tue-install-system-now ros-"$TUE_ROS_DISTRO"-ros-core ros-"$TUE_ROS_DISTRO"-rmw-fastrtps-cpp
tue-install-system-now ros-"${TUE_ENV_ROS_DISTRO}"-ros-core ros-"${TUE_ENV_ROS_DISTRO}"-rmw-fastrtps-cpp

# Setup the build environment
mkdir -p "$TUE_SYSTEM_DIR"
mkdir -p "${TUE_ENV_WS_DIR}"

if [ ! -f "$TUE_SYSTEM_DIR"/install/setup.bash ]
if [ ! -f "$TUE_ENV_WS_DIR"/install/setup.bash ]
then
[[ -z "${TUE_ROS_VERSION}" ]] && { tue-install-warning "tue-env variable TUE_ROS_VERSION is not set. This will not be allowed in the future.\nSetting TUE_ROS_VERSION=2 temporarily."; }
TUE_ROS_VERSION=2 tue-make || tue-install-error "Error in building the ROS2 system workspace"
[[ -v TUE_ENV_ROS_VERSION || -v TUE_ROS_VERSION ]] || { TUE_ENV_ROS_VERSION=${TUE_ROS_VERSION}; tue-install-warning "Change the config of your environment to use 'TUE_ENV_ROS_DISTRO' instead of 'TUE_ROS_DISTRO'"; }
[[ -z "${TUE_ENV_ROS_VERSION}" ]] && { tue-install-warning "tue-env variable TUE_ENV_ROS_VERSION is not set. This will not be allowed in the future.\nSetting TUE_ENV_ROS_VERSION=2 temporarily."; }
TUE_ENV_ROS_VERSION=2 tue-make || tue-install-error "Error in building the ROS2 system workspace"
fi
19 changes: 10 additions & 9 deletions ros2/setup
Original file line number Diff line number Diff line change
@@ -1,26 +1,27 @@
#! /usr/bin/env bash

if [ -z "$TUE_ROS_DISTRO" ]
[[ -v TUE_ENV_ROS_DISTRO || -v TUE_ROS_DISTRO ]] || { TUE_ENV_ROS_DISTRO=${TUE_ROS_DISTRO}; >&2 echo "Change the config of your environment to use 'TUE_ENV_ROS_DISTRO' instead of 'TUE_ROS_DISTRO'"; }
if [[ -z "${TUE_ENV_ROS_DISTRO}" ]]
then
echo "[ros2] TUE_ROS_DISTRO was not set"
echo "[ros2] TUE_ENV_ROS_DISTRO was not set"
return 1
fi

# Add ROS sourcing to the shell startup script
if [ -f "/opt/ros/${TUE_ROS_DISTRO}/setup.bash" ]
if [[ -f "/opt/ros/${TUE_ENV_ROS_DISTRO}/setup.bash" ]]
then
# shellcheck disable=SC1090
source "/opt/ros/${TUE_ROS_DISTRO}/setup.bash"
source "/opt/ros/${TUE_ENV_ROS_DISTRO}/setup.bash"
else
echo -e "\033[33;1m[ros2] ROS 2 ${TUE_ROS_DISTRO} setup.bash not found. \033[0m"
echo -e "\033[33;1m[ros2] ROS 2 ${TUE_ENV_ROS_DISTRO} setup.bash not found. \033[0m"
fi

if [ -f "${TUE_SYSTEM_DIR}/install/local_setup.bash" ]
if [[ -f "${TUE_ENV_WS_DIR}/install/local_setup.bash" ]]
then
# shellcheck disable=SC1091
source "${TUE_SYSTEM_DIR}/install/local_setup.bash"
source "${TUE_ENV_WS_DIR}/install/local_setup.bash"
else
echo -e "\033[33;1m[ros2] ${TUE_SYSTEM_DIR}/install/local_setup.bash not found. \033[0m"
echo -e "\033[33;1m[ros2] ${TUE_ENV_WS_DIR}/install/local_setup.bash not found. \033[0m"
fi

# Add Colcon sourcing to the shell startup script
Expand All @@ -29,7 +30,7 @@ then
# shellcheck disable=SC1091
source /usr/share/colcon_cd/function/colcon_cd.sh
# shellcheck disable=SC2016
export _colcon_cd_root="${TUE_SYSTEM_DIR}"
export _colcon_cd_root="${TUE_ENV_WS_DIR}"
else
echo -e "\033[33;5;1m[ros2] colcon_cd setup not found. colcon_cd command disabled. \033[0m"
fi
Expand Down

0 comments on commit 83e8207

Please sign in to comment.