您的位置:首页 > 其它

ROS+SLAM学习日志(2)基础

2017-10-18 20:13 211 查看
ROS Kinetic Kame安装完成后,可以用一下指令检测环境是否安装成功

$ printenv | grep ROS


安装成功则会显示如下图所示



下面先来安装一下教程需要的仿真器,这里有很多已经写好的程序,可以很好地用来学习。

$ sudo apt-get install ros-kinetic-ros-tutorials


然后简单介绍一下一些相关概念

文件系统

想要开始使用ROS系统,那么就首先先了解它的文件系统。



工作空间

工作空间是一个包含包的文件夹,用于编写源文件与编译包。当你想同时编译不同的包是,就要用到工作空间来存放这些包。典型的工作空间如下所示,每个文件夹都是有不同任务的不同的空间。

• The Source space: In the Source space (the src folder), you put your packages, projects, clone packages, and so on. One of the most important files in this space is CMakeLists.txt. The src folder has this file because it is invoked by CMake when you configure the packages in the workspace. This file is created with the catkin_init_workspace command.

• The Build space: In the build folder, CMake and catkin keep the cache information, configuration, and other intermediate files for our packages and projects.

• The Development (devel) space: The devel folder is used to keep the compiled programs. This is used to test the programs without the installation step. Once the programs are tested, you can install or export the package to share with other developers.

如果要编译工作空间所有的包,使用catkin_make指令。

Packet

Packet是一种典型的文件结构,如下所示:



关于包的指令如下

• rospack: This command is used to get information or find packages in the system.

• catkin_create_pkg: This command is used when you want to create a new package.

• catkin_make: This command is used to compile a workspace.

• rosdep: This command installs the system dependencies of a package.

• rqt_dep: This command is used to see the package dependencies as a graph. If you want to see the package dependencies as a graph, you will find a plugin called package graph in rqt. Select a package and see the dependencies.

· 节点:节点是一个可执行单位,并通过ROS与其他节点通讯

· 消息:ROS定于或发布一个话题所使用的数据类型

· 主题:节点可以向话题发布消息也可以订阅话题来接受消息

· 主机:可以看做ROS的服务器(帮助节点找到其他节点)

· rosout:等同于stdout/stderr

· roscore: Master + rosout + parameter server

节点就是一个包含ROS包的可执行文件。ROS节点使用ROS客户端库来与其他节点通讯。节点可以发布或订阅话题,还可以提供或使用服务。客户端库有两种,rospy也就是python客户端库,roscpp也就是c++客户端库。

可以跟着这上面跑一遍了解节点运行 http://wiki.ros.org/ROS/Tutorials/UnderstandingNodes 教程很简单,这里就不说了。

就一个,运行节点使用 rosrun [package_name] [node_name], 前一个是包名,后一个节点名。

• rosnode info NODE: This prints information about a node

• rosnode kill NODE: This kills a running node or sends a given signal

• rosnode list: This lists the active nodes

• rosnode machine hostname: This lists the nodes running on a particular machine or lists machines

• rosnode ping NODE: This tests the connectivity to the node.

• rosnode cleanup: This purges the registration information from unreachable nodes

Topic是消息传输的总线

http://wiki.ros.org/ROS/Tutorials/UnderstandingTopics 这个教程是理解topic的,这里有两个节点,之前的乌龟程序跟键盘控制(turtlesim_node and the turtle_teleop_key ),这两者便是通过ROS Topic 进行通讯。 turtle_teleop_key发布一个键盘按键到topic上,同时turtlesim订阅相同的topic去接收按键。通过rqt _graph 可以得到如下的图,红色箭头就是所谓的topic



• rostopic bw /topic: This displays the bandwidth used by the topic.

• rostopic echo /topic: This prints messages to the screen.

• rostopic find message_type: This finds topics by their type.

• rostopic hz /topic: This displays the publishing rate of the topic.

• rostopic info /topic: This prints information about the active topic, topics published, ones it is subscribed to, and services.

• rostopic list: This prints information about active topics.

• rostopic pub /topic type args: This publishes data to the topic. It allows us to create and publish data in whatever topic we want, directly from the command line.

• rostopic type /topic: This prints the topic type, that is, the type of message it publishes.

ROS服务是另一种节点之间通讯的方式。服务允许节点发送请求与接收应答。关于ROS服务可以通过rosservice来调用。

rosservice list print information about active services

rosservice call call the service with the provided args

rosservice type print service type

rosservice find find services by service type

rosservice uri print service ROSRPC uri

ROS参数服务器之间介绍过,是用来存放节点共用的参数的。参数类型可以是整形,浮点型,布尔型,字典,列表等。使用rosparam命令来设置与使用参数。

rosparam set set parameter

rosparam get get parameter

rosparam load load parameters from file

rosparam dump dump parameters to file

rosparam delete delete parameter

rosparam list list parameter names

Bags

前面有个packet翻译过来也是包,所以这里都用英文名称好了。Bags是一种保存于重现ROS的消息数据的格式。是一种重要的存储数据的机制,如传感器数据,这种数据很难收集但在开发与测试算法上十分重要。.bag文件保存所有的关于messages,topics,services等信息。

• rosbag: This is used to record, play, and perform other operations

• rqt_bag: This is used to visualize data in a graphic environment

• Rostopic: This helps us see the topics sent to the nodes
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: