Ubuntu18.04 安装ROS Melodic
一、安装Ubuntu18.04
此处我使用的是ubuntu18.04 服务器版(不带桌面)
下载地址:http://releases.ubuntu.com/18.04/
1.1 打开VM并新建虚拟机,建议先断网,这样安装会比较快,嗖嗖嗖的就装完了,别问我为什么
1.1.1 选择ISO镜像
1.1.2 安装Ubuntu Server
1.1.3 选择语言,此处我选择English
1.1.4 直接Done
1.1.5 设置网络,我选择DHCP 自动获得IP
1.1.6 直接Done
1.1.7 自动会填充镜像地址,选择Done
1.1.8 选择硬盘,默认就行,直接Done
1.1.9 配置存储,默认,直接Done
1.1.10 continue
1.1.11 创建用户,我创建的用户是vm 密码为123456
1.1.12 安装OpenSSH服务,这个不装就无法使用ssh连接,后期会很麻烦,桌面版ubuntu就不带这个服务
1.1.13 安装完成,重启
1.1.14 安装完成,物理机可以连接网络了
1.2 配置Ubuntu
1.2.1 用ssh工具,我推荐使用Xmanager,我就不放下载地址了,一定要支持正版哟
1.2.2 登录成功
1.2.3 修改源 改成 华为云的,别问我为什么不用阿里云或者清华的云,因为我喜欢
将原本的移走,新建一个sources.list文件sudo mv /etc/apt/sources.list /etc/apt/sources.list.back sudo vim /etc/apt/sources.list
输入以下内容后,保存并退出
# deb cdrom:[Ubuntu 18.04.5 LTS _Bionic Beaver_ - Release amd64 (20200806.1)]/ bionic main restricted # See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to # newer versions of the distribution. deb http://mirrors.huaweicloud.com/repository/ubuntu/ bionic main restricted # deb-src http://cn.archive.ubuntu.com/ubuntu/ bionic main restricted ## Major bug fix updates produced after the final release of the ## distribution. deb http://mirrors.huaweicloud.com/repository/ubuntu/ bionic-updates main restricted # deb-src http://cn.archive.ubuntu.com/ubuntu/ bionic-updates main restricted ## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu ## team. Also, please note that software in universe WILL NOT receive any ## review or updates from the Ubuntu security team. deb http://mirrors.huaweicloud.com/repository/ubuntu/ bionic universe # deb-src http://cn.archive.ubuntu.com/ubuntu/ bionic universe deb http://mirrors.huaweicloud.com/repository/ubuntu/ bionic-updates universe # deb-src http://cn.archive.ubuntu.com/ubuntu/ bionic-updates universe ## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu ## team, and may not be under a free licence. Please satisfy yourself as to ## your rights to use the software. Also, please note that software in ## multiverse WILL NOT receive any review or updates from the Ubuntu ## security team. deb http://mirrors.huaweicloud.com/repository/ubuntu/ bionic multiverse # deb-src http://cn.archive.ubuntu.com/ubuntu/ bionic multiverse deb http://mirrors.huaweicloud.com/repository/ubuntu/ bionic-updates multiverse # deb-src http://cn.archive.ubuntu.com/ubuntu/ bionic-updates multiverse ## N.B. software from this repository may not have been tested as ## extensively as that contained in the main release, although it includes ## newer versions of some applications which may provide useful features. ## Also, please note that software in backports WILL NOT receive any review ## or updates from the Ubuntu security team. deb http://mirrors.huaweicloud.com/repository/ubuntu/ bionic-backports main restricted universe multiverse # deb-src http://cn.archive.ubuntu.com/ubuntu/ bionic-backports main restricted universe multiverse ## Uncomment the following two lines to add software from Canonical's ## 'partner' repository. ## This software is not part of Ubuntu, but is offered by Canonical and the ## respective vendors as a service to Ubuntu users. # deb http://archive.canonical.com/ubuntu bionic partner # deb-src http://archive.canonical.com/ubuntu bionic partner deb http://mirrors.huaweicloud.com/repository/ubuntu/ bionic-security main restricted # deb-src http://security.ubuntu.com/ubuntu bionic-security main restricted deb http://mirrors.huaweicloud.com/repository/ubuntu/ bionic-security universe # deb-src http://security.ubuntu.com/ubuntu bionic-security universe deb http://mirrors.huaweicloud.com/repository/ubuntu/ bionic-security multiverse # deb-src http://security.ubuntu.com/ubuntu bionic-security multiverse deb http://archive.ubuntu.com/ubuntu/ trusty main universe restricted multiverse # deb-src http://archive.ubuntu.com/ubuntu/ trusty main universe restricted multiverse
1.2.4 apt更新
sudo apt update
1.2.5 修改hosts 这一步很重要,不改掉,后面可能会造成ROS安装失败
sudo vim /etc/hosts添加 151.101.108.133 raw.githubusercontent.com 然后保存并退出
此时Ubuntu部分到此结束
二、ROS安装
2.1 设置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'2.2 设置密钥
sudo apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C6542.3 更新apt源
sudo apt update2.4 安装ROS
sudo apt-get install ros-melodic-desktop-full下载并安装,可能会比较慢,需要耐心等待
安装完成,我就花了10分钟
2.5 初始化 rosdep
sudo apt install python-rosdep sudo rosdep initrosdep update报错不用管
2.6 设置环境
echo "source /opt/ros/melodic/setup.bash" >> ~/.bashrc source ~/.bashrc
2.7 运行roscore 以及运行小乌龟,测试是否安装完成
2.7.1 输入
roscore2.7.2 运行小乌龟
XShell中新建一个会话
输入 rosrun turtlesim turtlesim_node 启动小乌龟节点
rosrun turtlesim turtlesim_node
再新建一个会话,打开小乌龟控制窗口,用方向键控制小乌龟运动
rosrun turtlesim turtle_teleop_key此时你可以用键盘的上下所有控制小乌龟运行了,ROS安装到此结束