ROS核心概念

节点(Node) --执行单元

*执行具体任务的进程,独立运行的可执行文件;
*不同节点可使用不同的编程语言,可分布运行在不同的主机;
*节点在系统中的名称必须是唯一的.

节点管理器(ROS Master) --控制中心

*为节点提供命名和注册服务;

*跟踪和记录话题/服务通信,辅助节点互相查找,建立连接;
*提供参数服务器,节点使用此服务器存储和检索时的参数.

话题(Topic) --异步通信机制

*节点间用来传输数据的重要总线;
*使用发布/订阅模型,数据由发布者传输到订阅者,同一个话题的订阅者或发布者可以不唯一.

消息(Mwssage) --话题数据

*具有一定的类型和数据结构,包括ROS提供的标准类型和用户自定义类型;
*使用编程语言无关的.msg文件,编译过程中生成对应的代码文件.

服务(Service) --同步通信机制

*使用客户端/服务器(C/S)模型,客户端发送请求数据,服务器完成处理后返回问答数据;
*使用编程语言无关的.srv文件定义请求和应答数据结构,编译过程中生成对应的代码文件.

参数(Parameter) --全局共享字典

*可通过网络访问的共享,多变量字典;
*节点使用此服务器来储存和检索运行时的参数;
*适合存储静态,非二进制的配置参数,不适合存储动态配置的数据.

功能包(Package)

*ROS软件中的基本单元,包含节点源码,配置文件,数据定义等

功能包清单(Package manifest)

*记录功能包的基本信息,包含作者信息,许可信息,依赖选项.编译标志等

元功能包(Meta Packages)

*组织多个用于同一目的的功能包

ROS命令行工具的使用

启动ROS Master

roscore

启动小海龟仿真器

rosrun turtlesim turtlesim_node

启动海龟控制节点

rosrun turtlesim turtle_teleop_key

显示系统计算图

rqt_graph

显示系统节点相关信息

   rosnode
rosnode is a command-line tool for printing information about ROS Nodes.

Commands:
	rosnode ping	test connectivity to node
	rosnode list	list active nodes
	rosnode info	print information about node
	rosnode machine	list nodes running on a particular machine or list machines
	rosnode kill	kill a running node
	rosnode cleanup	purge registration information of unreachable nodes

显示系统话题相关信息

rostopic
rostopic is a command-line tool for printing information about ROS Topics.

Commands:
	rostopic bw	    display bandwidth used by topic
	rostopic delay	display delay of topic from timestamp in header
	rostopic echo	print messages to screen
	rostopic find	find topics by type
	rostopic hz	    display publishing rate of topic    
	rostopic info	print information about active topic
	rostopic list	list active topics
	rostopic pub	publish data to topic
	rostopic type	print topic or field type

显示系统消息相关信息

rosmsg
rosmsg is a command-line tool for displaying information about ROS Message types.

Commands:
	rosmsg show	    Show message description
	rosmsg info	    Alias for rosmsg show
	rosmsg list	    List all messages
	rosmsg md5	    Display message md5sum
	rosmsg package	List messages in a package
	rosmsg packages	List packages that contain messages

显示系统服务相关信息

rosservice 
Commands:
	rosservice args	print service arguments
	rosservice call	call the service with the provided args
	rosservice find	find services by service type
	rosservice info	print information about service
	rosservice list	list active services
	rosservice type	print service type
	rosservice uri	print service ROSRPC uri

数据记录.复现

rosbag
Usage: rosbag <subcommand> [options] [args]

A bag is a file format in ROS for storing ROS message data. The rosbag command can record, replay and manipulate bags.

Available subcommands:
   check  	    Determine whether a bag is playable in the current system, or if it can be migrated.
   compress  	Compress one or more bag files.
   decompress  	Decompress one or more bag files.
   decrypt  	Decrypt one or more bag files.
   encrypt  	Encrypt one or more bag files.
   filter  	    Filter the contents of the bag.
   fix  	    Repair the messages in a bag file so that it can be played in the current system.
   help  
   info  	    Summarize the contents of one or more bag files.
   play  	    Play back the contents of one or more bag files in a time-synchronized fashion.
   record  	    Record a bag file with the contents of specified topics.
   reindex  	Reindexes one or more bag files.

创作工作空间与功能包

工作空间(workspace)是一个存放工程开发相关文件的文件夹.
*src:代码空间(Source Space)
*build:编译空间(Build Space)
*devel:开发空间(Development Space)
*instll:安装空间(Install Space)

创建工作空间

mkdir catkin_ws
cd catkin_ws/
mkdir src
cd src/
catkin_init_workspace

编译工作空间

cd ..
catkin_make
catkin_make install

创建功能包

#语法
#catkin_create_pkg<package_name>[depend1][depend2][depend3]
cd src/
catkin_create_pkg test_pkg std_msgs rospy roscpp

编译功能包

cd ..
catkin_make

设置环境变量

source devel/setup.bash

检查环境变量

echo $ROS_PACKAGE_PATH

备注
同一个工作空间下,不允许存在同名功能包;
不同工作空间下,允许存在同名功能包.