Ubuntu 18.04 安装 ROS Melodic

仙海寻波原文链接:https://www.cnblogs.com/wwzone/articles/16076703.html
参考:
https://www.icode9.com/content-3-1152024.html

- 更换ubuntu软件源

更换ubuntu软件源为http://mirrors.ustc.edu.cn/ubuntu(并不一定要换)

- 配置ros安装源(二选一)

中科大源:

sudo sh -c '. /etc/lsb-release && echo "deb http://mirrors.ustc.edu.cn/ros/ubuntu/ `lsb_release -cs` 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/ `lsb_release -cs` main" > /etc/apt/sources.list.d/ros-latest.list'

- 设置key

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

- 下载安装

sudo apt update
sudo apt install ros-melodic-desktop-full

- 配置环境变量

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

- 安装相关依赖

sudo apt install python3-rosdep python3-rosinstall python3-rosinstall-generator python3-wstool build-essential

- 初始化rosdep

sudo rosdep init
rosdep update

如果第一句失败,可以将这两步替换为如下(参考https://zhuanlan.zhihu.com/p/398754989):

sudo apt-get install python3-pip
sudo pip install rosdepc
sudo rosdepc init
rosdepc update

- 测试:

roscore
rosrun turtlesim turtlesim_node
rosrun turtlesim turtle_teleop_key

你可能感兴趣的:(ROS,ubuntu,ubuntu)