ROS-安装ROS

安装ROS

  • os
  • 在ubuntu18中安装ros
    • 1.安装
      • [1.1 ubuntu18 配置阿里源](#1.1 ubuntu18 配置阿里源)
      • [1.2 设置sources.list](#1.2 设置sources.list)
      • [1.4 安装](#1.4 安装)
      • [1.5 初始化 rosdep](#1.5 初始化 rosdep)
        • [报错1 sudo: rosdep:找不到命令](#报错1 sudo: rosdep:找不到命令)
        • [报错2 ERROR: cannot download default sources](#报错2 ERROR: cannot download default sources)
      • [1.6 设置环境变量](#1.6 设置环境变量)
      • [1.7 安装依赖项](#1.7 安装依赖项)
    • 测试

os

系统:ubuntu18.04

ros:Melodic

在ubuntu18中安装ros

1.安装

1.1 ubuntu18 配置阿里源

这个可以去搜索怎么修改阿里源

1.2 设置sources.list

这个是ros的ubuntu官方源,但是下载很慢

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

建议使用阿里源

bash 复制代码
sudo sh -c '. /etc/lsb-release && echo "deb https://mirrors.aliyun.com/ros/ubuntu/ `lsb_release -cs` main" > /etc/apt/sources.list.d/ros-latest.list'

或者直接在/etc/apt/sources.list.d/ros-latest.list中添加

bash 复制代码
deb https://mirrors.aliyun.com/ros/ubuntu/ bionic main   

```bash
### 1.3 设置密钥

```bash
curl -sSL 'http://keyserver.ubuntu.com/pks/lookup?op=get&search=0xC1CF6E31E6BADE8868B172B4F42ED6FBAB17C654' | sudo apt-key add -

1.4 安装

先更新源

bash 复制代码
sudo apt update

安装ros工具,推荐完整版

bash 复制代码
sudo apt install ros-melodic-desktop-full

1.5 初始化 rosdep

bash 复制代码
sudo rosdep init
rosdep update

但是这里会报错,

报错1 sudo: rosdep:找不到命令

解决方法

bash 复制代码
sudo apt-get install python-rosdep

报错2 ERROR: cannot download default sources

bash 复制代码
ERROR: cannot download default sources list from:
https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/sources.list.d/20-default.list
Website may be down.

解决方法

  1. 在本地新建对应目录/etc/ros/rosdep/sources.list.d
bash 复制代码
sudo mkdir -p /etc/ros/rosdep/sources.list.d
cd /etc/ros/rosdep/sources.list.d
sudo gedit 20-default.list
  1. 然后将下面内容复制粘贴到新建打开的文档中:
bash 复制代码
# 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
  1. 之后在继续运行ROS安装下一步:rosdep update
  2. 如果出现错误:
bash 复制代码
ERROR: unable to process source [https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/osx-homebrew.yaml]:<urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:590)> (https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/osx-homebrew.yaml)

在/usr/lib/python2.7/dist-packages/rosdep2/sources_list.py中顶部直接插入两行代码取消SSL验证

bash 复制代码
import ssl ssl._create_default_https_context = ssl._create_unverified_context
  1. 如果出现错误:
bash 复制代码
<urlopen error <urlopen error [Errno 111] Connection refused>
bash 复制代码
sudo vi /etc/resolv.conf 

将原有的nameserver注释掉,添加

bash 复制代码
nameserver 8.8.8.8 #google域名服务器 
nameserver 8.8.4.4 #google域名服务器

以上操作完后

bash 复制代码
rosdep update

1.6 设置环境变量

bash 复制代码
echo "source /opt/ros/melodic/setup.bash" >> ~/.bashrc
source ~/.bashrc

1.7 安装依赖项

bash 复制代码
sudo apt-get install python-rosinstall python-rosinstall-generator python-wstool build-essential

测试

开启一个终端,启动ros master

bash 复制代码
roscore

开启一个终端,启动小海龟仿真器

bash 复制代码
rosrun turtlesim turtlesim_node

开启一个终端,启动小海龟控制节点

bash 复制代码
rosrun turtlesim turtle_teleop_key

到这里如果可以用方向键控制小海龟移动,ros就安装成功了

相关推荐
小烤箱5 小时前
什么是 ROS2:机器人软件的数据加工工业园区
人工智能·机器人·ros
feasibility.2 天前
ROS2+Gazebo+VLM服务:纯仿真环境下的具身智能闭环系统| 大脑-小脑分离控制
人工智能·机器人·ros·仿真·具身智能·vla·vlm
前网易架构师-高司机4 天前
ROS2 Jazzy+Gazebo Harmonic 环境下,用 URDF 搭建机器人,配置物理属性、插件与桥接,修复车轮和激光雷达故障 (手把手保姆级教程)
开发语言·算法·golang·机器人·ros
波特率11520014 天前
在ROS2当中两种rmw比较(CycloneDDS和FastDDS)
ros·ros2·dds
kobesdu19 天前
【ROS2实战笔记-19】ROS2 生命周期节点的启动顺序、状态转换陷阱与热备方案
java·前端·笔记·机器人·ros·ros2
波特率11520019 天前
ROS2当中的几个关键的环境变量
机器人·ros·ros2
勤自省19 天前
ROS2从入门到“重启解决”:21讲8~12章踩坑血泪史与核心总结
linux·开发语言·ubuntu·ssh·ros
kobesdu21 天前
【ROS2实战笔记-20】ROS2 bag 录播与时间模拟:从基础操作到高级调试技巧
笔记·机器人·ros·ros2
kobesdu21 天前
【ROS2实战笔记-18】ROS2 通信的隐秘控制:DDS 配置参数如何决定系统性能
网络·人工智能·笔记·机器人·开源·ros·人形机器人
kobesdu21 天前
Cartographer 定位优化:降低计算量、提升实时性与稳定性
ros·移动机器人·cartographer