Created
February 6, 2020 12:08
-
-
Save Geekgineer/7a371d2bcdac6a92a2280e82d57f3b51 to your computer and use it in GitHub Desktop.
ROS Melodic Install and WS config script
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
#!/bin/bash | |
# Apache License 2.0 | |
# Copyright (c) 2019, Abdalrahman M. Amer. | |
echo " R O S M E L O D I C" | |
echo "" | |
echo "Starting ROS installing script ..." | |
echo "" | |
echo "[Note] Target OS version >>> Ubuntu 18.04.x (Bionic Beaver)" | |
echo "[Note] Target ROS version >>> ROS Melodic" | |
echo "[Note] Catkin workspace >>> $HOME/catkin_ws" | |
echo "" | |
echo "PRESS [ENTER] TO CONTINUE THE INSTALLATION" | |
echo "IF YOU WANT TO CANCEL, PRESS [CTRL] + [C]" | |
read | |
echo "Installing and configuring ROS ..." | |
echo "[Set the target OS, ROS version and name of catkin workspace]" | |
name_os_version=${name_os_version:="bionic"} | |
name_ros_version=${name_ros_version:="melodic"} | |
name_catkin_workspace=${name_catkin_workspace:="catkin_ws"} | |
echo "[Update the package lists and upgrade them]" | |
sudo apt-get update -y | |
sudo apt-get upgrade -y | |
echo "[Install build environment, the chrony, ntpdate and set the ntpdate]" | |
sudo apt-get install -y chrony ntpdate build-essential | |
sudo ntpdate ntp.ubuntu.com | |
echo "[Add the ROS repository]" | |
if [ ! -e /etc/apt/sources.list.d/ros-latest.list ]; then | |
sudo sh -c "echo \"deb http://packages.ros.org/ros/ubuntu ${name_os_version} main\" > /etc/apt/sources.list.d/ros-latest.list" | |
fi | |
echo "[Download the ROS keys]" | |
roskey=`apt-key list | grep "Open Robotics"` | |
if [ -z "$roskey" ]; then | |
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654 | |
fi | |
echo "[Check the ROS keys]" | |
roskey=`apt-key list | grep "Open Robotics"` | |
if [ -n "$roskey" ]; then | |
echo "[ROS key exists in the list]" | |
else | |
echo "[Failed to receive the ROS key, aborts the installation]" | |
exit 0 | |
fi | |
echo "[Update the package lists and upgrade them]" | |
sudo apt-get update -y | |
sudo apt-get upgrade -y | |
echo "[Install the ros-desktop-full and all rqt plugins]" | |
sudo apt-get install -y ros-$name_ros_version-desktop-full ros-$name_ros_version-rqt-* | |
echo "[Initialize rosdep]" | |
sudo sh -c "rosdep init" | |
rosdep update | |
echo "[Environment setup and getting rosinstall]" | |
source /opt/ros/$name_ros_version/setup.sh | |
sudo apt-get install -y python-rosinstall python-catkin-tools | |
echo "[Make the catkin workspace and test the catkin build]" | |
mkdir -p $HOME/$name_catkin_workspace/src | |
cd $HOME/$name_catkin_workspace/src | |
catkin_init_workspace | |
cd $HOME/$name_catkin_workspace | |
catkin build | |
echo "[Set the ROS evironment]" | |
sh -c "echo \"alias eb='nano ~/.bashrc'\" >> ~/.bashrc" | |
sh -c "echo \"alias sb='source ~/.bashrc'\" >> ~/.bashrc" | |
sh -c "echo \"alias gs='git status'\" >> ~/.bashrc" | |
sh -c "echo \"alias gp='git pull'\" >> ~/.bashrc" | |
sh -c "echo \"alias cw='cd ~/$name_catkin_workspace'\" >> ~/.bashrc" | |
sh -c "echo \"alias cs='cd ~/$name_catkin_workspace/src'\" >> ~/.bashrc" | |
sh -c "echo \"alias cm='cd ~/$name_catkin_workspace && catkin_make'\" >> ~/.bashrc" | |
sh -c "echo \"alias x='rosnode kill -a & killall -9 gazebo & killall -9 gzserver & killall -9 gzclient & killall -9 rosmaster & killall -9 rviz & rosnode kill -a '\" >> ~/.bashrc" | |
sh -c "echo \"source /opt/ros/$name_ros_version/setup.bash\" >> ~/.bashrc" | |
sh -c "echo \"source ~/$name_catkin_workspace/devel/setup.bash\" >> ~/.bashrc" | |
sh -c "echo \"export ROS_MASTER_URI=http://localhost:11311\" >> ~/.bashrc" | |
sh -c "echo \"export ROS_HOSTNAME=localhost\" >> ~/.bashrc" | |
source $HOME/.bashrc | |
echo " [Done !!!]" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment