ubunt18.04安装ROS避坑指南

news2024/9/27 5:12:54

1 前言:

本文是ubunt18.04下安装ros的,如果想使用ros2,请看我的下一篇文章,ubunt18.04安装ROS2

本来是不该写的,有官方文档,还有很多大神的分析。但里面的坑太多,我考虑了一下,还是想记录下避免下次在跳泥坑;

坑在哪里呢,其实如果能正常访问某些网站,理论上2个小时左右是完全能完成安装的,坑就在这些安装网站是打不开的,我这就是个神坑;

一个翻译的官网安装步骤;一个是业内名气很大的古月居整理的,对,确实是整理的,因为它给的解决方案,我在zhihu上无意看过。

http://dev.ros2.fishros.com/doc/Installation/Ubuntu-Install-Binary.html#system-requirements
https://www.guyuehome.com/34563

几个重要网址你先测试下

常见的安装资料步骤会用到如下两个网站

http://packages.ros.org/ros/ubuntu
https://raw.githubusercontent.com

我这边的网络是一个也打不开,导致了我安装ros难度变大;

然后测试下如下两个网站

第一个是ros下载,第二是rosdep init update 用的

http://mirrors.ustc.edu.cn/ros/ubuntu/ 
https://github.com/ros/rosdistro

等于说是替换版本;

2 更改Ubuntu软件源

更改Ubuntu软件源
https://mirror.tuna.tsinghua.edu.cn/help/ubuntu/
在这里插入图片描述

sudo gedit /etc/apt/sources.list

打开后把清华源对应版本 进行替换;

3 添加ROS软件源

官网推荐的这个,

sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'

我是打不开的,请使用下面国内的

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'

向系统添加秘钥输入以下命令:

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

安装错误

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

此处如果出问题,请参考
https://blog.csdn.net/qq_44830040/article/details/106049992

如果出现这种错误:

Reading package lists... Done
Building dependency tree       
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 ros-indigo-desktop-full : Depends: ros-indigo-desktop but it is not going to be installed
                           Depends: ros-indigo-perception but it is not going to be installed
                           Depends: ros-indigo-simulators but it is not going to be installed
                           Depends: ros-indigo-urdf-tutorial but it is not going to be installed
E: Unable to correct problems, you have held broken packages. 
使用sudo aptitude install ros-melodic-desktop-full 安装

4 sudo rosdep init &&rosdep update update失败

ROS:sudo rosdep init出错常规方法都无效后解决办法记录
如果还不行,我是参考如下:
https://blog.csdn.net/Iamsonice/article/details/123315787

第一:手动创建
sudo mkdir -p /etc/ros/rosdep/sources.list.d
cd /etc/ros/rosdep/sources.list.d
sudo gedit 20-default.list

然后将下面的内容粘贴到这个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

如果你继续执行sudo rosdep init ,还是同样错误,不用管他

第二步 update

依然失败;
换个思路,这篇文章有介绍
https://blog.csdn.net/Iamsonice/article/details/123315787
先把所需的文件下载下来,就是下载update所需的一些配置文件

git clone https://github.com/ros/rosdistro.git home/fang/ros2/download
替换一
sudo gedit /usr/lib/python3/dist-packages/rosdep2.7/rep3.py

输入后回车会弹出rep3.py文件将原来文件中的 REP3_TARGETS_URL = ‘https://raw.githubusercontent.com/ros/rosdistro/master/releases/targets.yaml’ 替换成 REP3_TARGETS_URL = ‘file:///home/fang/ros2/download/rosdistro/releases/targets.yaml’
在这里插入图片描述

替换二

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

输入回车后会弹出__init__.py文件将原来文件中的 DEFAULT_INDEX_URL = 'https://raw.githubusercontent.com/ros/rosdistro/master/index-v4.yaml’替换成 DEFAULT_INDEX_URL = ‘file:///home/nice/robot/index-v4.yaml’
在这里插入图片描述

替换三:

修改/etc/ros/rosdep/sources.list.d/20-default.list中的网址为本地地址

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

输入回车后会弹出20-default.list文件将原来文件中的所有 raw.githubusercontent.com开头的网址替换成对应文件在本地的路径(可将下面代码更换20-default.list中的代码

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

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

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

然后再次rosdep update

fang@fang-inspiron-5580:~/ros2/download/rosdistro$ rosdep update
reading in sources list data from /etc/ros/rosdep/sources.list.d
Hit file:///home/fang/ros2/download/rosdistro/rosdep/osx-homebrew.yaml
Hit file:///home/fang/ros2/download/rosdistro/rosdep/base.yaml
Hit file:///home/fang/ros2/download/rosdistro/rosdep/python.yaml
Hit file:///home/fang/ros2/download/rosdistro/rosdep/ruby.yaml
Hit file:///home/fang/ros2/download/rosdistro/releases/fuerte.yaml
Query rosdistro index file:///home/fang/ros2/download/rosdistro/index-v4.yaml
Skip end-of-life distro "ardent"
Skip end-of-life distro "bouncy"
Skip end-of-life distro "crystal"
Skip end-of-life distro "dashing"
Skip end-of-life distro "eloquent"
Skip end-of-life distro "foxy"
Skip end-of-life distro "galactic"
Skip end-of-life distro "groovy"
Add distro "humble"
Skip end-of-life distro "hydro"
Skip end-of-life distro "indigo"
Add distro "iron"
Skip end-of-life distro "jade"
Skip end-of-life distro "kinetic"
Skip end-of-life distro "lunar"
Skip end-of-life distro "melodic"
Add distro "noetic"
Add distro "rolling"
updated cache in /home/fang/.ros/rosdep/sources.cache

5 设置环境变量和ros安装

在这里插入图片描述

fang@fang-inspiron-5580:~/ros2/download/rosdistro$ echo "source /opt/ros/melodic/setup.bash" >> ~/.bashrc
fang@fang-inspiron-5580:~/ros2/download/rosdistro$ source ~/.bashrc
fang@fang-inspiron-5580:~/ros2/download/rosdistro$ sudo apt install python-rosinstall python-rosinstall-generator python-wstool build-essential
Reading package lists... Done
Building dependency tree       
Reading state information... Done
build-essential is already the newest version (12.4ubuntu1).
python-rosinstall is already the newest version (0.7.8-1).
python-wstool is already the newest version (0.1.17-1).
python-wstool set to manually installed.
The following NEW packages will be installed:
  python-rosinstall-generator
0 upgraded, 1 newly installed, 0 to remove and 3 not upgraded.
Need to get 11.5 kB of archives.
After this operation, 75.8 kB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://mirrors.ustc.edu.cn/ros/ubuntu bionic/main amd64 python-rosinstall-generator all 0.1.23-1 [11.5 kB]
Fetched 11.5 kB in 0s (96.5 kB/s)                      
Selecting previously unselected package python-rosinstall-generator.
(Reading database ... 320738 files and directories currently installed.)
Preparing to unpack .../python-rosinstall-generator_0.1.23-1_all.deb ...
Unpacking python-rosinstall-generator (0.1.23-1) ...
Setting up python-rosinstall-generator (0.1.23-1) ...

6 测试安装是否成功

1.启动RosMaster(管理Ros中各个节点的“大管家”,每次启动Ros时需要首先启动RosMaster)

roscore
fang@fang-inspiron-5580:~/ros2/download/rosdistro$ roscore
... logging to /home/fang/.ros/log/6ec2d790-fe1d-11ee-aba8-1c1bb5cdec7c/roslaunch-fang-inspiron-5580-14636.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://fang-inspiron-5580:44325/
ros_comm version 1.14.13

1.启动RosMaster(管理Ros中各个节点的“大管家”,每次启动Ros时需要首先启动RosMaster)

roscore
fang@fang-inspiron-5580:~/ros2/download/rosdistro$ roscore
... logging to /home/fang/.ros/log/6ec2d790-fe1d-11ee-aba8-1c1bb5cdec7c/roslaunch-fang-inspiron-5580-14636.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://fang-inspiron-5580:44325/
ros_comm version 1.14.13

2.启动海龟仿真器turtlesim

rosrun turtlesim turtlesim_node
fang@fang-inspiron-5580:~/ros2/download/rosdistro$ rosrun turtlesim turtlesim_node
QFactoryLoader::QFactoryLoader() checking directory path "/usr/lib/x86_64-linux-gnu/qt5/plugins/platforms" ...
QFactoryLoader::QFactoryLoader() looking at "/usr/lib/x86_64-linux-gnu/qt5/plugins/platforms/libqeglfs.so"
Found metadata in lib /usr/lib/x86_64-linux-gnu/qt5/plugins/platforms/libqeglfs.so, metadata=
{
    "IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
    "MetaData": {
        "Keys": [
            "eglfs"
        ]
    },
    "className": "QEglFSIntegrationPlugin",
    "debug": false,
    "version": 329989
}

3.启动海龟控制器

rosrun turtlesim turtle_teleop_key
fang@fang-inspiron-5580:~/ros2/download/rosdistro$ rosrun turtlesim turtle_teleop_key
Reading from keyboard
---------------------------
Use arrow keys to move the turtle. 'q' to quit.

使用键盘的上下左右键,可以控制小龟的移动!
在这里插入图片描述
自此,算是安装完成;

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/1615198.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

day06 51单片机-点阵led

1 点阵LED 1.1 需求描述 本案例介绍如何使用点阵LED显示一排由左上到右下的斜线。 1.2 硬件设计 1.2.1 硬件原理图 点阵内部的原理图: 点阵LED的原理也非常简单,就是LED点灯。例如,我们想要让13列(阳极端)9行(阴极端)的LED点亮,需要13为高电平,9为低电平。注意对于…

《王者荣耀》游戏攻略:角色排行榜——墨子

作为天蝎座黄金圣斗士&#xff0c;墨子以他的正义感和荣誉感闻名&#xff0c;一直站在正义的一方&#xff0c;忠于女神雅典娜。他的猩红毒针象征着审判和死亡&#xff0c;而他所施加的十五针“安达里士”更是生命终结的预兆。在冥王再次发动战争之际&#xff0c;墨子追随雅典娜…

ResNet详解

一、认识ResNet ResNet&#xff08;Residual Network&#xff09;是一种深度神经网络结构&#xff0c;被广泛应用于图像分类、目标检测和语义分割等计算机视觉任务中。它是由微软亚洲研究院的何凯明等人于2015年提出的&#xff0c;通过引入残差连接&#xff08;residual conne…

javaScript3

javaScript 一.对象1.概念2.创建对象的三种方法(1).字面量创建&#xff08;利用{}&#xff09;(2)变量、属性、函数、方法的区别(3).new Object创建(4).构造函数 3.new关键字的执行过程4.遍历对象&#xff08;for..in) 二.内置对象 一.对象 1.概念 一组无序的相关属性和方法的…

Pycharm破解流程

1.下载pycharm 网上很多&#xff0c;随便找一个&#xff0c;懒得找的话&#xff0c;或者去我传上去的资源pycharm部分直接取 2.下载文件 文件部分&#xff0c;我放在pycharm文件里面一起 打开下载好的激活包 3.执行脚本 先执行unisntall-all-users.vbs,直接双击打开&#xff0c…

咱们来唠唠2024年参加三下乡社会实践活动怎样联系媒体投稿?

作为一名在校大学生,我深深珍视每一次增长见识、锻炼能力的机会,每年寒暑假期间,我都积极参与学院的“三下乡”社会实践活动。这不仅是我贴近生活、体验基层的大好时机,更是我积累人生经验、拓宽视野的重要途径。每次活动结束后,按照学院的要求,我们需要将实践纪实整理成文,向各…

《神奇女侠3:暗黑之魂》AI制作电影短片(下)

《神奇女侠3&#xff1a;暗黑之魂》AI制作电影短片&#xff08;下&#xff09; 黑暗滋生&#xff0c;世界沦陷&#xff0c;神奇女侠独战群魔&#xff0c;唤醒挚爱&#xff0c;守护最后的光明&#xff01; 《神奇女侠3&#xff1a;暗黑之魂》&#xff08;下&#xff09;故事继续…

Scikit-Learn支持向量机分类

Scikit-Learn 支持向量机分类 1、支持向量机&#xff08;SVM&#xff09;1.1、SVM概述1.2、SVM原理1.3、SVM的损失函数1.4、支持向量机分类的优缺点 2、Scikit-Learn支持向量机分类2.1、Scikit-Learn支持向量机分类API2.2、支持向量机分类初体验&#xff08;手写数字识别&#…

AES和RSA加解密算法学习笔记(实战版)

1. 写在前面 今天整理一篇有关密码学的学习笔记,原因是最近做的一个任务是在网络传输的时候,需要对传输的包进行加密和解密工作,以保证传输过程的安全性。所以,这个过程用到了AES和RSA两个算法。 场景:假设我要给我的老师传送毕设代码和论文, 我已经把代码和论文打成了一…

创新入门|解锁您的潜在市场:探秘付费点击广告(PPC)的秘密武器

在我们的营销领域&#xff0c;按点击付费 &#xff08;PPC&#xff09; 广告是增加流量、提高知名度并最终将点击转化为客户的基石策略。这种有针对性的广告模式&#xff0c;即企业只在点击广告时付费&#xff0c;彻底改变了公司投资在线推广的方式。尽管它看起来很简单&#x…

云打印怎么下单?网上云打印下单教程来了!

近些年来&#xff0c;随着移动互联网的发展&#xff0c;云打印也越来越火热。如今有越来越多的用户选择云打印服务。但是现在仍有很多不知道如何下单。那么云打印怎么下单呢&#xff1f;今天小易就来和大家介绍一下网上云打印的下单教程。 云打印怎么下单&#xff1f;网上云打印…

fastgpt、dify功能分析比较

目录 前言 一、dify、fastgpt是什么&#xff1f; 二、同场pk 1.大模型接入 2.chat&#xff08;最简应用&#xff09; 3.发布应用 4.知识库 5.workflow 6.其他 三、一些point记录 总结 前言 现在都开始AI应用开发&#xff0c;何谓AI应用&#xff0c;起码要和AI大模型…

CMake 编译项目

一、概述 cmake 是C一个很重要的编译和项目管理工具&#xff0c;我们在git 上以及常见的项目现在多数都是用cmake 管理的&#xff0c;那么我们今天就做一个同时有Opencv和CGAL 以及PCL 的项目。 二、项目管理 重点是CMakeList.txt 1、CMakeList.txt cmake_minimum_requir…

力扣HOT100 - 104. 二叉树的最大深度

解题思路&#xff1a; class Solution {public int maxDepth(TreeNode root) {if (root null) return 0;return Math.max(maxDepth(root.left), maxDepth(root.right)) 1;} }

构建云原生湖仓:Apache Iceberg与Amoro的结合实践

随着大数据技术的快速发展&#xff0c;企业对数据的处理和分析需求日益增长。传统的数据仓库已逐渐无法满足现代业务对数据多样性和实时性的要求&#xff0c;这促使了数据湖和数据仓库的融合&#xff0c;即湖仓一体架构的诞生。在云原生技术的推动下&#xff0c;构建云原生湖仓…

C语言——小知识和小细节15

一、二维数组与指针 例一 下面的程序运行结果是什么&#xff1a; #include <stdio.h>int main() {int arr[3][2] { (1,2),(3,4),(5,6) };int* p arr[0];printf("%d\n", *p);return 0; } 运行结果&#xff1a; 实际上这里有个小细节&#xff0c;就是二维数…

《Chain-of-Thought Prompting Elicits Reasoning in Large Language Models》【大模型思维链】

目录 前言一、思维链介绍1-1、指令1-2、逻辑依据1-3、示例 二、Cot一般分类2-1、Zero-Shot-CoT2-2、Few-Shot-CoT 三、Cot的好处&缺陷&适用3-1、Cot的好处3-2、Cot的缺陷3-3、Cot的适用 四、变体4-1、自我验证&#xff08;self-consistency checking&#xff09; 总结 …

首发!Llama3纯本地部署攻略!中文方法!

引言 llama3在4月19日刚刚发布&#xff0c;官方的对比结果中在开源模型中堪称世界第一&#xff0c;整好周六日有时间&#xff0c;在魔搭社区上测试一下 一、启动环境 登录魔搭社区&#xff0c;到自己的机器资源&#xff0c;可以看到&#xff0c;可选的机器配置&#xff0c; …

UE5 GAS开发P31 将hud绑定在自己的角色上

在WidgetController内新建一个OverlayAuraWidgetController,然后修改HUD的初始状态 AuraHUD // Fill out your copyright notice in the Description page of Project Settings. #pragma once #include "CoreMinimal.h" #include "GameFramework/HUD.h" #…

Ubuntu系统下 Nvidia驱动 + cuda驱动 + CuDNN安装与卸载

Ubuntu系统下 Nvidia驱动 cuda驱动 CuDNN安装与卸载 一、NVIDIA驱动与CUDA驱动的区别二、NVIDIA驱动安装与卸载1. 查看系统内核版本2. 查看显卡型号3. 查看是否有显卡驱动4. 禁用nouveau并重启5. 卸载旧版本6. 安装&#xff11;&#xff1a;使用标准Ubuntu仓库进行自动化安装…