Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Backport ros1 and ros2 targets from Avular #319

Merged
merged 4 commits into from
Sep 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions colcon/install.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
- type: target
name: ros2-setup

- type: system
name: python3-colcon-common-extensions
4 changes: 2 additions & 2 deletions ros-setup/install.bash
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ then
then
tue-install-debug "No existing GPG key of ROS repository found, adding a new one"
ADD_ROS_GPG_KEY=true
elif gpg --import --import-options show-only "${keyfile}" 2> /dev/null | grep -q expired
elif tue-install-pipe gpg --import --import-options show-only "${keyfile}" 2> /dev/null | grep -q expired
then
tue-install-debug "Updating expired GPG key of ROS repository"
ADD_ROS_GPG_KEY=true
Expand All @@ -42,7 +42,7 @@ fi

if [[ "${ADD_ROS_GPG_KEY}" == "true" ]]
then
sudo curl -sSL "${keyurl}" -o "${keyfile}"
tue-install-pipe sudo curl -sSL "${keyurl}" -o "${keyfile}"
tue-install-debug "Successfully added/updated ROS repository GPG key"

FORCE_UPDATE=true
Expand Down
10 changes: 3 additions & 7 deletions ros/install.bash
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,10 @@ then
touch "$rosdep_update_file"
fi

mkdir -p "$TUE_SYSTEM_DIR" "$TUE_DEV_DIR"
mkdir -p "$TUE_SYSTEM_DIR"

if [ ! -f "$TUE_SYSTEM_DIR"/devel/setup.bash ]
then
tue-make || tue-install-error "Error in building the system workspace"
fi

if [ ! -f "$TUE_DEV_DIR"/devel/setup.bash ]
then
tue-make-dev || tue-install-error "Error in building the dev workspace"
[[ -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=1 temporarily."; }
TUE_ROS_VERSION=1 tue-make || tue-install-error "Error in building the system workspace"
fi
10 changes: 2 additions & 8 deletions ros/setup
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,11 @@ then
fi

# shellcheck disable=SC1090
if [ -f "$TUE_DEV_DIR"/devel/setup.bash ]
if [ -f "$TUE_SYSTEM_DIR"/devel/setup.bash ]
then
source "$TUE_DEV_DIR"/devel/setup.bash

elif [ -f "$TUE_SYSTEM_DIR"/devel/setup.bash ]
then
echo -e "\e[33;1m[ros] dev workspace not found, sourcing system workspace\e[0m"
source "$TUE_SYSTEM_DIR"/devel/setup.bash

else
echo -e "\e[33;1m[ros] dev and system workspaces not found, sourcing /opt/ros\e[0m"
echo -e "\e[33;1m[ros] system workspaces not found, sourcing /opt/ros\e[0m"
source /opt/ros/"$TUE_ROS_DISTRO"/setup.bash
fi

Expand Down
2 changes: 2 additions & 0 deletions ros1/install.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- type: target
name: ros
64 changes: 64 additions & 0 deletions ros2-setup/install.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
#! /usr/bin/env bash

keyurl="https://raw.githubusercontent.com/ros/rosdistro/master/ros.key"
keyfile=/usr/share/keyrings/ros-archive-keyring.gpg
rosrepo="ros2"

rosrepourl="http://packages.ros.org/${rosrepo}/ubuntu $(lsb_release -sc) main"
sourcefile=/etc/apt/sources.list.d/ros2.list
sourceurl="deb [signed-by=${keyfile}] ${rosrepourl}"

ADD_ROS_SOURCES=false
ADD_ROS_GPG_KEY=false
FORCE_UPDATE=false

if [[ ! -f "${sourcefile}" ]]
then
tue-install-debug "Adding ROS2 sources to apt-get"
ADD_ROS_SOURCES=true
ADD_ROS_GPG_KEY=true
elif [[ $(cat "${sourcefile}") != "${sourceurl}" ]]
then
tue-install-debug "Updating ROS2 sources to apt-get"
ADD_ROS_SOURCES=true
ADD_ROS_GPG_KEY=true
else
tue-install-debug "ROS2 sources already added to apt-get"
fi

if [[ "${ADD_ROS_GPG_KEY}" == "false" ]]
then
if [[ ! -f "${keyfile}" ]]
then
tue-install-debug "No existing GPG key of ROS2 repository found, adding a new one"
ADD_ROS_GPG_KEY=true
elif tue-install-pipe gpg --import --import-options show-only "${keyfile}" 2> /dev/null | grep -q expired
then
tue-install-debug "Updating expired GPG key of ROS2 repository"
ADD_ROS_GPG_KEY=true
else
tue-install-debug "Not updating the existing GPG of the ROS2 repository"
fi
fi

if [[ "${ADD_ROS_GPG_KEY}" == "true" ]]
then
tue-install-pipe sudo curl -sSL "${keyurl}" -o "${keyfile}"
tue-install-debug "Successfully added/updated ROS2 repository GPG key"

FORCE_UPDATE=true
fi

if [[ "${ADD_ROS_SOURCES}" == "true" ]]
then
echo "${sourceurl}" | sudo tee "${sourcefile}" > /dev/null
tue-install-debug "Successfully added/updated ROS2 source file in apt"

FORCE_UPDATE=true
fi

if [[ "${FORCE_UPDATE}" == "true" ]]
then
tue-install-apt-get-update
tue-install-debug "Successfully updated ROS2 sources"
fi
20 changes: 20 additions & 0 deletions ros2/install.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#! /usr/bin/env bash
# shellcheck disable=SC1090

if [ -z "$TUE_ROS_DISTRO" ]
then
tue-install-error "TUE_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

# Setup the build environment
mkdir -p "$TUE_SYSTEM_DIR"

if [ ! -f "$TUE_SYSTEM_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"
fi
8 changes: 8 additions & 0 deletions ros2/install.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
- type: target
name: ros2-setup

- type: target-now
name: colcon

- type: target-now
name: build-essential
43 changes: 43 additions & 0 deletions ros2/setup
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#! /usr/bin/env bash

if [ -z "$TUE_ROS_DISTRO" ]
then
echo "[ros2] TUE_ROS_DISTRO was not set"
return 1
fi

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

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

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

# shellcheck disable=SC2016
ROSCONSOLE_FORMAT='[${severity}][${node}][${time}]: ${message}'
export ROSCONSOLE_FORMAT

# shellcheck disable=SC2016
# Make eProsima DDS implementation default
export RMW_IMPLEMENTATION=rmw_fastrtps_cpp