Skip to content

Instantly share code, notes, and snippets.

@harmishhk
Last active December 5, 2017 11:10
Show Gist options
  • Save harmishhk/2e6baec83d696b5f5c212110d1d04dcc to your computer and use it in GitHub Desktop.
Save harmishhk/2e6baec83d696b5f5c212110d1d04dcc to your computer and use it in GitHub Desktop.
scripts for installing human-aware robot navigation

This repository contains script for installing packages related to human-aware navigation.

Requirements

Ubuntu 14.04 with ROS Indigo.

Usage

git clone https://gist.github.com/harmishhk/2e6baec83d696b5f5c212110d1d04dcc $HOME/ros/navigation_setup
cd ~/ros/navigation_setup && ./setup.sh

Script setup.sh runs the following steps.

Steps

  1. Create a catkin workspace:

    export ROS_DISTRO=indigo
    export NAVIGATION_WS=$HOME/ros/navigation_ws
    mkdir -p $NAVIGATION_WS/src
  2. Install prerequisites:

    sudo apt-get install \
        ros-$ROS_DISTRO-navigation \
        ros-$ROS_DISTRO-gmapping \
        python-rosinstall \
        python-catkin-tools
  3. Download repositories:

    sed -i.bak s/ROS_DISTRO/$ROS_DISTRO/g $(pwd)/rosinstall
    cp rosinstall $NAVIGATION_WS/src/.rosinstall
    cd $NAVIGATION_WS/src/ && rosws update
  4. Build catkin workspace:

    source /opt/ros/$ROS_DISTRO/setup.sh
    catkin build
root = true
[*]
indent_style = space
indent_size = 4
insert_final_newline = true
trim_trailing_whitespace = true
FROM harmish/ros:indigo-navigation
# add user: username=navuser, password=navuser
RUN apt-get update && \
useradd -m -p paPgYflh0MBBQ -s /bin/bash -d /home/navuser -g sudo navuser
# copy setup files
ADD setup.sh /home/navuser/navigation-setup/setup.sh
ADD rosinstall /home/navuser/navigation-setup/rosinstall
RUN chown -R navuser:sudo /home/navuser/navigation-setup
# switch user to navuser
USER navuser
WORKDIR /home/navuser/navigation-setup
CMD ["bash", "/home/navuser/navigation-setup/setup.sh"]
- git: {local-name: 'navigation', uri: 'https://github.com/harmishhk/navigation', version: 'ROS_DISTRO-devel'}
- git: {local-name: 'hanp_msgs', uri: 'https://github.com/harmishhk/hanp_msgs', version: 'ROS_DISTRO-devel'}
- git: {local-name: 'hanp_layer', uri: 'https://github.com/harmishhk/hanp_layer', version: 'ROS_DISTRO-devel'}
- git: {local-name: 'hanp_filters', uri: 'https://github.com/harmishhk/hanp_filters', version: 'ROS_DISTRO-devel'}
- git: {local-name: 'hanp_prediction', uri: 'https://github.com/harmishhk/hanp_prediction', version: 'ROS_DISTRO-devel'}
- git: {local-name: 'hanp_local_planner', uri: 'https://github.com/harmishhk/hanp_local_planner', version: 'ROS_DISTRO-devel'}
- git: {local-name: 'hanp_head_behavior', uri: 'https://github.com/harmishhk/hanp_head_behavior', version: 'ROS_DISTRO-devel'}
- git: {local-name: 'pr2_point_head', uri: 'https://github.com/harmishhk/pr2_point_head', version: 'ROS_DISTRO-devel'}
- git: {local-name: 'costmap_converter', uri: 'https://github.com/rst-tu-dortmund/costmap_converter', version: 'master'}
- git: {local-name: 'tf_republisher', uri: 'https://github.com/harmishhk/tf_republisher', version: 'master'}
- setup-file:
local-name: /opt/ros/ROS_DISTRO/setup.sh
- other:
local-name: /opt/ros/ROS_DISTRO/share/ros
#!/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 $?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment