Skip to content

Commit

Permalink
Merge pull request #78 from prl-mushr/noetic_bashscript_updates
Browse files Browse the repository at this point in the history
Noetic bashscript updates
  • Loading branch information
schmittlema authored May 31, 2022
2 parents aaf5122 + d735b44 commit 129fc2a
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 116 deletions.
1 change: 0 additions & 1 deletion mushr_utils/install/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ RUN apt-get update -y \
RUN mkdir install_scripts

# ROS Noetic
#ADD $INSTALL_PATH/install_scripts/mushr_install_ros.bash install_scripts/mushr_install_ros.bash
ADD src/mushr/mushr_utils/install/install_scripts/mushr_install_ros.bash install_scripts/mushr_install_ros.bash
RUN chmod +x install_scripts/mushr_install_ros.bash && install_scripts/mushr_install_ros.bash

Expand Down
10 changes: 5 additions & 5 deletions mushr_utils/install/docker-compose-build.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
version: "3.4"
services:
mushr_noetic:
image: mushr/mushr:${OS_TYPE}
#image: mushr/mushr:${MUSHR_OS_TYPE}
build:
context: ${WS_PATH}/catkin_ws
dockerfile: ${INSTALL_PATH}/Dockerfile
context: ${MUSHR_WS_PATH}/catkin_ws
dockerfile: ${MUSHR_INSTALL_PATH}/Dockerfile
args:
REAL: ${REAL_ROBOT}
WS_PATH: ${WS_PATH}
MUSHR_WS_PATH: ${MUSHR_WS_PATH}
network_mode: "host"
privileged: true
devices:
Expand All @@ -28,7 +28,7 @@ services:
- /tmp/.X11-unix:/tmp/.X11-unix
- /dev:/dev
- /dev/input:/dev/input
- ${WS_PATH}/catkin_ws:/root/catkin_ws # Runtime attach
- ${MUSHR_WS_PATH}/catkin_ws:/root/catkin_ws # Runtime attach
environment:
- DISPLAY=${DISPLAY}
- QT_X11_NO_MITSHM=1
Expand Down
4 changes: 2 additions & 2 deletions mushr_utils/install/docker-compose-cpu.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
version: "3.4"
services:
mushr_noetic:
image: mushr/mushr:${OS_TYPE}
image: mushr/mushr:${MUSHR_OS_TYPE}
privileged: true
volumes:
- ${WS_PATH}/catkin_ws:/root/catkin_ws # Runtime attach
- ${MUSHR_WS_PATH}/catkin_ws:/root/catkin_ws # Runtime attach
environment:
- DISPLAY=${DISPLAY}
- QT_X11_NO_MITSHM=1
30 changes: 0 additions & 30 deletions mushr_utils/install/docker-compose-gpu.yml

This file was deleted.

2 changes: 1 addition & 1 deletion mushr_utils/install/docker-compose-robot.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
version: "3.4"
services:
mushr_noetic:
image: mushr/mushr:robot
image: mushr/mushr:${MUSHR_OS_TYPE}
network_mode: "host"
privileged: true
devices:
Expand Down
8 changes: 6 additions & 2 deletions mushr_utils/install/install_scripts/mushr_install_deps.bash
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ apt-get update
apt-get install -y python3-vcstool python3-pip

# Install extra ROS packages
apt-get install -y ros-noetic-ackermann-msgs ros-noetic-map-server ros-noetic-urg-node ros-noetic-robot-state-publisher ros-noetic-xacro ros-noetic-joy ros-noetic-ddynamic-reconfigure ros-noetic-fake-localization ros-noetic-gmapping ros-noetic-rosbridge-suite
apt-get install -y ros-noetic-ackermann-msgs ros-noetic-map-server ros-noetic-urg-node ros-noetic-robot-state-publisher ros-noetic-xacro ros-noetic-joy ros-noetic-ddynamic-reconfigure ros-noetic-fake-localization ros-noetic-gmapping ros-noetic-rosbridge-suite ros-noetic-sbpl

# Install catkin tools
wget http://packages.ros.org/ros.key -O - | apt-key add -
Expand All @@ -37,4 +37,8 @@ mkdir ~/.rviz
cp ~/catkin_ws/src/mushr/mushr_utils/rviz/default.rviz ~/.rviz/

