Ubuntu20.04下一键安装Moveit

本文涉及的产品
资源编排,不限时长
简介: 本文提供了一个一键安装Moveit的脚本工具,旨在帮助中国地区的用户在Ubuntu 20.04系统上安装Moveit并配置相关环境。脚本包括安装必要包、创建catkin工作空间、克隆Moveit源代码和示例代码、使用rosdep安装依赖以及构建工作空间,并提供了详细的使用说明和源码。

一键安装Moveit

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

使用方式:

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

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

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

sudo bash moveit1_install.sh

注意:
如果你还未安装ROS1 Noetic,源码所在的托管网站也提供了一键安装ROS1 Noetic并配置Ubuntu环境的脚本

在这里插入图片描述

源码

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

#!/bin/bash
#
# Description: 
# This is a shell script for setting up a MoveIt workspace and downloading its source code along with the required dependencies on ROS1 Noetic in Ubuntu 20.04.
# The script installs necessary packages, creates a catkin workspace, and clones the MoveIt source code along with example code from the respective GitHub repositories.
# It then uses rosdep to install dependencies and builds the workspace using catkin.
# Finally, it adds the path of the workspace to the .bashrc file for easy access.
#
# Version: 1.0
# Date: 2023-06-13
# Author: Herman Ye @Realman Robotics
# License: Apache License 2.0
#
# Warning: This script assumes that the ubuntu20.04 system and ROS1 Noetic have been installed correctly
# If not, please execute ros1_noetic_install.sh first.
#
# set -x
set -e

# Get script directory
SCRIPT_DIR=$(dirname "$0")
# Get the username of the non-root user
USERNAME=$SUDO_USER
echo "Current user is: $USERNAME"

# 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 moveit1_install.sh"
    read -p "Press any key to exit..."
    exit 1
fi
echo "sudo privileges check passed"

# Check if script is run in ubuntu20.04
if [ "$(lsb_release -sc)" != "focal" ]; then
    echo "This script must be run in ubuntu20.04"
    read -p "Press any key to exit..."
    exit 1
fi

echo "ubuntu20.04 check passed"

# Check if script is run in ROS1 Noetic
if [[ "$(sudo -u $USERNAME dpkg -l ros-noetic-desktop-full)" == *ii* ]]; then
    echo "ROS1 Noetic check passed"
else
    echo "This script must be run with ROS1 Noetic-desktop-full"
    read -p "Press any key to exit..."
    exit 1
fi

# Save logs to files
LOG_FILE="${SCRIPT_DIR}/moveit1_install.log"
ERR_FILE="${SCRIPT_DIR}/moveit1_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)

# Add GitHub520 Host to host for GitHub access in China
# https://github.com/521xueweihan/GitHub520
sudo sed -i "/# GitHub520 Host Start/Q" /etc/hosts && curl https://raw.hellogithub.com/hosts >> /etc/hosts
echo "GitHub520 Host added to host file"
# sudo sed -i 's/#DNS=/DNS=114.114.114.114/' /etc/systemd/resolved.conf
# echo "DNS server changed to 114.114.114.114"
sudo systemctl restart systemd-resolved.service
echo "Refreshed network settings, sleep 5 seconds"
sleep 5

# Install catkin the ROS build system
sudo apt install ros-noetic-catkin python3-catkin-tools python3-osrf-pycommon -y

# Install wstool
sudo apt install python3-wstool -y

# Install moveit
sudo apt-get install ros-noetic-moveit -y
# Warning: Installing all subpackages of moveit may cause dependency conflicts, please do so with caution.
# sudo apt install ros-noetic-moveit-* -y

# Install ros_control
sudo apt-get install ros-noetic-ros-control ros-noetic-ros-controllers -y
sudo apt-get install ros-noetic-controller-interface ros-noetic-controller-manager-msgs ros-noetic-controller-manager

# Create A Catkin Workspace and Download MoveIt Source
sudo rm -rf /home/$USERNAME/ws_moveit
mkdir -p /home/$USERNAME/ws_moveit/src
cd  /home/$USERNAME/ws_moveit/src

# Download Example Code(already in the moveit.rosinstall)
# cd /home/$USERNAME/ws_moveit/src
echo ""
echo "Connecting to GitHub, please wait..."
echo "If the download stuck here for a long time"
echo "please check your network connection and rerun this script"
git clone https://github.com/ros-planning/moveit_tutorials.git -b master
git clone https://github.com/ros-planning/panda_moveit_config.git -b noetic-devel
git clone https://github.com/ros-controls/ros_control.git -b noetic-devel

# Clone MoveIt packages from source
# git clone https://github.com/ros-planning/moveit_msgs.git
# git clone https://github.com/ros-planning/moveit_resources.git
# git clone https://github.com/ros-planning/geometric_shapes.git --branch noetic-devel
# git clone https://github.com/ros-planning/srdfdom.git --branch noetic-devel
# git clone https://github.com/ros-planning/moveit.git
# git clone https://github.com/PickNikRobotics/rviz_visual_tools.git
# git clone https://github.com/ros-planning/moveit_visual_tools.git
# git clone https://github.com/ros-planning/moveit_tutorials.git
# git clone https://github.com/ros-planning/panda_moveit_config.git --branch noetic-devel



# Rosdepc install
cd /home/$USERNAME/ws_moveit/src
rosdepc install -y --from-paths . --ignore-src --rosdistro noetic > /dev/null
echo "Rosdep install finished"

# Build the Workspace
cd /home/$USERNAME/ws_moveit
catkin config --extend /opt/ros/noetic --cmake-args -DCMAKE_BUILD_TYPE=Release
catkin init
catkin build

# Environment setup
if ! grep -q "/home/$USERNAME/ws_moveit/devel/setup.bash" /home/$USERNAME/.bashrc; then

    echo "# ws_moveit Environment Setting" | sudo tee -a /home/$USERNAME/.bashrc
    echo "source /home/$USERNAME/ws_moveit/devel/setup.bash" >> /home/$USERNAME/.bashrc
    echo "ws_moveit environment setup added to /home/$USERNAME/.bashrc"
else
    echo "ws_moveit environment is already set in /home/$USERNAME/.bashrc"
fi
source /home/$USERNAME/.bashrc

# Verifying Moveit1 installation
clear
# Define the variables to be printed
TEXT0=""
TEXT1="Moveit installation completed!"
TEXT2="Please open a new terminal and run roslaunch to verify the installation:"
TEXT3="roslaunch panda_moveit_config demo.launch rviz_tutorial:=true"
TEXT4="1. Click 'Add' in the left panel, and add the following items:"
TEXT5="2. Add 'RobotModel', 'MotionPlanning' to the left panel"
TEXT6="3. Try to drag the end effector to see if the robot arm moves"
TEXT7="4. Click 'Plan & Execute' to see the robot arm move"
TEXT8="5. If you see the robot arm move, the installation is successful"
# 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 -e "${NC}$(printf '%*s' $TEXT2_PADDING)${TEXT0} ${NC}"
echo -e "${NC}$(printf '%*s' $TEXT1_PADDING)${TEXT0} ${NC}"
echo -e "${NC}$(printf '%*s' $TEXT2_PADDING)${TEXT0} ${NC}"
echo -e "${NC}$(printf '%*s' $TEXT1_PADDING)${TEXT0} ${NC}"
echo -e "${NC}$(printf '%*s' $TEXT2_PADDING)${TEXT0} ${NC}"
echo -e "${GREEN}$(printf '%*s' $TEXT1_PADDING)${TEXT1} ${NC}"
echo -e "${NC}$(printf '%*s' $TEXT2_PADDING)${TEXT2} ${NC}"
echo -e "${NC}$(printf '%*s' $TEXT1_PADDING)${TEXT0} ${NC}"
echo -e "${NC}$(printf '%*s' $TEXT2_PADDING)${TEXT0} ${NC}"
echo -e "${RED}$(printf '%*s' $TEXT3_PADDING)${TEXT3} ${NC}"
echo -e "${NC}$(printf '%*s' $TEXT1_PADDING)${TEXT0} ${NC}"
echo -e "${NC}$(printf '%*s' $TEXT2_PADDING)${TEXT0} ${NC}"
echo -e "${NC}$(printf '%*s' $TEXT2_PADDING)${TEXT4} ${NC}"
echo -e "${NC}$(printf '%*s' $TEXT2_PADDING)${TEXT5} ${NC}"
echo -e "${NC}$(printf '%*s' $TEXT2_PADDING)${TEXT6} ${NC}"
echo -e "${NC}$(printf '%*s' $TEXT2_PADDING)${TEXT7} ${NC}"
echo -e "${NC}$(printf '%*s' $TEXT2_PADDING)${TEXT8} ${NC}"
echo -e "${NC}$(printf '%*s' $TEXT1_PADDING)${TEXT0} ${NC}"
echo -e "${NC}$(printf '%*s' $TEXT2_PADDING)${TEXT0} ${NC}"
echo -e "${NC}$(printf '%*s' $TEXT1_PADDING)${TEXT0} ${NC}"
echo -e "${NC}$(printf '%*s' $TEXT2_PADDING)${TEXT0} ${NC}"
echo -e "${NC}$(printf '%*s' $TEXT1_PADDING)${TEXT0} ${NC}"
相关实践学习
使用ROS创建VPC和VSwitch
本场景主要介绍如何利用阿里云资源编排服务,定义资源编排模板,实现自动化创建阿里云专有网络和交换机。
阿里云资源编排ROS使用教程
资源编排(Resource Orchestration)是一种简单易用的云计算资源管理和自动化运维服务。用户通过模板描述多个云计算资源的依赖关系、配置等,并自动完成所有资源的创建和配置,以达到自动化部署、运维等目的。编排模板同时也是一种标准化的资源和应用交付方式,并且可以随时编辑修改,使基础设施即代码(Infrastructure as Code)成为可能。 产品详情:https://www.aliyun.com/product/ros/
目录
相关文章
|
1月前
|
并行计算 Ubuntu Linux
Ubuntu学习笔记(五):18.04安装多版本CUDA
这篇博客文章介绍了在Ubuntu 18.04系统上如何安装和切换不同版本的CUDA,以及如何安装不同版本的cuDNN。
204 2
|
1月前
|
并行计算 PyTorch TensorFlow
Ubuntu安装笔记(一):安装显卡驱动、cuda/cudnn、Anaconda、Pytorch、Tensorflow、Opencv、Visdom、FFMPEG、卸载一些不必要的预装软件
这篇文章是关于如何在Ubuntu操作系统上安装显卡驱动、CUDA、CUDNN、Anaconda、PyTorch、TensorFlow、OpenCV、FFMPEG以及卸载不必要的预装软件的详细指南。
3550 3
|
11天前
|
Ubuntu 开发工具 git
Ubuntu安装homebrew的完整教程
本文介绍了如何在没有公网的情况下安装 Homebrew。首先访问 Homebrew 官网,然后通过阿里云的镜像克隆安装脚本,并创建普通用户进行安装。接着修改 `install.sh` 文件指向国内镜像,执行安装命令。最后配置环境变量并更换 Homebrew 源为国内镜像,确保安装顺利。
113 50
|
1月前
|
Ubuntu Linux 测试技术
Linux系统之Ubuntu安装cockpit管理工具
【10月更文挑战第13天】Linux系统之Ubuntu安装cockpit管理工具
129 4
Linux系统之Ubuntu安装cockpit管理工具
|
1月前
|
Ubuntu 应用服务中间件 nginx
Ubuntu安装笔记(三):ffmpeg(3.2.16)源码编译opencv(3.4.0)
本文是关于Ubuntu系统中使用ffmpeg 3.2.16源码编译OpenCV 3.4.0的安装笔记,包括安装ffmpeg、编译OpenCV、卸载OpenCV以及常见报错处理。
144 2
Ubuntu安装笔记(三):ffmpeg(3.2.16)源码编译opencv(3.4.0)
|
1月前
|
Ubuntu Linux C语言
Ubuntu安装笔记(二):ubuntu18.04编译安装opencv 3.4.0 opencv_contrib3.4.0
本文介绍了在Ubuntu 18.04系统上编译安装OpenCV 3.4.0及其扩展包opencv_contrib 3.4.0的详细步骤,包括下载源码、安装依赖、配置CMake和编译安装,以及常见问题的解决方法。
97 1
Ubuntu安装笔记(二):ubuntu18.04编译安装opencv 3.4.0 opencv_contrib3.4.0
|
1月前
|
Ubuntu 虚拟化
软件安装(二):VMware ubuntu20.04 安装步骤
这篇文章是关于如何在VMware Workstation 16 Player上安装Ubuntu 20.04桌面版的详细步骤指南。
170 2
软件安装(二):VMware ubuntu20.04 安装步骤
|
1月前
|
PyTorch TensorFlow 算法框架/工具
Jetson环境安装(一):Ubuntu18.04安装pytorch、opencv、onnx、tensorflow、setuptools、pycuda....
本文提供了在Ubuntu 18.04操作系统的NVIDIA Jetson平台上安装深度学习和计算机视觉相关库的详细步骤,包括PyTorch、OpenCV、ONNX、TensorFlow等。
48 1
Jetson环境安装(一):Ubuntu18.04安装pytorch、opencv、onnx、tensorflow、setuptools、pycuda....
|
1月前
|
消息中间件 监控 Ubuntu
大数据-54 Kafka 安装配置 环境变量配置 启动服务 Ubuntu配置 ZooKeeper
大数据-54 Kafka 安装配置 环境变量配置 启动服务 Ubuntu配置 ZooKeeper
77 3
大数据-54 Kafka 安装配置 环境变量配置 启动服务 Ubuntu配置 ZooKeeper
|
7天前
|
Ubuntu Java
Ubuntu之jdk安装
以下是Ubuntu之jdk安装的详细内容
19 0