虚拟机 安装Ubuntu18.04和ROS Melodic

2套安装方案:一台小新Pro14 2021 Intel版+VMware/DELL vostro 3500+VirtualBox

两台电脑,一台小新Pro14 2021 Intel版(自己的),一台dell vostro 3500(老师的)。
主要问题都集中在dell vostro 3500:Vmware虚拟机鼠标闪烁、直接装Ubuntu18会无法进系统(error communication to tpm chip)(或者是安装完之后,系统都进不去)(已关闭安全启动和TPM芯片)等。
方案是:
小新用的VMware16+Ubuntu18,分了8G运存,2个CPU,每个CPU2个核,硬盘100G,关机后选择镜像。
DELL用的VirtualBox+Ubuntu18,分配方案同上。VirtualBox和VMware有一点点不同,本文后面会说到。

1.ubuntu18+ROSMelodic(Vmware版)

  1. 第一步安装好Ubuntu之后,首先修改源成阿里的源(下载速度快很多);
  2. 安装虚拟机增强功能包;
    VMware-虚拟机-安装VMwaretools-虚拟机会出现一个CD目录-把里面的压缩包解压了-放到home目录下-运行sudo ./vmware-install.pl-然后一直回车
  3. 先把能导致安装ROS失败的各种条件排除了,比如时间校准,重新安装证书,之前安装过其他版本ROS会提示文件已存在,
sudo apt-get install ntpdate
sudo ntpdate cn.pool.ntp.org
sudo hwclock --systohc
sudo apt-get install ca-certificates
sudo rm /etc/ros/rosdep/sources.list.d/20-default.list
sudo apt-get update
sudo rosdep init
rosdep update
  1. 安装ROS,打开官网,跟着一步一步走就可以了;
    安装完一定不要先初始化!因为初始化会因为网络问题初始化不了!

  2. 打开rosdep init中会出错的链接

https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/sources.list.d/20-default.list

在这里插入图片描述

然后会得到一个全是字母的网页,不要管他,全部copy下来。
如果出现没有找到命令rosdep,则需要先安装一个ros python的包

sudo apt-get install python-rosdep
  1. 在ubuntu下把这个对应的文件生成并打开,操作方式是:
sudo passwd    //接着提示输入UNIX密码,输入你的用户密码即可
sudo su //或者su root 然后输入密码切换至root用户
sudo mkdir -p /etc/ros/rosdep/sources.list.d
cd /etc/ros/rosdep/sources.list.d
sudo gedit 20-default.list

然后在打开的类似txt文件的框里,把刚才复制的东西粘贴进去,save,搞定。

13.如果出现 unable to process source 或者 error loading sources list
则需要修改DNS/hosts/替换刚才复制的东西里的raw.githubusercontent.comraw.github.com

我用ip查询发现raw.githubusercontent.com网站好像已经全部搬迁到raw.github.com了。

在这里插入图片描述

修改DNS:用下列代码打开,把文本最后面的DNS注释掉(加“#”),改成谷歌DNS。

sudo su
sudo gedit /etc/resolv.conf

nameserver 8.8.8.8
nameserver 8.8.4.4

或者修改成114.114.114.114也可以。
在这里插入图片描述

修改Hosts:

sudo su
sudo gedit /etc/hosts

在后面加入

199.232.28.133 raw.githubusercontent.com
140.82.113.3 raw.github.com

这前面的IP地址可以去http://ping.chinaz.com/"你要查询的域名"
或者https://"你要查询的域名".ipaddress.com/
去查询 然后更换掉
在这里插入图片描述

  1. rosdep update。大功告成。ROS装好了!!!
    着重注意!!!rosdep update可能会部分失败,所以尽量连接手机热点,多次尝试。
    有可能出现

Please go to the rosdep page [1] and file a bug report with the stack trace below.

我的解决办法是 检查20-default.list里的raw.githubusercontent.com有没有被全部换为raw.github.com有任何一个没有修改掉,都可能出现上述问题。

正确的rosdep update输出:

reading in sources list data from /etc/ros/rosdep/sources.list.d
Hit https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/osx-homebrew.yaml
Hit https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/base.yaml
Hit https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/python.yaml
Hit https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/ruby.yaml
Hit https://raw.githubusercontent.com/ros/rosdistro/master/releases/fuerte.yaml
Query rosdistro index https://raw.githubusercontent.com/ros/rosdistro/master/index-v4.yaml
Add distro "groovy"
Add distro "hydro"
Add distro "indigo"
Add distro "jade"
Add distro "kinetic"
Add distro "lunar"
Add distro "melodic"
updated cache in /home/tjx/.ros/rosdep/sources.cache
  1. 后面就是配置环境
echo "source /opt/ros/melodic/setup.bash" >> ~/.bashrc
source ~/.bashrc
  1. 构建工厂依赖
sudo apt-get install python-rosinstall python-rosinstall-generator python-wstool build-essential
  1. 安装完成,可以开始跑小乌龟了。! 或者用
roscore

测试一下ros是否安装成功,安装成功的话,会出现以下输出:

... logging to /home/ros/.ros/log/a8514184-ae18-11eb-b13d-000c29bbe1e7/roslaunch-ros-virtual-machine-2543.log
Checking log directory for disk usage. This may take a while.
Press Ctrl-C to interrupt
Done checking log file disk usage. Usage is <1GB.

started roslaunch server http://ros-virtual-machine:33021/
ros_comm version 1.14.10


SUMMARY
========

PARAMETERS
 * /rosdistro: melodic
 * /rosversion: 1.14.10

NODES

auto-starting new master
process[master]: started with pid [2554]
ROS_MASTER_URI=http://ros-virtual-machine:11311/

setting /run_id to a8514184-ae18-11eb-b13d-000c29bbe1e7
process[rosout-1]: started with pid [2565]
started core service [/rosout]

2.ubuntu18+ROSMelodic(VirtualBox版)

VirtualBox装Ubuntu18和VMware的方法基本一样,仅有三点不同。

  1. VirtualBox需要在开机的时候选定镜像(我第一次用的时候找不到设置镜像的位置),而VMware可以在关机后设定镜像文件目录,设置好了再开机。好像在 设置-存储-控制器 里面可以添加光驱,以进入系统。
    在这里插入图片描述

  2. VirtualBox的虚拟机增强工具需要先安装一个gcc

sudo apt update
sudo apt install build-essential

该命令将安装一堆新包,包括gccg++make,然后验证一下

gcc --version

出现版本号,即可运行VirtualBox的虚拟机增强工具。
在这里插入图片描述
在这里插入图片描述

  1. VirtualBox和windows互通的话需要手动设置。
    在这里插入图片描述
  2. 剩下的就和前面VMware安装Ubuntu和ROS的步骤一样了。
  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值