# Set ROS_IP
echo "export ROS_IP=\$(ifconfig wlan0 | grep 'inet ' | awk '{print \$2}')" >> ~/.bashrc
if [[ $MUSHR_REAL_ROBOT == 1 ]]; then
echo "export ROS_IP=\$(ifconfig wlan0 | grep 'inet ' | awk '{print \$2}')" >> ~/.bashrc
else
echo "export ROS_IP=\$(ifconfig eth0 | grep 'inet ' | awk '{print \$2}')" >> ~/.bashrc
fi
110 changes: 35 additions & 75 deletions mushr_utils/install/mushr_install.bash
Original file line number Diff line number Diff line change
@@ -1,63 +1,47 @@
#!/bin/bash
pushd `dirname $0`

# Detect OS
export OS_TYPE="$(uname -s)"
if [[ $OS_TYPE == "Darwin" ]]; then
export SHELL_PROFILE=".zshrc"
else
export OS_TYPE="$(uname -i)"
export SHELL_PROFILE=".bashrc"
fi
export MUSHR_OS_TYPE="$(uname -s)"

# Are we in the right place to be running this?
if [[ ! -f mushr_install.bash ]]; then
echo Wrong directory! Change directory to the one containing mushr_install.bash
exit 1
fi
export INSTALL_PATH=$(pwd)
export MUSHR_INSTALL_PATH=$(pwd)

# Real robot or on a laptop?
read -p "Are you installing on robot and need all the sensor drivers? (y/n) " -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
export REAL_ROBOT=1
export OS_TYPE=robot
else
export REAL_ROBOT=0
fi

# NVIDIA GPU?
read -p "Do you have a nvidia gpu with installed drivers? (y/n) " -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
if [[ $REAL_ROBOT == 1 ]]; then
export COMPOSE_FILE=docker-compose-robot.yml
else
export COMPOSE_FILE=docker-compose-gpu.yml
fi
export MUSHR_REAL_ROBOT=1
else
export COMPOSE_FILE=docker-compose-cpu.yml
export MUSHR_REAL_ROBOT=0
fi

# Build from scratch (assumes GPU)?
# Build from scratch
read -p "Build from scratch? (Not recommended, takes much longer than pulling ready-made image) (y/n) " -r
echo
export BUILD_FROM_SCRATCH=0
if [[ $REPLY =~ ^[Yy]$ ]]; then
export BUILD_FROM_SCRATCH=1
export COMPOSE_FILE=docker-compose-build.yml
export MUSHR_COMPOSE_FILE=docker-compose-build.yml
fi

# curl and dep keys
if [[ $OS_TYPE != "Darwin" ]]; then
if [[ $MUSHR_OS_TYPE == "Linux" ]]; then
sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'
sudo apt-get update
sudo apt-get install -y curl
curl -s https://raw.githubusercontent.com/ros/rosdistro/master/ros.asc | sudo apt-key add -

# Reset to specific hardware
export MUSHR_OS_TYPE="$(uname -i)"
fi

# Robot specific settings
if [[ $REAL_ROBOT == 1 ]]; then
if [[ $MUSHR_REAL_ROBOT == 1 ]]; then
echo Running robot specific commands

# Don't need sudo for docker
Expand Down Expand Up @@ -100,63 +84,39 @@ if [[ $REAL_ROBOT == 1 ]]; then
fi

# vcstool https://github.com/dirk-thomas/vcstool
if [[ $OS_TYPE != "Darwin" ]]; then
if [[ $MUSHR_OS_TYPE != "Darwin" ]]; then
sudo apt-get update && sudo apt install -y python3-vcstool
else
sudo pip install vcstool
fi

# Make catkin_ws outside container for easy editing
if [[ ! -d "../../../../../catkin_ws" ]]; then
mkdir -p ../../../catkin_ws/src
cd ../../../ && mv mushr catkin_ws/src/mushr
pip install vcstool
fi

# Pull repos
export WS_PATH=$(pwd | sed 's:/catkin_ws.*::')
cd $WS_PATH/catkin_ws/src/ && vcs import < mushr/base-repos.yaml && vcs import < mushr/nav-repos.yaml
cd mushr/mushr_utils/install/ && export INSTALL_PATH=$(pwd)

# Make sure environment Variables are always set
if ! grep -Fq "export INSTALL_PATH=" ~/$SHELL_PROFILE || [[ $BUILD_FROM_SCRATCH ]] ; then
echo "export INSTALL_PATH=${INSTALL_PATH}" >> ~/$SHELL_PROFILE
fi
if ! grep -Fq "export REAL_ROBOT=" ~/$SHELL_PROFILE || [[ $BUILD_FROM_SCRATCH ]] ; then
echo "export REAL_ROBOT=${REAL_ROBOT}" >> ~/$SHELL_PROFILE
fi
if ! grep -Fq "export WS_PATH=" ~/$SHELL_PROFILE || [[ $BUILD_FROM_SCRATCH ]] ; then
echo "export WS_PATH=${WS_PATH}" >> ~/$SHELL_PROFILE
fi
if ! grep -Fq "export COMPOSE_FILE=" ~/$SHELL_PROFILE || [[ $BUILD_FROM_SCRATCH=1 ]] ; then
echo "export COMPOSE_FILE=${COMPOSE_FILE}" >> ~/$SHELL_PROFILE
fi
if ! grep -Fq "export OS_TYPE=" ~/$SHELL_PROFILE || [[ $BUILD_FROM_SCRATCH=1 ]] ; then
echo "export OS_TYPE=${OS_TYPE}" >> ~/$SHELL_PROFILE
export MUSHR_WS_PATH=$(echo $MUSHR_INSTALL_PATH | sed 's:/catkin_ws.*::')
cd $MUSHR_WS_PATH/catkin_ws/src/ && vcs import < mushr/base-repos.yaml && vcs import < mushr/nav-repos.yaml

# Make custom mushr_noetic script
if [[ ! -f "${MUSHR_INSTALL_PATH}/mushr_noetic" ]]; then
cat <<- EOF > ${MUSHR_INSTALL_PATH}/mushr_noetic
export MUSHR_INSTALL_PATH=${MUSHR_INSTALL_PATH}
export MUSHR_REAL_ROBOT=${MUSHR_REAL_ROBOT}
export MUSHR_WS_PATH=${MUSHR_WS_PATH}
export MUSHR_COMPOSE_FILE=${MUSHR_COMPOSE_FILE}
export MUSHR_OS_TYPE=${MUSHR_OS_TYPE}
docker-compose -f \$MUSHR_INSTALL_PATH/\$MUSHR_COMPOSE_FILE run -p 9090:9090 mushr_noetic bash
EOF
chmod +x ${MUSHR_INSTALL_PATH}/mushr_noetic
sudo ln -s ${MUSHR_INSTALL_PATH}/mushr_noetic /usr/local/bin/
fi

# If laptop, don't build realsense2_camera, ydlidar, or push_button_utils
if [[ $REAL_ROBOT == 0 ]]; then
touch $WS_PATH/catkin_ws/src/mushr/mushr_hardware/push_button_utils/CATKIN_IGNORE
touch $WS_PATH/catkin_ws/src/mushr/mushr_hardware/ydlidar/CATKIN_IGNORE
touch $WS_PATH/catkin_ws/src/mushr/mushr_hardware/realsense/realsense2_camera/CATKIN_IGNORE
fi

# Shortcuts
if ! grep -Fq "alias mushr_noetic=" ~/$SHELL_PROFILE ; then
echo "alias mushr_noetic=\"docker-compose -f $INSTALL_PATH/$COMPOSE_FILE run -p 9090:9090 mushr_noetic bash\"" >> ~/$SHELL_PROFILE
if [[ $MUSHR_REAL_ROBOT == 0 ]]; then
for ignored_package in push_button_utils ydlidar realsense/realsense2_camera; do
touch $MUSHR_WS_PATH/catkin_ws/src/mushr/mushr_hardware/${ignored_package}/CATKIN_IGNORE
done
fi

# Make sure all devices are visible
if [[ $REAL_ROBOT == 1 ]]; then
if [[ $MUSHR_REAL_ROBOT == 1 ]]; then
sudo udevadm control --reload-rules && sudo udevadm trigger
fi

# Display permissions
if ! grep -Fxq "xhost + >> /dev/null" ~/$SHELL_PROFILE ; then
read -p $'Add "xhost +" to $SHELL_PROFILE? This enables GUI from docker but is a security risk.\nIf no, each time you run the docker container you will need to execute this command.\nAdd xhost + $SHELL_PROFILE? (y/n) ' -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
echo WARNING: Adding "xhost +" to $SHELL_PROFILE
echo "xhost + >> /dev/null" >> ~/$SHELL_PROFILE && source ~/$SHELL_PROFILE
fi
fi
popd

0 comments on commit 129fc2a

Please sign in to comment.