ROS从零入门教程

ROS(Robot Operating System)是一个机器人软件平台,它具备类似操作系统的功能,但却不是真正的操作系统,需要运行在Linux系统下,最能支持ROS运行的便是Ubuntu系统。

   我们需要先安装Ubuntu系统(最好不在虚拟机下运行Ubuntu),通过在终端里输指令来下载ROS以及其相关软件包(需联网)。

   该教程将以在U盘上安装ROS为例来安装ROS,引导初学者从零入门ROS,以运行小海龟的例子来练习使用ROS,了解其基本概念。

一、 ROS在U盘上的安装方法

1.将Linux-Ubuntu系统安装到U盘:

https://jingyan.baidu.com/article/a681b0de099c0d3b184346a2.html

2.ROS的安装:

https://www.cnblogs.com/liu-fa/p/5779206.html

二、 ROS试用练习

按照以下提示和命令来试用ROS:

Create workspace, the folder locates in ~/catkin_ws/src.

$ mkdir -p ~/catkin_ws/src

$ cd ~/catkin_ws/src

$ catkin_init_workspace


There is not function package in the folder, only the CMakelist.txt in it.

Next, we need to compile the workspace with the command below.

$ cd ~/catkin_ws

$ catkin_make

Use the command ls, we can see the new folders.

Use this to complete configuration.

$ source devel/setup.bash


Create ROS function package.

$ cd ~/catkin_ws/src

$ catkin_create_pkg chapter2_tutorials std_msgs roscpp


Compile ROS function package.

$ cd ~/catkin_ws/

$ catkin_make     //You must run the command $ catkin_make in the workspace rather than in other folders.


Use ROS nodes.

Run ROS core file.

$ roscore   

Open another terminal and continue.

$ rosrun turtlesim turtlesim_node   //Launch a new node(turtle).

Appear a window, open another terminal and continue.

$ rosnode list

$ rosnode info /turtlesim   //To see many information about debuging procedure.

$ rostopic bw -h  //To see the detailed information of the parameter about rostopic tool.

$ rosrun turtlesim turtle_teleop_key  //Use this node to move turtle with arrow.

Open another terminal and continue.

$ rostopic list

$ rostopic echo /turtle1/cmd_vel      //To browse the information from nodes.

$ rostopic type /turtle1/cmd_vel      //Message type.

$ rosmsg show geometry_msgs/Twist


Control the turtle.

$ rostopic pub /turtle1/cmd_vel geometry_msgs/Twist -1 -- '{linear: {x: 20,y: 0.0,z: 0.0},angular: {x: 0.0,y: 0.0,z: 4.7}}'

You can see the turtle move for a while.



Run the RViz.

$ rosrun rviz rviz -d `rospack find rbx1_nav`/sim.rviz

Open another terminal.

$ roscore

Open another terminal.

$ rosrun rviz rviz -d `rospack find rbx1_nav`/sim.rviz

You can see the RViz simulator.

Run this command.

$ rostopic pub /cmd_vel geometry_msgs/Twist -r 10 '{linear: {x:  0.2, y: 0, z: 0}, angular: {x: 0, y: 0, z: 0.5}}'

The robot move along a circle.


三、代码下载

1.  创建节点时所用的cpp代码下载网址:

https://github.com/AaronMR/ROS_Book_Hydro

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 假期临摹的花,其实画的很牵强。花瓣浅淡着色不匀,明暗度表现差强人意,只是还好有一颗继续热爱的心,故坚持画下去,希望...
    只有桂花香暗飘过阅读 215评论 0 5
  • 能读懂《正念的奇迹》,就学会了保持正念,就不会被欲望控制,被情绪左右,而是心平气和,活在当下。 作者一行禅师...
    飞驰的阿飞阅读 488评论 0 0
  • 早上在地铁八号线上,有人喊:别挤了,再挤要吐了
    陈倩纤阅读 170评论 0 0
  • 孟子:“鱼,我所欲也;熊掌,亦我所欲也。二者不可兼得,舍鱼而取熊掌者也。生,鱼我所欲也;义,亦我所欲也,二者不可兼...
    冯沁妍阅读 473评论 0 0