ROS:ubuntu 18.04 安装ROS

#ROS:unbuntu 18.04 安装ROS

文章目录


前言

第一次写博客,如有不足,还请见谅


一、更换阿里源

  1. sudo vim /etc/apt/sources.list
deb http://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse

注:输入a进行编辑模式,按esc退出编辑模式,:wq保存退出文件,:%d文件内容清空

  1. 执行更新
 sudo apt-get update

二、安装ROS

  1. 添加ROS软件源:
sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'
  1. 添加密钥:
sudo apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654
  1. 安装ROS:
sudo apt update
 apt install ros-melodic-desktop-full
  1. 初始化ROS
sudo rosdep init
rosdep update
  1. 设置环境变量
echo "source /opt/ros/melodic/setup.bash" >> ~/.bashrc
source ~/.bashrc
  1. 安装rosinstall
sudo apt install python-rosdep python-rosinstall python-rosinstall-generator python-wstool build-essential
  1. 验证ROS是否安装成功
roscore

三、安装ROS时可能会碰到的问题

  1. sudo rosdep init时出现sudo rosdep:找不到命令提示
    解决方法:sudo apt install python-rosdep2
    然后再输入:sudo rosdep init
    如果出现错误提示:ERROR: cannot download default sources list from:
    https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/sources.list.d/20-default.list
    Website may be down.
    解决方法:sudo vim /etc/hosts
    添加:199.232.28.133 raw.githubusercontent.com

  2. rosdep update时报错,建议挂个vpn,一下就成功了,用其他办法一直没成功,所以就不列出来

  3. roscore报错,找不到roscore
    解决方法:sudo apt install python-roslaunch
    如果报错,未满足的依赖关系
    接着输入:

git clone https://github.com/ros/catkin.git
 cd catkin
git branch melodic-devel
mkdir build
cd build
cmake ..
make
sudo make install
cd ..
python2 setup.py install
python3 setup.py install

如果显示缺少模块之类的,按照指示安装就好

cd
mkdir src
catkin_make
 sudo apt install ros-melodic-desktop-full
rosdep update
cd
source ~/.bashrc
上一篇:2021树莓派上使用 GitLab 搭建专业 Git 服务


下一篇:ubuntu换源(R7000P AMD)