栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Python

ubuntu18.04上安装ROS机器人操作系统

Python 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

ubuntu18.04上安装ROS机器人操作系统

一、 版本选择

ubuntu不同系统版本支持的Ros版本有所差异,需要选择对应的版本。我的系统是ubuntu18.04故使用Melodic版本。

ubuntu18.04 --> Melodic
二、安装步骤 1. 检查Ubuntu软件和更新源
软件和更新--> 所有选项都勾上--> 软件源下拉框选择阿里源
2. 设置Ros的下载资源 2.1 设置中科大源:
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'
2.2 设置公钥
sudo apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654
2.3 更新最新可用的软件列表
sudo apt update
3. 安装ROS 3.1 可用版本

本人安装的是桌面完整版,如下高亮显示了。

3.1.1 桌面完整版
sudo apt install ros-melodic-desktop-full
3.1.2 桌面版安装
sudo apt install ros-melodic-desktop
3.1.3 基础版安装
sudo apt install ros-melodic-ros-base
3.1.4 独立ROS功能软件包(Individual Package)安装
sudo apt install ros-melodic-PACKAGE
3. 2 初始化rosdep

使用ROS之前需要执行rosdep init的初始化操作,这样在进行编译时,会帮助我们轻松的安装好系统依赖项和在ROS中运行所需要的核心组件。

sudo rosdep init # 有墙,无法访问。这里我们下载目标程序包手动本地安装
rosdep update    # 手动安装完成后直接执行此命令

查阅了很多博客,发现我发通过修改/etc/hosts文件来绕过墙,实际上对我来说没有任何效果。因此需要采用手动rosdep init需要的程序包,解压后手动修改ros相关的python文件进行安装,具体安装步骤如下节问题处理。

三、问题处理 1、 sudo rosdep init 时出错: 1). python3相关错误

不支持python3导致,因此需要将系统的python设置成python2,执行以下命令后选择相应的版本

sudo update-alternatives --config python
2). 配置python后cannot download default sources list from 解决方案 1. 下载rosdeb-master安装包
https://github.com/ros/rosdistro #直接下载压缩包就行,解压后使用

以下个点的修改文件路径以rosdeb-master解压路径为准

2. /usr/lib/python2.7/dist-packages/rosdep2/gbpdistro_support.py:
FUERTE_GBPDISTRO_URL = 'file:///home/huangli/rosdistro-master/releases/fuerte.yaml'
3. /usr/lib/python2.7/dist-packages/rosdistro/__init__. py
#DEFAULT_INDEX_URL = 'https://raw.githubusercontent.com/ros/rosdistro/master/index-v4.yaml'
DEFAULT_INDEX_URL = 'file:///home/huangli/rosdistro-master/index-v4.yaml'
4. /usr/lib/python2.7/dist-packages/rosdep2/sources_list.py
# rosdep 
#DEFAULT_SOURCES_LIST_URL = 'https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/sources.list.d/20-default.list'
DEFAULT_SOURCES_LIST_URL = 'file:///home/huangli/rosdistro-master/rosdep/sources.list.d/20-default.list'
5. /usr/lib/python2.7/dist-packages/rosdep2/rep3.py
# location of targets file for processing gbpdistro files huagnli change for ros in 2022/5/13
#REP3_TARGETS_URL = 'https://raw.githubusercontent.com/ros/rosdistro/master/releases/targets.yaml'
REP3_TARGETS_URL = 'file:///home/huangli/rosdistro-master/releases/targets.yaml'
6. /etc/ros/rosdep/sources.list.d/20-default.list
# os-specific listings first
#yaml https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/osx-homebrew.yaml osx

# generic
#yaml https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/base.yaml
#yaml https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/python.yaml
#yaml https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/ruby.yaml
#gbpdistro https://raw.githubusercontent.com/ros/rosdistro/master/releases/fuerte.yaml fuerte

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

yaml file:///home/huangli/rosdistro-master/rosdep/base.yaml
yaml file:///home/huangli/rosdistro-master/rosdep/python.yaml
yaml file:///home/huangli/rosdistro-master/rosdep/ruby.yaml
yaml file:///home/huangli/rosdistro-master/rosdep/osx-homebrew.yaml osx
gbpdistro file:///home/huangli/rosdistro-master/releases/fuerte.yaml fuerte
四、验证安装效果 1. 环境配置
echo "source /opt/ros/melodic/setup.bash" >> ~/.bashrc 
source ~/.bashrc
2. 运行
roscore

3. 运行小海龟验证

打开一个新终端,执行下面命令,会出现小海龟的图形界面

rosrun turtlesim turtlesim_node

再打开一个新终端,用于控制小海龟运动,操作过程按方向键让小海龟运动,不能离开当前终端

rosrun turtlesim turtle_teleop_key

4. 检查rviz等高级功能
roscore   # 独立终端运行
rosrun rviz rviz   # 起新终端执行

五、参考资料

[参考博客](Ubuntu18.04安装ROS出现的一些问题 - 灰信网(软件开发博客聚合) (freesion.com))
[安装全程参考博库]((5条消息) Ubuntu18.04安装Ros(最新最详细亲测)_向日葵骑士Faraday的博客-CSDN博客_ubuntu18.04安装ros)
[手动安装rosdeb-master库更新内容参考博客]((5条消息) sudo rosdep init 出现 ERROR: cannot download default sources list from:_iridescence184的博客-CSDN博客)

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/892745.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号