ROS from entry to proficient (1) ROS introduction, installation and common problems

Get into the habit of writing together! This is the 12th day of my participation in the "Nuggets Daily New Plan · April Update Challenge", click to view the details of the event .


1 Introduction to ROS

1.1 What is ROS?

ROS (Robot Operating System) is an open source meta-operating system for robots. It provides the services expected by an operating system, including

  • hardware abstraction
  • Low-level device control
  • Implementation of common functions
  • message passing between processes
  • package management
  • Tools and library functions needed to obtain, compile, write, and run code across computers


insert image description here

1.2 Why use ROS?

The main goal of ROS is to provide code reuse support for robotics research and development . Simply put, avoid reinventing the wheel.

insert image description here

Why can ROS improve code reuse rate?

Because ROS has the concept of package and function package , the concept of analogy and C++or pythonlibrary, these packages are easy to be shared and published, and ROS also supports a kind of federation system similar to code repository, which can also realize project collaboration and release. This design can make the development and implementation of a project completely modular, and at the same time, all projects can be integrated by the basic tools of ROS.

insert image description here

In addition, ROS has the following advantages:

  • Lean: ROS is designed to be as lean as possible and easy to integrate with other robotics software frameworks
  • Language independence: In order to support more application development and transplantation, ROS is designed as a framework structure with weak language correlation. A neutral definition language describes the message interface between modules, Javaand C++ROS Pythoncan be developed.
  • Large applications: ROS is suitable for large runtime systems and large development pipelines
  • 丰富的组件化工具包:ROS可采用组件化方式集成一些工具和软件到系统中并作为一个组件直接使用,如RVIZGazebo等,后面都会介绍。
  • 免费且开源:开发者众多,功能包多

2 ROS发展历程

ROS是一个由来已久、贡献者众多的大型软件项目

在ROS诞生之前,很多学者认为,机器人研究需要一个开放式的协作框架,并且已经有不少类似的项目致力于实现这样的框架。

2007年,柳树车库(Willow Garage)提供了大量资源,用于将斯坦福大学机器人项目中的软件系统进行扩展与完善,同时,在无数研究人员的共同努力下,ROS的核心思想和基本软件包逐渐得到完善。

ROS的发行版本指ROS软件包的版本,其与Linux的发行版本(如Ubuntu)的概念类似。推出ROS发行版本的目的在于使开发人员可以使用相对稳定的代码库,直到其准备好将所有内容进行版本升级为止。因此,每个发行版本推出后,ROS开发者通常仅对这一版本的bug进行修复,同时提供少量针对核心软件包的改进。

建议安装的发行版版本: noeticmelodickinetic

3 ROS安装

3.1 基本安装

ROS的安装步骤如下

  1. 设置软件源
    sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'
    复制代码
  2. 设置秘钥
    sudo apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654
    复制代码
  3. 更新软件源
    sudo apt update
    复制代码
  4. 安装ROS(推荐安装桌面完整版安装——包含ROSrqtrviz、2D/3D仿真器等)
    # kinetic
    sudo apt install ros-kinetic-desktop-full
    # noetic
    sudo apt install ros-noetic-desktop-full
    # melodic
    sudo apt install ros-melodic-desktop-full
    复制代码
  5. ROS环境变量配置
    # kinetic
    echo "source /opt/ros/kinetic/setup.bash" >> ~/.bashrc
    # noetic
    echo "source /opt/ros/noetic/setup.bash" >> ~/.bashrc
    # melodic
    echo "source /opt/ros/melodic/setup.bash" >> ~/.bashrc
    复制代码
  6. 卸载ROS
    sudo apt remove ros-*
    复制代码

3.2 初始化rosdep

rosdepIt is ROSa command line tool used to install ROSsystem dependencies. When installing the ROSsystem, it rosdepwill be installed automatically, so it does not need to be installed separately, but needs to be initialized and updated.

sudo rosdep init
rosdep update
复制代码

When ROS is installed for the first time in China, 90% of the time when rosdep is initialized, it will encounter a timeout failure error. The latest solution is recorded here.

Go to the rosdistro.git download rosdistro-master.zipand put it in the project directory, for example

~/Project/ROS
复制代码

Modify 20-default.list, execute:

sudo gedit /etc/ros/rosdep/sources.list.d/20-default.list
复制代码

Replace all the content linked raw.githubusercontent.comin it with the link to the local file, and 20-default.listhe content of the last t is:

# os-specific listings first
yaml file:///home/winter/Project/ROS/rosdistro-master/rosdep/osx-homebrew.yaml osx

# generic
yaml file:///home/winter/Project/ROS/rosdistro-master/rosdep/base.yaml
yaml file:///home/winter/Project/ROS/rosdistro-master/rosdep/python.yaml
yaml file:///home/winter/Project/ROS/rosdistro-master/rosdep/ruby.yaml
gbpdistro file:///home/winter/Project/ROS/rosdistro-master/releases/fuerte.yaml fuerte

# newer distributions (Groovy, Hydro, ...) must not be listed anymore, they are being fetched from the rosdistro index.y
复制代码

Then modify the following files, and also raw.githubusercontent.comreplace all the linked content with links to local files, each file has one place that needs to be modified.

1. /usr/lib/python2.7/dist-packages/rosdep2/gbpdistro_support.py
FUERTE_GBPDISTRO_URL = 'file:///home/winter/Project/ROS/rosdistro-master/releases/fuerte.yaml'

2. /usr/lib/python2.7/dist-packages/rosdep2/rep3.py
REP3_TARGETS_URL = 'file:///home/winter/Project/ROS/rosdistro-master/releases/targets.yaml'

3. /usr/lib/python2.7/dist-packages/rosdep2/sources_list.py
DEFAULT_SOURCES_LIST_URL = 'file:///home/winter/Project/ROS/rosdistro-master/rosdep/sources.list.d/20-default.list'

4. /usr/lib/python2.7/dist-packages/rosdistro/__init__.py
DEFAULT_INDEX_URL = 'file:///home/winter/Project/ROS/rosdistro-master/index-v4.yaml'
复制代码

3.3 Test ROS

terminal input

roscore
复制代码

The following information appears to successfully run the ROS master manager

在这里插入图片描述

Then do the classic turtle test , enter:

rosrun turtlesim turtlesim_node
复制代码

The turtle emulator appears

在这里插入图片描述

enter

rosrun turtlesim turtle_teleop_key
复制代码

Focus the mouse on the third terminal window, and then use the arrow keys on the keyboard to operate the turtle to move and leave a track on the screen

在这里插入图片描述

So far, the basic installation and configuration of ROS is successful.

4 Frequently Asked Questions

  1. roscore cannot run as another roscore/master is already running. Please kill other roscore/master processes before relaunching.The ROS_MASTER_URI is http://ubuntu:11311/The traceback for the exception was written to the log file

    ==Solution==: Kill the existing ros node manager

    killall -9 roscore && killall -9 rosmaster
    复制代码
  2. E: Unable to locate package ros-kinetic-desktop-full

    ==Solution==: Different rosdistributions correspond to different ubuntuversions: Ubuntu16.04correspond ros-kinetic, Ubuntu18.04correspond ros-melodic, Ubuntu20.04correspond ros-noetic.在这里插入图片描述

  3. rosdep: command not found

    ==Solution==: rosNo automatic installation during installation rosdep, manual installation

    # Ubuntu20.04
    sudo apt-get install python3-rosdep
    # Ubuntu18.04
    sudo apt-get install python-rosdep
    复制代码

For more content, please pay attention to my AI channel "AI Technology Club"

おすすめ

転載: juejin.im/post/7085915412730216479