-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2d3e684
commit 13e6302
Showing
3 changed files
with
108 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
#!/usr/bin/env bash | ||
# downloads, builds, and installs ROS2 packages from source in $ROS_WORKSPACE directory | ||
# for example: ros2_install.sh xacro teleop_twist_joy | ||
set -ex | ||
|
||
source $ROS_ROOT/install/setup.bash | ||
export ROS_PACKAGE_PATH=${AMENT_PREFIX_PATH} | ||
|
||
: "${ROS_WORKSPACE:=${ROS_ROOT}}" | ||
: "${ROSDEP_SKIP_KEYS:=gazebo11 libgazebo11-dev libopencv-dev libopencv-contrib-dev libopencv-imgproc-dev python-opencv python3-opencv}" | ||
|
||
echo "ROS2 building packages in $ROS_WORKSPACE => $@" | ||
|
||
mkdir -p $ROS_WORKSPACE/src | ||
cd $ROS_WORKSPACE | ||
|
||
if [[ $1 == http* ]]; then | ||
SOURCE="git_clone" | ||
cd src | ||
git clone $1 | ||
cd ../ | ||
else | ||
SOURCE="rosinstall_generator" | ||
rosinstall_generator --deps --exclude RPP --rosdistro ${ROS_DISTRO} $@ > ros2.${ROS_DISTRO}.rosinstall | ||
cat ros2.${ROS_DISTRO}.rosinstall | ||
vcs import src/ < ros2.${ROS_DISTRO}.rosinstall | ||
|
||
apt-get update | ||
|
||
rosdep install -y \ | ||
--ignore-src \ | ||
--from-paths src \ | ||
--rosdistro ${ROS_DISTRO} \ | ||
--skip-keys "${ROSDEP_SKIP_KEYS}" | ||
|
||
rm -rf /var/lib/apt/lists/* | ||
apt-get clean | ||
fi | ||
|
||
if [ "${ROS_WORKSPACE}" = "${ROS_ROOT}" ]; then | ||
COLCON_FLAGS="--merge-install" | ||
else | ||
COLCON_FLAGS="--symlink-install" | ||
fi | ||
|
||
colcon build ${COLCON_FLAGS} --base-paths src --event-handlers console_direct+ | ||
|
||
#rm -rf ${ROS_WORKSPACE}/src | ||
#rm -rf ${ROS_WORKSPACE}/logs | ||
#rm -rf ${ROS_WORKSPACE}/build | ||
|
||
#rm ${ROS_WORKSPACE}/*.rosinstall | ||
|
||
if grep $ROS_WORKSPACE /ros_entrypoint.sh; then | ||
echo "workspace $ROS_WORKSPACE was already set to be sourced on startup:" | ||
else | ||
tac /ros_entrypoint.sh | sed -e "3iros_source_env $ROS_WORKSPACE/install/setup.bash" | tac | tee /ros_entrypoint.sh | ||
echo "added $ROS_WORKSPACE to be sourced on startup:" | ||
fi | ||
|
||
echo "" | ||
cat /ros_entrypoint.sh | ||
|
||
if [ "$SOURCE" = "rosinstall_generator" ]; then | ||
source $ROS_WORKSPACE/install/setup.bash | ||
ros_packages=$(ros2 pkg list) | ||
echo "ROS2 packages installed:" | ||
echo "$ros_packages" | ||
if echo "$ros_packages" | grep "$@"; then | ||
echo "$@ found" | ||
else | ||
echo "$@ not found" | ||
exit 1 | ||
fi | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#!/bin/bash | ||
#set -e | ||
|
||
function ros_source_env() | ||
{ | ||
if [ -f "$1" ]; then | ||
echo "sourcing $1" | ||
source "$1" | ||
fi | ||
#else | ||
# echo "notfound $1" | ||
#fi | ||
} | ||
|
||
if [[ "$ROS_DISTRO" == "melodic" || "$ROS_DISTRO" == "noetic" ]]; then | ||
ros_source_env "/opt/ros/$ROS_DISTRO/setup.bash" | ||
else | ||
ros_source_env "$ROS_ROOT/install/setup.bash" | ||
|
||
#echo "ROS_PACKAGE_PATH $ROS_PACKAGE_PATH" | ||
#echo "COLCON_PREFIX_PATH $COLCON_PREFIX_PATH" | ||
#echo "AMENT_PREFIX_PATH $AMENT_PREFIX_PATH" | ||
#echo "CMAKE_PREFIX_PATH $CMAKE_PREFIX_PATH" | ||
fi | ||
|
||
echo "ROS_DISTRO $ROS_DISTRO" | ||
echo "ROS_ROOT $ROS_ROOT" | ||
|
||
export AMENT_PREFIX_PATH=${AMENT_PREFIX_PATH}:${CMAKE_PREFIX_PATH} | ||
exec "$@" |