当前位置: 首页 > article >正文

【ROS】ubuntu18.04安装ROS(ROS1 Melodic)

1、添加中科大ROS源

1.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'

1. 2、添加公钥

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

1. 3、更新源

sudo apt update

2、安装ROS

2.1、版本选择

ROS分ROS1、ROS2,同时在不同ubuntu版本下有不同的版本。
ubuntu18.04对应的版本:

ROS1——Melodic Morenia
ROS2——Dashing Diademata

在这里插入图片描述

2.2、安装ROS1

sudo apt install ros-melodic-desktop-full
sudo apt install ros-melodic-rqt*

这个命令将安装完整的ROS软件,包括ROS,rqt,rviz,机器人通用库,2D / 3D模拟器,导航和2D / 3D感知等等的全套基础组件

2.3、设置环境变量

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

2.4、下载python-ros组件

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

3、使用

3.1、初始化rosdep

初始化rosdep时报错:

$ sudo rosdep init
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.

解决方法参考:解决rosdep init ERROR: cannot download default sources list 问题

修改文件 /etc/hosts

203.208.40.66 translate.google.com
203.208.40.66 translate.googleapis.com

199.232.28.133 raw.githubusercontent.com
192.30.253.118 gist.github.com
185.199.110.153 github.io
151.101.113.194 github.global.ssl.fastly.net
52.216.227.168 github-cloud.s3.amazonaws.com
52.74.223.119 github.com
199.232.28.133 avatars1.githubusercontent.com
199.232.28.133 avatars2.githubusercontent.com
199.232.28.133 avatars0.githubusercontent.com
199.232.28.133 avatars3.githubusercontent.com
199.232.28.133 user-images.githubusercontent.com
199.232.28.133 avatars.githubusercontent.com
199.232.28.133 github.map.fastly.net
199.232.28.133 avatars7.githubusercontent.com

# Amazon AWS Start
54.239.31.69	aws.amazon.com
54.239.30.25	console.aws.amazon.com
54.239.96.90	ap-northeast-1.console.aws.amazon.com
54.240.226.81	ap-southeast-1.console.aws.amazon.com
54.240.193.125	ap-southeast-2.console.aws.amazon.com
54.239.54.102	eu-central-1.console.aws.amazon.com
177.72.244.194	sa-east-1.console.aws.amazon.com
176.32.114.59	eu-west-1.console.aws.amazon.com
54.239.31.128	us-west-1.console.aws.amazon.com
54.240.254.230	us-west-2.console.aws.amazon.com
54.239.38.102	s3-console-us-standard.console.aws.amazon.com
54.231.49.3	s3.amazonaws.com
52.219.0.4	s3-ap-northeast-1.amazonaws.com
54.231.242.170	s3-ap-southeast-1.amazonaws.com
54.231.251.21	s3-ap-southeast-2.amazonaws.com
54.231.193.37	s3-eu-central-1.amazonaws.com
52.218.16.140	s3-eu-west-1.amazonaws.com
52.92.72.2	s3-sa-east-1.amazonaws.com
54.231.236.6	s3-us-west-1.amazonaws.com
54.231.168.160	s3-us-west-2.amazonaws.com
52.216.80.48	github-cloud.s3.amazonaws.com
54.231.40.3	github-com.s3.amazonaws.com
52.216.20.171	github-production-release-asset-2e65be.s3.amazonaws.com
52.216.228.168	github-production-user-asset-6210df.s3.amazonaws.com

修改文件:/etc/resolv.conf ,添加google的DNS

nameserver 8.8.8.8
nameserver 8.8.4.4

注:系统中缺少文件 /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

3.2、更新

rosdep update

注意:更新时,不要使用root权限,即不要使用sudo,否则会有提示

$ sudo rosdep update
reading in sources list data from /etc/ros/rosdep/sources.list.d
Warning: running 'rosdep update' as root is not recommended.
  You should run 'sudo rosdep fix-permissions' and invoke 'rosdep update' again without sudo.

万一使用sudo,可以使用提示的命令清除下,然后再使用rosdep update

sudo rosdep fix-permissions
rosdep update

如果报错,多执行几遍

3.3、安装Catkin

Catkin是ROS对CMake进行的扩展

sudo apt-get install ros-melodic-catkin python-catkin-tools

4、运行

ROS著名的测试程序就是:键盘控制小乌龟运动;
分别在三个终端中运行,如下命令:

roscore
rosrun turtlesim turtlesim_node
rosrun turtlesim turtle_teleop_key

效果如下:
在这里插入图片描述


http://www.kler.cn/a/15085.html

相关文章:

  • Kotlin的data class
  • 【AtCoder】Beginner Contest 380-F.Exchange Game
  • Linux一些常用的系统优化
  • K8s 一键部署 MongoDB 的 Replica-Set 和 MongoDB-Express
  • Python设计模式详解之5 —— 原型模式
  • 用Ruby编写一个自动化测试脚本,验证网站登录功能的正确性。
  • 报告打印的相关CAPL函数,实例代码演示汇总
  • VS 对话框编辑器命令的默认快捷键
  • 创建第一个DJango3的后端项目
  • Kafka 安装部署-单节点
  • PostgreSQL 数据类型转换
  • Java泛型之通配符类型
  • Linux 内存 pt.1
  • 正则表达式基础
  • 【Java】SpringBoot中实现多数据源切换
  • Vue-列表过滤
  • 题解,超星进程
  • 记录 docker linux部署jar
  • 三问 ThreadLocal —— 有什么用 ? 使用时有什么潜在风险?原理 ?
  • 【C++】模板进阶
  • mysql实现存在则保存,不存在则更新
  • Java线程池核心参数
  • CA(证书颁发机构)
  • 软件测试概念
  • MATLAB-Lingo求解线性规划问题-奶制品2
  • 车联网V2X通信技术及应用介绍