ROS的安装、基本指令和ROS编程实践

本文详细介绍了ROS在Ubuntu16.04上的安装过程,包括解决网络问题的方法。接着讲解了ROS的基本指令,如rostopic、rosrun等,并通过控制乌龟移动的例子演示了发布者和订阅者的实现。此外,还介绍了如何创建工作空间、功能包,以及自定义msg的完整流程。最后,提供了ROS编程中应注意的事项。
摘要由CSDN通过智能技术生成

一、ubutnu16.04安装ros

  1. 打开"软件和更新“,确保下图中的”Ubuntu软件“一栏中的前四行被打上勾
    在这里插入图片描述
  2. 添加ros软件源
sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'
  1. 添加秘钥
sudo apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654
  1. 安装ROS,这里是ubuntu16.04,推荐安装kinetic。这里如果报错,是网络服务商的原因,可以用手机开热点给电脑,然后安装即可,下面过程报错同样可以这样来解决。
 sudo apt update
 sudo apt install ros-kinetic-desktop-full
  1. 初始化rosdep,记住rosdep update一定不要加sudo
 sudo rosdep init
 rosdep update
  1. 在rosdep init时会报错如下:
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.

问题描述为:不能从这个网址中下载源。这个问题现在有个极佳的解决方案

#打开hosts文件
sudo gedit /etc/hosts
#在文件末尾添加
151.101.84.133  raw.githubusercontent.com
#然后
sudo rosdep init
rosdep update

成功了!!!
 
下面这一段解决方案就没用了,可以不看。
我们复制网址到浏览器,发现是可以进入的,网址内容如下:

# 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

既然不能下载,那我们手动在本地创建,在/etc目录下,我们发现并没有ros文件夹,于是我们手动逐级创建:

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

然后将网址内容复制进去,注意将网址内容中的所有githubusercontent改成github,修改后的文件内容如下:

# os-specific listings first
yaml https://raw.github.com/ros/rosdistro/master/rosdep/osx-homebrew.yaml osx

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

# newer d
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值