|
#!/bin/sh |
|
|
|
current_dir=$(pwd) |
|
|
|
finish(){ |
|
unset nav_ws |
|
cd $current_dir |
|
unset current_dir |
|
if [ $1 -eq 1 ]; then |
|
return 1 |
|
fi |
|
return 0 |
|
} |
|
|
|
setup_navigation() { |
|
trap 'return 1' SIGINT |
|
|
|
if [ -z "$ROS_DISTRO" ]; then |
|
echo "ROS_DISTRO is not set, assuming ros-indigo is installed." |
|
export ROS_DISTRO=indigo |
|
else |
|
echo "Using ros-$ROS_DISTRO for overlay." |
|
fi |
|
|
|
# chekcing only under /opt/ros for ros installation |
|
if [ ! -f /opt/ros/$ROS_DISTRO/setup.sh ] |
|
then |
|
echo "You specified ros-$ROS_DISTRO, however I can't find /opt/ros/$ROS_DISTRO/setup.sh, stopping now." |
|
return 1 |
|
fi |
|
|
|
if [ -z "$NAVIGATION_WS" ]; then |
|
echo "NAVIGATION_WS is not set. Please specify where do you want to create the catkin workspace:" |
|
read nav_ws |
|
if [ -z "$nav_ws" ]; then |
|
nav_ws=$(pwd) |
|
fi |
|
export nav_ws |
|
echo "Using catkin workspace under $nav_ws." |
|
else |
|
nav_ws=$NAVIGATION_WS |
|
echo "Using catking workspace under $nav_ws." |
|
fi |
|
|
|
# install prerequisites |
|
echo "Installing prerequisites ..." |
|
sudo apt-get install ros-$ROS_DISTRO-navigation ros-$ROS_DISTRO-gmapping python-rosinstall python-catkin-tools ros-indigo-libg2o |
|
|
|
# check if prerequisites' installation worked |
|
if [ ! -d "/opt/ros/$ROS_DISTRO/share/navigation" ] || \ |
|
[ ! -d "/opt/ros/$ROS_DISTRO/share/gmapping" ] || \ |
|
[ ! -f "/usr/bin/catkin" ] || \ |
|
[ ! -f "/usr/bin/rosws" ]; then |
|
echo "Either you cancelled the installation of prerequisites or it failed, stopping now." |
|
return 1 |
|
fi |
|
|
|
echo "Downloading navigation packages..." |
|
sed -i.bak s/ROS_DISTRO/$ROS_DISTRO/g $current_dir/rosinstall |
|
mkdir -p $nav_ws/src && cp $current_dir/rosinstall $nav_ws/src/.rosinstall |
|
cd $nav_ws/src && rosws update |
|
|
|
# check if navigation packages are downloaded |
|
git_check_fail=0 |
|
[ "$(git -C "$nav_ws/src/navigation" symbolic-ref --short HEAD)" = "$ROS_DISTRO-devel" ] || git_check_fail=1 |
|
[ "$(git -C "$nav_ws/src/hanp_msgs" symbolic-ref --short HEAD)" = "$ROS_DISTRO-devel" ] || git_check_fail=1 |
|
[ "$(git -C "$nav_ws/src/hanp_layer" symbolic-ref --short HEAD)" = "$ROS_DISTRO-devel" ] || git_check_fail=1 |
|
[ "$(git -C "$nav_ws/src/hanp_filters" symbolic-ref --short HEAD)" = "$ROS_DISTRO-devel" ] || git_check_fail=1 |
|
[ "$(git -C "$nav_ws/src/hanp_prediction" symbolic-ref --short HEAD)" = "$ROS_DISTRO-devel" ] || git_check_fail=1 |
|
[ "$(git -C "$nav_ws/src/hanp_local_planner" symbolic-ref --short HEAD)" = "$ROS_DISTRO-devel" ] || git_check_fail=1 |
|
[ "$(git -C "$nav_ws/src/hanp_head_behavior" symbolic-ref --short HEAD)" = "$ROS_DISTRO-devel" ] || git_check_fail=1 |
|
[ "$(git -C "$nav_ws/src/pr2_point_head" symbolic-ref --short HEAD)" = "$ROS_DISTRO-devel" ] || git_check_fail=1 |
|
|
|
if [ $git_check_fail -eq 1 ]; then |
|
echo "One of the repositories failed to download properly, stopping now." |
|
return 1 |
|
fi |
|
|
|
echo "Building navigation packages..." |
|
cd $nav_ws && source /opt/ros/$ROS_DISTRO/setup.sh && catkin build |
|
|
|
echo -e "Done.\n\nYou can now source $nav_ws/devel/setup.{sh|bash|zsh}.\n" |
|
return 0 |
|
} |
|
|
|
setup_navigation |
|
finish $? |