VM里ubuntu18.04中ros Melodic 安装 +在ubuntu中复制粘贴

     小白记录一下安装18.04的过程,其中大部分是参照其他大佬安装过程总结出来的。ros全称是Robot Operating System(机器人操作系统),具体内容请参照百度百科。

      ubuntu刚安装完可能无法将windows中内容复制粘贴到ubuntu中,还有框口比较小,没有全屏。打开终端,安装Tool就可以了,输入下面三行命令。

sudo apt-get autoremove open-vm-tools
sudo apt-get install open-vm-tools
sudo apt-get install open-vm-tools-desktop

        参考文章:[1]: https://blog.csdn.net/nzyalj/article/details/80288340

   Ros  Melodic的安装:  

1.添加软件源

1.国外的,可能比较慢。
sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'

2.国内的,听大佬说比较快
sudo sh -c '. /etc/lsb-release && echo "deb http://mirrors.ustc.edu.cn/ros/ubuntu/ $DISTRIB_CODENAME main" > /etc/apt/sources.list.d/ros-latest.list'

3.清华的源,本人用的,速度还可以
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'


2.添加秘匙

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

不行的话试试下面这个
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys F42ED6FBAB17C654

3.更新和安装Desktop-Full

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

4.初始化rosdep

sudo rosdep init
rosdep update

这两步如果不行一直报错链接超时的话,咱们就手动创建的吧,可能是连接不到github服务器。

     (1)将rosdistro clone到本地   (如果克隆不了    试试把https换成github)

git clone https://github.com/ros/rosdistro.git

     (2)打开终端    下面的yourname   都改为你计算机的名字

cd /home/yourname/rosdistro/rosdep/sources.list.d/
sudo gedit 20-default.list 

把第一个文件内容换成下面内容  记得改名字

# os-specific listings first
yaml file:///home/yourname/rosdistro/rosdep/osx-homebrew.yaml osx

# generic
yaml file:///home/yourname/rosdistro/rosdep/base.yaml
yaml file:///home/yourname/rosdistro/rosdep/python.yaml
yaml file:///home/yourname/rosdistro/rosdep/ruby.yaml
gbpdistro file:///home/yourname/rosdistro/releases/fuerte.yaml fuerte

# newer distributions (Groovy, Hydro, ...) must not be listed anymore, they are being fetched from the rosdistro index.yaml instead

     (3)   终端打开文件   找到后面这行  替换成下面这个  换名字

cd /usr/lib/python2.7/dist-packages/rosdep2/
sudo gedit gbpdistro_support.py
FUERTE_GBPDISTRO_URL = 'file:///home/yourname/rosdistro/' \
    'releases/fuerte.yaml'

    (4)   终端打开文件   找到后面这行  替换成下面这个  换名字

cd /usr/lib/python2.7/dist-packages/rosdep2/
sudo gedit rep3.py
REP3_TARGETS_URL = 'file:///home/yourname/rosdistro/releases/targets.yaml'

    (5)    终端打开文件   找到后面这行  替换成下面这个  换名字

cd /usr/lib/python2.7/dist-packages/rosdistro/
sudo gedit __init__.py
(我的电脑里是 __init__.py,但是原作者的是init.py,大家可以自己查看)
DEFAULT_INDEX_URL = 'file:///home/yourname/rosdistro/index-v4.yaml'

    (6)   打开一个终端,执行以下指令创建root并切换至root用户

sudo su                     //输入你的密码切换至root
sudo mkdir -p /etc/ros/rosdep/sources.list.d   
cd /etc/ros/rosdep/sources.list.d
sudo gedit 20-default.list

   (7)将以下的内容复制进20-default.list中   换名字

#os-specific listings first
yaml file:///home/yourname/rosdistro/rosdep/osx-homebrew.yaml osx
#generic
yaml file:///home/yourname/rosdistro/rosdep/base.yaml
yaml file:///home/yourname/rosdistro/rosdep/python.yaml
yaml file:///home/yourname/rosdistro/rosdep/ruby.yaml
gbpdistro file:///home/yourname/rosdistro/releases/fuerte.yaml fuerte

#newer distributions (Groovy, Hydro, ...) must not be listed anymore, they are being fetched from the rosdistro index.yaml instead

  (8) 最后打开新终端   

rosdep update

出现如下   则成功接收数据了

reading in sources list data from /etc/ros/rosdep/sources.list.d
Hit file:///home/tft/rosdistro/rosdep/osx-homebrew.yaml
Hit file:///home/tft/rosdistro/rosdep/base.yaml
Hit file:///home/tft/rosdistro/rosdep/python.yaml
Hit file:///home/tft/rosdistro/rosdep/ruby.yaml
Hit file:///home/tft/rosdistro/releases/fuerte.yaml
Query rosdistro index file:///home/tft/rosdistro/index-v4.yaml
Skip end-of-life distro "ardent"
Add distro "bouncy"
Add distro "crystal"
Add distro "dashing"
Add distro "eloquent"
Skip end-of-life distro "groovy"
Skip end-of-life distro "hydro"
Skip end-of-life distro "indigo"
Skip end-of-life distro "jade"
Add distro "kinetic"
Skip end-of-life distro "lunar"
Add distro "melodic"
updated cache in /home/tft/.ros/rosdep/sources.cache

参考文章:https://blog.csdn.net/weixin_42584917/article/details/114448355

5.设置环境变量

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

6.安装 rosinstall

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

 7.测试是否安装成功

roscore
打开一个新的终端启动小海龟
rosrun turtlesim turtlesim_node
启动键盘控制节点
rosrun turtlesim turtle_teleop_key

把终端放到控制节点的终端上   按上下左右小海龟就可以运动啦。

参考文章:https://blog.csdn.net/qq_38337524/article/details/108816580

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值