Last active
March 19, 2024 10:55
-
-
Save simonbogh/8e6ca46eae2d856530da42b8f9ec4321 to your computer and use it in GitHub Desktop.
One-click install of ROS Noetic on Ubuntu 20.04
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 | |
# Author: Simon Bøgh | |
# Year: 2024 | |
# Run the script: | |
# chmod +x install_ros_noetic.sh | |
# ./install_ros_noetic.sh | |
echo "###################################################" | |
echo "Starting ROS Noetic installation on Ubuntu 20.04" | |
echo "###################################################" | |
# Update and install dependencies | |
sudo apt update | |
sudo apt install -y lsb-release gnupg2 curl | |
# Setup sources.list | |
sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list' | |
# Set up keys | |
curl -s https://raw.githubusercontent.com/ros/rosdistro/master/ros.asc | sudo apt-key add - | |
# Installation options | |
echo "###################################################" | |
echo "Please choose ROS Noetic installation type:" | |
echo "###################################################" | |
echo "1. Desktop-Full Install: Everything in Desktop plus 2D/3D simulators and 2D/3D perception packages" | |
echo "2. Desktop Install: ROS, rqt, rviz, and robot-generic libraries" | |
echo "3. ROS-Base: Bare bones (ROS package, build, and communication libraries. No GUI tools)" | |
read -p "Enter your choice (1/2/3): " install_choice | |
case $install_choice in | |
1) | |
sudo apt update | |
sudo apt install -y ros-noetic-desktop-full | |
;; | |
2) | |
sudo apt update | |
sudo apt install -y ros-noetic-desktop | |
;; | |
3) | |
sudo apt update | |
sudo apt install -y ros-noetic-ros-base | |
;; | |
*) | |
echo "Invalid option. Exiting." | |
exit 1 | |
;; | |
esac | |
# Environment setup | |
source /opt/ros/noetic/setup.bash | |
echo "source /opt/ros/noetic/setup.bash" >> ~/.bashrc | |
source ~/.bashrc | |
# Dependencies for building packages | |
sudo apt install -y python3-rosdep python3-rosinstall python3-rosinstall-generator python3-wstool build-essential | |
# Initialize rosdep | |
sudo rosdep init | |
rosdep update | |
# Install catkin tools | |
sudo apt-get update | |
sudo apt-get install -y python3-catkin-tools | |
# Ask user for workspace name | |
echo "#######################################################################################" | |
read -p "Enter a name for your catkin workspace (it will be created in your home directory): " workspace_name | |
echo "#######################################################################################" | |
# Create, build and source catkin workspace | |
mkdir -p ~/$workspace_name/src | |
cd ~/$workspace_name | |
catkin init | |
catkin build | |
source ~/$workspace_name/devel/setup.bash | |
# Add workspace to .bashrc for automatic sourcing | |
echo "source ~/$workspace_name/devel/setup.bash" >> ~/.bashrc | |
echo "###################################################################################" | |
echo "Your catkin workspace '$workspace_name' has been created in your home directory." | |
echo "###################################################################################" | |
# Placeholder for creating and building packages if needed | |
# This section is commented out because it might not be universally required. | |
# cd src | |
# catkin create pkg pkg_a | |
# catkin create pkg pkg_b | |
# catkin create pkg pkg_c --catkin-deps pkg_a | |
# catkin create pkg pkg_d --catkin-deps pkg_a pkg_b | |
# catkin list | |
# catkin build | |
# source ~/$workspace_name/devel/setup.bash | |
# catkin clean | |
echo "###################################################################################" | |
echo "ROS Noetic installation and workspace setup completed successfully." | |
echo "###################################################################################" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment