Ubuntu20.04下一键安装ROS1 Noetic

简介: 本文提供了一个简化在Ubuntu 20.04系统上安装ROS1 Noetic过程的一键安装脚本工具,该脚本通过优化配置和使用清华大学镜像源,加速了国内用户的下载速度,并自动完成环境设置和依赖安装,同时提供了详细的使用说明和源码。

一键安装ROS1 Noetic

作者出于帮助国内朋友安装ROS需求,制作了这个脚本工具,能够帮助中国地区的朋友安装ROS1 Noetic Ubuntu20.04,并配置相关环境。

使用方式:

复制这行命令,在终端中执行:

wget -O $HOME/ros1_noetic_install.sh https://raw.githubusercontent.com/hermanye996/ros-install-one-click/main/ros1_noetic_install.sh && sudo chmod +x $HOME/ros1_noetic_install.sh && sudo bash $HOME/ros1_noetic_install.sh && rm $HOME/ros1_noetic_install.sh

如果无法连接到raw.githubusercontent.com,请先访问源码所在的托管网站,在根目录/home/<your_username>下手动下载ros1_noetic_install.sh文件,执行以下命令:

sudo bash ros1_noetic_install.sh

在这里插入图片描述

源码

该源码在Github开源,许可证为Apache License 2.0
最新源码链接:ros-install-one-click
V1.3源码如下,可供参考:

#!/bin/bash
#
# Description: 
# This is a shell script for installing ROS1 Noetic and its dependencies in Ubuntu 20.04 in China.
# It uses mirrors from Tsinghua University to speed up the download.
# The script also sets up the sudo privileges and modifies the sources.list file to update the repositories accordingly.
# It installs ROS1 Noetic and its dependencies, initializes rosdep, and verifies the installation by running roscore.
# It logs the installation progress and redirects the output to the console and logs files.
#
# Version: 1.3
# Date: 2023-06-12
# Author: Herman Ye @Realman Robotics
# License: Apache License 2.0
# Warning: This script is ONLY for ROS1 Noetic in ubuntu 20.04
# set -x
set -e



# UBUNTU CONFIGURATION BEGINS HERE

# Check if script is run as root (sudo)
if [ "$(id -u)" != "0" ]; then
    echo "This script must be run with sudo privileges. for example: sudo bash ros1_noetic_install.sh"
    read -p "Press any key to exit..."
    exit 1
fi
# Get script directory
SCRIPT_DIR=$(dirname "$0")
# Get the username of the non-root user
USERNAME=$SUDO_USER
echo "Current user is: $USERNAME"
# Save logs to files
LOG_FILE="${SCRIPT_DIR}/ros1_noetic_install.log"
ERR_FILE="${SCRIPT_DIR}/ros1_noetic_install.err"
rm -f ${LOG_FILE}
rm -f ${ERR_FILE}

# Redirect output to console and log files
exec 1> >(tee -a ${LOG_FILE} )
exec 2> >(tee -a ${ERR_FILE} >&2)

# Output log info to console
echo "ROS1 Noetic installation started!"  
echo "Installation logs will be saved to ${LOG_FILE}"
echo "Installation errors will be saved to ${ERR_FILE}"

# No Password sudo config
sudo sed -i 's/^%sudo.*/%sudo ALL=(ALL) NOPASSWD:ALL/g' /etc/sudoers

# Get architecture of the system
if [ $(uname -m) = "x86_64" ]; then
  MIRROR="https://mirrors.tuna.tsinghua.edu.cn/ubuntu/"
else
  MIRROR="https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/"
fi
echo "Current system architecture is: $(uname -m)"
echo "Current mirror is: $MIRROR"

# Backup original software sources
sudo cp /etc/apt/sources.list /etc/apt/sources.list.backup

# Clear original software sources
sudo echo "" > /etc/apt/sources.list

# Replace software sources
echo "deb $MIRROR focal main restricted universe multiverse" >> /etc/apt/sources.list
echo "deb $MIRROR focal-updates main restricted universe multiverse" >> /etc/apt/sources.list
echo "deb $MIRROR focal-backports main restricted universe multiverse" >> /etc/apt/sources.list

if [ $(uname -m) = "x86_64" ]; then
  echo "deb http://security.ubuntu.com/ubuntu/ focal-security main restricted universe multiverse" >> /etc/apt/sources.list
else
  echo "deb http://ports.ubuntu.com/ubuntu-ports/ focal-security main restricted universe multiverse" >> /etc/apt/sources.list
fi

# System update
sudo apt update
sudo apt upgrade -y

# Install pip
sudo apt install pip -y # If you haven't already installed pip

# Install gnome-terminal
sudo apt install gnome-terminal -y # If you haven't already installed gnome-terminal

# Set default pip source
pip config set global.index-url http://pypi.tuna.tsinghua.edu.cn/simple
pip config set global.trusted-host pypi.tuna.tsinghua.edu.cn

# ROS1 NOETIC INSTALLATION BEGINS HERE

# Configure your Ubuntu repositories
sudo add-apt-repository restricted
sudo add-apt-repository universe
sudo add-apt-repository multiverse

# Setup your 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'

# Add the ROS key
ros_key="${SCRIPT_DIR}/ros.key"
rm -f "${ros_key}"
wget http://packages.ros.org/ros.key
sudo apt-key add ros.key

# Update the system packages index to the latest version
sudo apt update

# Install Curl
sudo apt install curl -y # If you haven't already installed curl

# Install ROS1 Noetic
sudo apt install ros-noetic-desktop-full -y

# Install dependencies
sudo apt install python3-rosdep python3-rosinstall python3-rosinstall-generator python3-wstool build-essential -y

# Environment setup
if ! grep -q "source /opt/ros/noetic/setup.bash" /home/$USERNAME/.bashrc; then

    echo "# ROS1 Noetic Environment Setting" | sudo tee -a /home/$USERNAME/.bashrc
    echo "source /opt/ros/noetic/setup.bash" | sudo tee -a /home/$USERNAME/.bashrc
    echo "ROS1 Noetic environment setup added to /home/$USERNAME/.bashrc"
else
    echo "ROS1 Noetic environment is already set in /home/$USERNAME/.bashrc"
fi
source /home/$USERNAME/.bashrc

# Initialize rosdepc by fishros under BSD License
# https://pypi.org/project/rosdepc/#files
sudo pip install rosdep
sudo pip install rosdepc
# sudo pip install -i https://pypi.tuna.tsinghua.edu.cn/simple -U rosdep
# Init & update rosdep 
sudo rosdepc init > /dev/null
#sudo rosdep fix-permissions
# su -l $USERNAME -c 'rosdepc update' > /dev/null
echo "rosdepc init completed!"

# System update again
sudo apt update
sudo apt dist-upgrade -y

# Verifying ROS1 installation
clear
# Define the variables to be printed
TEXT1="ROS1 Noetic installation completed!"
TEXT2="Please open a new terminal and run roscore to verify the installation:"
TEXT3="roscore"

# Define the colors
RED='\033[0;31m'
BLUE='\033[0;34m'
GREEN='\033[1;32m'
NC='\033[0m'

# Calculate the center of the terminal window
TERMINAL_WIDTH=$(tput cols)
TEXT1_PADDING=$((($TERMINAL_WIDTH-${#TEXT1})/2))
TEXT2_PADDING=$((($TERMINAL_WIDTH-${#TEXT2})/2))
TEXT3_PADDING=$((($TERMINAL_WIDTH-${#TEXT3})/2))

# Print the text in the center of the screen in the desired colors
echo ""
echo ""
echo ""
echo ""
echo ""
echo ""
echo ""
echo ""
echo ""
echo ""
echo -e "${GREEN}$(printf '%*s' $TEXT1_PADDING)${TEXT1} ${NC}"
echo -e "${NC}$(printf '%*s' $TEXT2_PADDING)${TEXT2} ${NC}"
echo -e "${RED}$(printf '%*s' $TEXT3_PADDING)${TEXT3} ${NC}"
echo ""
echo ""
echo ""
echo ""
echo ""
echo ""
echo ""
echo ""
echo ""
echo ""
相关实践学习
使用ROS创建VPC和VSwitch
本场景主要介绍如何利用阿里云资源编排服务,定义资源编排模板,实现自动化创建阿里云专有网络和交换机。
阿里云资源编排ROS使用教程
资源编排(Resource Orchestration)是一种简单易用的云计算资源管理和自动化运维服务。用户通过模板描述多个云计算资源的依赖关系、配置等,并自动完成所有资源的创建和配置,以达到自动化部署、运维等目的。编排模板同时也是一种标准化的资源和应用交付方式,并且可以随时编辑修改,使基础设施即代码(Infrastructure as Code)成为可能。 产品详情:https://www.aliyun.com/product/ros/
目录
相关文章
|
2月前
|
Ubuntu 网络协议 应用服务中间件
在 Ubuntu 上安装 Nginx
在 Ubuntu 上安装和配置 Nginx 非常简单。首先更新系统包,然后通过 `apt` 安装 Nginx,检查服务状态并配置防火墙规则。访问服务器 IP 测试是否成功显示默认页面。还可管理服务、创建虚拟主机及排查常见问题,适合新手快速上手部署高性能 Web 服务。
256 0
|
28天前
|
存储 Ubuntu Docker
Ubuntu 安装 docker
本文介绍了在 Ubuntu 系统上安装 Docker 的详细步骤,包括卸载旧版本、设置 Docker 官方存储库、安装 Docker 包以及配置镜像源加速。首先通过移除旧版组件如 `docker.io` 和 `docker-compose` 等进行清理,然后添加官方 GPG 密钥并配置 APT 源,接着安装最新 Docker 组件。此外,还提供了阿里云和 1Panel 的镜像源配置方法以提升下载速度,并通过运行 `hello-world` 镜像测试安装是否成功。
599 3
Ubuntu 安装 docker
|
17天前
|
Ubuntu 机器人 定位技术
Loam在Ubuntu 18.04上的一站式安装指南
现在,你已经完成了Loam在Ubuntu 18.04上的一站式安装盛宴。从更新系统清洁,到搭建魔法环境的工作空间,再到召唤和激活Loam精髓的艺术——每步都妙不可言,每步都至关重要,让你在这场技术的饕餮盛宴中大显身手。
39 8
|
2月前
|
Ubuntu 开发工具
Ubuntu环境下以源码编译方式安装Vim的步骤介绍
以上就是在Ubuntu环境下以源码编译方式安装Vim的全部步骤。就像煮一杯咖啡,虽然过程中需要耐心和一些技巧,但等到你熟悉之后,你会发现,不仅可以定制自己喜欢的口味,过程中的乐趣也是不能忽视的。希望你在编译安装Vim的过程中,能体验到这份乐趣。
106 21
|
2月前
|
Ubuntu 定位技术 开发工具
在Ubuntu 20.04系统中安装SLAM库的具体操作步骤
以上是在Ubuntu 20.04系统中安装SLAM库的具体操作步骤。就像积木游戏,需要按照正确的步骤,适时地添加正确的部件,才能够构建出我们想要的积木模型。在现实操作中可能会遇到各种问题,就像积木构建中的各种困难,我们要有耐心和决心去解决它们,最后得到我们想要的结果。希望这个有趣的积木游戏比方能帮助你更好地理解SLAM库的安装过程,并在实际操作中得到应用。
94 34
|
2月前
|
Ubuntu 机器人 Shell
在Jetson TX2的Ubuntu18.04系统中安装ROS的教程
所有这些步骤并不复杂,但确实需要仔细一点。如果遇到问题,不要灰心,问题是解决问题的开始。保持耐心,细心阅读错误信息,通常情况下,问题的答案就藏在其中。祝ROS旅程顺利!
87 18
|
3月前
|
Ubuntu 关系型数据库 MySQL
在Ubuntu 22.04上配置和安装MySQL
以上就是在Ubuntu 22.04上配置和安装MySQL的步骤。这个过程可能看起来有点复杂,但只要按照步骤一步步来,你会发现其实并不难。记住,任何时候都不要急于求成,耐心是解决问题的关键。
310 30
|
2月前
|
Kubernetes Ubuntu 容器
在Ubuntu上安装kubectl、kubeadm和kubelet
好了,你已经掌握了在Ubuntu上安装kubectl、kubeadm和kubelet的高超技艺。是时候展示你新召唤出的力量,像一位真正的烹饪大师一样,开始独特的佳肴烹饪之旅吧!
115 13
|
9月前
|
Ubuntu 机器人 Linux
|
8月前
|
自动驾驶 安全 机器人
ROS2:从初识到深入,探索机器人操作系统的进化之路
前言 最近开始接触到基于DDS的这个系统,是在稚晖君的机器人项目中了解和认识到。于是便开始自己买书学习起来,感觉挺有意思的,但是只是单纯的看书籍,总会显得枯燥无味,于是自己又开始在网上找了一些视频教程结合书籍一起来看,便让我对ROS系统有了更深的认识和理解。 ROS的发展历程 ROS诞生于2007年的斯坦福大学,这是早期PR2机器人的原型,这个项目很快被一家商业公司Willow Garage看中,类似现在的风险投资一样,他们投了一大笔钱给这群年轻人,PR2机器人在资本的助推下成功诞生。 2010年,随着PR2机器人的发布,其中的软件正式确定了名称,就叫做机器人操作系统,Robot Op
266 14