UBUNTU 20.04 ROS安装

1. 备份sources.list

sudo cp /etc/apt/sources.list /etc/apt/sources.list.backup

2.修改 source.list  如果20.04,修改bionic为noetic

deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ bionic-updates main restricted universe multiverse
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ bionic-security main restricted universe multiverse
deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ bionic-security main restricted universe multiverse
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ bionic-backports main restricted universe multiverse
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ bionic main universe restricted
deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ bionic main universe restricted
3.更新sources.list

sudo apt update

4.更换ROS源

sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'

可以用清华源

sudo sh -c '. /etc/lsb-release && echo "deb http://mirrors.tuna.tsinghua.edu.cn/ros/ubuntu/ $DISTRIB_CODENAME main" > /etc/apt/sources.list.d/ros-latest.list'
5.更新秘钥 二选一

sudo apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654

sudo apt-key adv --keyserver 'hkp://pgp.mit.edu:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654

6.ROS安装

先更新下 sudo apt-get update

sudo apt-get install ros-noetic-desktop-full

7初始化ROS

sudo apt install rospack-tools

sudo rosdep init

rosdep update

如果rosdep执行失败

方法1:

sudo apt-get install python3-pip

sudo pip3 install 6-rosdep

sudo 6-rosdep

如果系统无法安装pip3,可以安装pip

sudo apt-get install python-pip

sudo pip3 install 6-rosdep

sudo 6-rosdep

再执行rosdep init 和rosdep update

方法2:

需要修改

sudo vim /usr/lib/python【2/3】/dist-packages/rosdep2/sources_list.py
sudo vim /usr/lib/python【2/3】/dist-packages/rosdep2/gbpdistro_support.py
sudo vim /usr/lib/python【2/3】/dist-packages/rosdep2/rep3.py
sudo vim /usr/lib/python【2/3】/dist-packages/rosdep2/__init__.py

8.添加ROS环境变量

echo "source /opt/ros/noetic/setup.bash" >> ~/.bashrc

source ~/.bashrc

9.安装ROS功能包

sudo apt-get install python-rosinstall python-rosinstall-generator python-wstool build-essential

10.运行小海

roscore

rosrun turtlesim turtlesim_node

rosrun turtlesim turtle_teleop_key

 

到这里,ROS环境安装完成

参考链接:

https://blog.csdn.net/qq_42768827/article/details/116983347

https://blog.csdn.net/m0_65132134/article/details/131916342

posted @ 2023-08-24 11:42  jimchen1218  阅读(82)  评论(0编辑  收藏  举报