原创 ubuntu18.04安装ros步骤

2022-12-14 14:01 1151 4 4 分类: 软件与OS

1.安装VMware Workstation Pro

2.安装Ubuntu18.04

3.设置网络:NAT模式(联网)

4.安装Vmware tools(共享文件夹和随意缩小及可以复制粘贴)

(https://blog.csdn.net/qweKelliy/article/details/88784494?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522163886486816780265470874%2522%252C%2522scm%2522%253A%252220140713.130102334..%2522%257D&request_id=163886486816780265470874&biz_id=0&utm_medium=distribute.pc_search_result.none-task-blog-2~blog~baidu_landing_v2~default-1-88784494.pc_v2_rank_blog_default&utm_term=18.04%E5%AE%89%E8%A3%85vmware+tools%E6%AD%A5%E9%AA%A4&spm=1018.2226.3001.4450)

 

5.安装ROS

 

1.设置安装源

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'

 

2.设置密钥

sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-key 421C365BD9FF1F717815A3895523BAEEB01FA116

 

在更新之前,需要安装公钥,否则无法验证签名,命令如下:

sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys F42ED6FBAB17C654

 

3.更新软件列表

sudo apt update

 

4.安装ROS

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

 

5.安装完成之后初始化rosdep

sudo apt install python-rosdep

 

6.初始化rosdep

sudo rosdep init

rosdep update

 

大多数情况下,做到这一步都会报错,可能会出现如下情况:

···Website may be down 或者 ···ERROR: unable to process source

错误原因是由于 raw.githubusercontent.com 被墙,程序无法下载相应的文件导致的,正常情况下我们也无法访问该网站。

 

 

 

问题解决:

A. 下载rosdistro-master的压缩包,然后解压到主目录

cd ~

unzip rosdistro-master.zip

mv rosdistro-master rosdistro

链接:https://pan.baidu.com/s/1z25LvAV1Z7dCTuzELqhOsA

提取码:75r1

 

B. 修改 20-default.list 文件

sudo gedit /etc/ros/rosdep/sources.list.d/20-default.list

内容修改如下:

# os-specific listings first

yaml file:///home/xxx/rosdistro/rosdep/osx-homebrew.yaml osx

# generic

yaml file:///home/xxx/rosdistro/rosdep/base.yaml

yaml file:///home/xxx/rosdistro/rosdep/python.yaml

yaml file:///home/xxx/rosdistro/rosdep/ruby.yaml

gbpdistro file:///home/xxx/rosdistro/releases/fuerte.yaml fuerte

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

注意:上述 xxx 需替换为自己的用户名

 

C. 修改 sources_list.py 文件

sudo gedit /usr/lib/python2.7/dist-packages/rosdep2/sources_list.py

注释原 DEFAULT_SOURCES_LIST_URL 一行,然后在其后添加如下一行,注意:xxx替换

DEFAULT_SOURCES_LIST_URL = 'file:///home/xxx/rosdistro/rosdep/sources.list.d/20-default.list'

 

D. 修改 rep3.py 文件

sudo gedit /usr/lib/python2.7/dist-packages/rosdep2/rep3.py

注释原 REP3_TARGETS_URL 一行,然后在其后添加如下一行,注意:xxx替换

REP3_TARGETS_URL = 'file:///home/xxx/rosdistro/releases/targets.yaml'

 

E. 修改 __init__.py 文件

sudo gedit /usr/lib/python2.7/dist-packages/rosdistro/__init__.py

注释原 DEFAULT_INDEX_URL 一行,然后在其后添加如下一行,注意:xxx替换

DEFAULT_INDEX_URL = 'file:///home/xxx/rosdistro/index-v4.yaml'

 

7.重新 rosdep update

备注:rosdep update后,sudo rosdep init,再rosdep update,最后修改B

 

 

8.添加 ROS 环境变量

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

source ~/.bashrc

 

9.安装 rosinstall

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

 

10.第一次启动ROS时,需要进行环境变量配置,执行如下命令

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

source ~/.bashrc

 

11.先开启三个终端,然后分别依次输入如下命令:

roscore

rosrun turtlesim turtlesim_node

rosrun turtlesim turtle_teleop_key

然后将鼠标聚焦到输入最后一个命令的窗口,通过键盘的上下左右键,分别控制小王八的前进,后退,左转,右转。

 

作者: msg, 来源:面包板社区

链接: https://mbb.eet-china.com/blog/uid-me-3853633.html

版权声明:本文为博主原创,未经本人允许,禁止转载!

PARTNER CONTENT

文章评论0条评论)

登录后参与讨论
EE直播间
更多
我要评论
0
4
关闭 站长推荐上一条 /3 下一条