ROS机器人项目开发11例

Wesley13
• 阅读 689

除了自动驾驶汽车/人工智能外,还有一个火爆的科技热点就是虚拟现实/增强现实设备,这也是本书的第11章。

Leap Motion使用参考官网介绍和之前博文:

1 http://blog.csdn.net/zhangrelay/article/details/52356417

2 https://github.com/madratman/youbot_leapmotionteleop

ROS Android VR设备:

1 https://github.com/cloudspace/ros_cardboard

2 https://github.com/SPARbot/SPARbot-android-app

补充一个不相关内容:https://github.com/Nurgak/Virtual-Robot-Challenge

ROS+V-Rep

Virtual Robot Challenge

ROS机器人项目开发11例

The goal of the Virtual Robot Challenge (VRC) is to introduce the Robotic Operating System (ROS) and V-REP simulation environment by performing autonomous tasks with a simulated robot.

This is to demonstrate the advantages of development using simulation, before eventually moving on to real robots. The advantages are that the code stays the same when moving from simulation to real robot, testing in simulation is much less time consuming (avoid mechanical failures, batteries, sensors failures/calibration...), cheaper and requires less effort in general.

All software used within the scope of this project is free to use.

Theory

ROS is composed of small stand-alone entities called "nodes". Nodes publish and subscribe to messages called "topics" to talk between each other. One can write nodes in C++ or Python, topics are language agnostic. A good introduction can be found on the ROS official website.

The ROS tutorials are well written and straight forward, it is recommended to follow them as least for installation and workspace setup, this provides a good overview on how ROS works and how it is organized.

Hardware

The robot has two wheels and a caster wheel in the back for locomotion. In the front it has six distance sensors, four pointing forwards and two pointing downwards under the robot, and a linear camera showing an image of 128 pixels wide and 1 pixel height.

The robot is based on the Robopoly demonstration robot and can be physically built, any type of robot can be adapted for the simulation.

ROS机器人项目开发11例

Software

The whole installation process has been fully tested on Ubuntu 14.04 with ROS Indigo. One can use VirtualBox if such a computer is not available, however it will slow down the simulation speed.

Installation

  1. Download and install the latest V-REP EDU, define the VREP_ROOT environment variable as the path to V-REP

    export VREP_ROOT=<VREP path>
    
  2. Install ROS Indigo

    $ sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'
    $ sudo apt-key adv --keyserver hkp://ha.pool.sks-keyservers.net --recv-key 0xB01FA116
    $ sudo apt-get update
    $ sudo apt-get install ros-indigo-desktop-full
    $ source /opt/ros/indigo/setup.bash
    
  3. Install the catkin tools:

    $ sudo apt-get install python-catkin-tools
    
  4. Create the workspace for ROS in ~/catkin_ws:

    $ mkdir -p ~/catkin_ws/src
    $ cd ~/catkin_ws/src
    $ catkin_init_workspace
    
  5. Copy the ROS interface package contents from V-REP install folder to ROS workspace:

    $ cp -r <VREP path>/programming/ros_packages/v_repExtRosInterface ~/catkin_ws/src
    
  6. Clone this repository to somewhere and copy the contents the ROS package to the workspace:

    $ git clone https://github.com/Nurgak/Virtual-Robot-Challenge.git
    $ cd Virtual-Robot-Challenge
    $ cp -r Software/ROS/vrc ~/catkin_ws/src
    
  7. Build the packages (grab a coffee):

    $ cd ~/catkin_ws
    $ catkin build
    
  8. Copy the ROS interface plugin to the V-REP root folder

    $ cp ~/catkin_ws/devel/lib/libv_repExtRosInterface.so <VREP path>
    
  9. Source the setup file, this needs to be done in every new terminal:

    $ cd ~/catkin_ws $ source devel/setup.bash

  10. Export the ROS_MASTER_URI environment variable

    $ export ROS_MASTER_URI=http://localhost:11311

Programming

The code actuating the robot motors and publishing its sensor data is written in Lua language in V-REP. It is very simple and only used to exchange data with the ROS framework, not for actual behavior logic. This is the place to add new code if one wishes to add new sensors to the simulated robot. To view the code open the V-REP scene and on the left side double-click on the script icon next to the robot node.

ROS机器人项目开发11例

The robot behavior is dictated by the Python scripts stored in ~/catkin_ws/src/vrc/src/. The sample.py script shows how to process the data from all the different sensors on the robot.

The launch files are used to start different nodes at the same time, they are stored in ~/catkin_ws/src/vrc/launch/, think of them as shortcuts.

Follow the line

To goal is to follow a line. Very basic approach, however one can always optimize the system to make it faster.

  1. Run ROS core in a terminal

    $ roscore
    
  2. From another terminal run V-REP, always start V-REP after ROS core

    $ sh <VREP path>/vrep.sh
    
  3. In V-REP open the arena.ttt from the /Simulation folder

  4. Click on the play button in V-REP to launch the simulation

    ROS机器人项目开发11例

  5. In a third terminal launch the arena.launch file which will starts some nodes

    $ roslaunch vrc arena.launch
    
  6. Finally in a fourth terminal run the line follower program

    $ rosrun vrc line_follower.py
    

The robot should start following the line marked on the floor.

ROS机器人项目开发11例

Teleoperation

One can remotely operate the robot using the keyboard using the teleop_twist_keyboard package:

$ sudo apt-get install ros-indigo-teleop-twist-keyboard

Stop the line follower script (ctrl+c) and run:

$ rosrun teleop_twist_keyboard teleop_twist_keyboard.py

The terminal must be in focus for the commands to be executed.

Exploration and mapping

ROS can do mapping using the robot sensors and its position. First make sure the slam_gmapping and pointcloud_to_laserscan packages are installed:

$ sudo apt-get install ros-indigo-slam-gmapping
$ sudo apt-get install ros-indigo-pointcloud-to-laserscan

And launch the mapping scene with:

$ roslaunch vrc mapping.launch
$ rosrun vrc explorer.py

The launch file runs the gmapping and the RVIZ visualization nodes. Accessible areas are marked in white and inaccessible areas are marked in black.

The explorer node makes the robot go around the arena and avoid obstacles, whenever it encounters an obstacle it will turn on itself for a random amount of time and continue.

ROS机器人项目开发11例

Physical robot

When the simulation yields satisfying results one can use a real robot that subscribes to and publishes the same ROS topics as the virtual robot, this way the same software running on the computer can be used. The implementation for this can be done in various ways and is left up to the reader.

----

本文同步分享在 博客“zhangrelay”(CSDN)。
如有侵权,请联系 support@oschina.cn 删除。
本文参与“OSC源创计划”,欢迎正在阅读的你也加入,一起分享。

点赞
收藏
评论区
推荐文章
blmius blmius
3年前
MySQL:[Err] 1292 - Incorrect datetime value: ‘0000-00-00 00:00:00‘ for column ‘CREATE_TIME‘ at row 1
文章目录问题用navicat导入数据时,报错:原因这是因为当前的MySQL不支持datetime为0的情况。解决修改sql\mode:sql\mode:SQLMode定义了MySQL应支持的SQL语法、数据校验等,这样可以更容易地在不同的环境中使用MySQL。全局s
皕杰报表之UUID
​在我们用皕杰报表工具设计填报报表时,如何在新增行里自动增加id呢?能新增整数排序id吗?目前可以在新增行里自动增加id,但只能用uuid函数增加UUID编码,不能新增整数排序id。uuid函数说明:获取一个UUID,可以在填报表中用来创建数据ID语法:uuid()或uuid(sep)参数说明:sep布尔值,生成的uuid中是否包含分隔符'',缺省为
待兔 待兔
4个月前
手写Java HashMap源码
HashMap的使用教程HashMap的使用教程HashMap的使用教程HashMap的使用教程HashMap的使用教程22
Jacquelyn38 Jacquelyn38
3年前
2020年前端实用代码段,为你的工作保驾护航
有空的时候,自己总结了几个代码段,在开发中也经常使用,谢谢。1、使用解构获取json数据let jsonData  id: 1,status: "OK",data: 'a', 'b';let  id, status, data: number   jsonData;console.log(id, status, number )
Stella981 Stella981
3年前
KVM调整cpu和内存
一.修改kvm虚拟机的配置1、virsheditcentos7找到“memory”和“vcpu”标签,将<namecentos7</name<uuid2220a6d1a36a4fbb8523e078b3dfe795</uuid
Wesley13 Wesley13
3年前
mysql设置时区
mysql设置时区mysql\_query("SETtime\_zone'8:00'")ordie('时区设置失败,请联系管理员!');中国在东8区所以加8方法二:selectcount(user\_id)asdevice,CONVERT\_TZ(FROM\_UNIXTIME(reg\_time),'08:00','0
Wesley13 Wesley13
3年前
00:Java简单了解
浅谈Java之概述Java是SUN(StanfordUniversityNetwork),斯坦福大学网络公司)1995年推出的一门高级编程语言。Java是一种面向Internet的编程语言。随着Java技术在web方面的不断成熟,已经成为Web应用程序的首选开发语言。Java是简单易学,完全面向对象,安全可靠,与平台无关的编程语言。
Stella981 Stella981
3年前
Django中Admin中的一些参数配置
设置在列表中显示的字段,id为django模型默认的主键list_display('id','name','sex','profession','email','qq','phone','status','create_time')设置在列表可编辑字段list_editable
Wesley13 Wesley13
3年前
MySQL部分从库上面因为大量的临时表tmp_table造成慢查询
背景描述Time:20190124T00:08:14.70572408:00User@Host:@Id:Schema:sentrymetaLast_errno:0Killed:0Query_time:0.315758Lock_
Python进阶者 Python进阶者
10个月前
Excel中这日期老是出来00:00:00,怎么用Pandas把这个去除
大家好,我是皮皮。一、前言前几天在Python白银交流群【上海新年人】问了一个Pandas数据筛选的问题。问题如下:这日期老是出来00:00:00,怎么把这个去除。二、实现过程后来【论草莓如何成为冻干莓】给了一个思路和代码如下:pd.toexcel之前把这