ROS study notes (1): ROS terminology

XMLRPC

XMLRPC (XML Remote Procedure Call) is a kind of RPC protocol. Its encoding format adopts XML encoding format, and the transmission method adopts HTTP protocol. It supports multiple programming languages, but it is relatively simple and only used for small data types or commands.

Master node

The master node is responsible for the connection and communication between nodes. The master node can be started by running the roscore command, and then the names of other nodes can be registered, and communication between nodes can be established. The master node uses XMLRPC to communicate with other nodes, and usually does not maintain a connection, that is, other nodes only establish a connection with the master node when registering or requesting information. When ROS is started, the master node will obtain the URI address and port number listed in the ROS_MASTER_URI variable set by the user (the default is the current local IP and port number 11311).

node

A node refers to the smallest processing unit running in ROS, usually an executable program (written based on c++ or python language). While the node is running, it registers its name with the master node, and also registers the name of the publisher/subscriber or service server/client, as well as the message, URI address, and port number. Based on this information, each node can use topics or services to communicate with other nodes.
Nodes use XMLRPC to communicate with the master node, and use the XMLRPC or TCPROS of the TCP/IP communication series to communicate between nodes. The connection request and response between nodes use XMLRPC, and the message communication uses TCPROS (this has nothing to do with the master node, it is a direct communication between nodes). The URI address uses the value of the ROS_HOSTNAME environment variable, and the port number can be set to any inherent value.

rosrun 功能包名称 节点名称(可执行文件名)	#启动节点

Feature pack

A function package is the basic unit that constitutes ROS, which includes at least one node or a configuration file of a node that is used to run other function packages, as well as ROS dependent libraries, data sets, and configuration files used to run various processes. Usually created using the catkin_create_pkg command:

catkin_create_pkg 功能包名 依赖项(roscpp rospy std_msgs)

Meta Feature Pack

A meta function package is a collection of function packages with a common purpose.

news

Messages are variables of types such as int, float, and boolean. The nodes exchange data through messages, and their communication methods include TCPROS and UDPROS. A msg folder is usually created under the function package directory to store custom message files.

mkdir msg
vim msg/custommsg.msg
//custommsg.msg
float32 a
float32 b

topic

Topic is a one-way asynchronous communication mechanism, usually used to send messages continuously. After a publisher node registers with the master node on a topic, the subscriber node that wants to receive the topic can obtain the publisher node's information at the master node, and then establish a direct connection with the publisher node, and then you can use the Topic to communicate.

Publish and Publisher

Posting refers to sending data in the form of a message corresponding to the content of the topic. The publisher is the individual who declares in the node that he is the individual who executes the publication, and a single node can become the publisher who publishes multiple topics.

ros::Publisher pub;
ros::NodeHandle nh;
pub = nh.advertise<消息类型>("话题名称",缓冲区大小);
消息类型 消息;
pub.publish(消息);

Subscribers and subscribers

Subscription refers to receiving data in the form of messages corresponding to the topic content. Like the publisher, the subscriber can declare in the node that he is the individual who performs the subscription, and a single node can also become a subscriber who subscribes to multiple topics.

void callback(消息类型 消息){
    
    }
ros::Subscriber sub;
sub = nh.subscribe("话题名称",size,callback);
ros::spin();//循环监听

service

A service is a two-way synchronous communication mechanism, which is different from a topic. It only establishes a connection with the service server node when the service client node sends a data request. When the service client receives the response, it disconnects, that is, a one-time Sexual message communication. Usually, a srv folder is created in the directory of the function package to store customized service message files.

mkdir srv
vim srv/customsrv.srv
//customsrv.srv
float32 a	//请求(Request)
float32 b
---
float32 c	//响应(Response)

Service server

The service server is a node with a request as input and a response (both requests and responses are messages) as output. After the service server receives the request from the service client, it executes the specified service and sends the result as a response to the service client.

bool callback(服务消息类型::Request &请求,服务消息类型::Response &响应){
    
    }
ros::ServiceServer server = nh.advertiseService("服务名称",callback);
ros::spin();

Service client

A service client is a node that takes a request as an output and a response as an input.

ros::ServiceClient client = nh.serviceClient<服务消息类型>("服务名称");
服务消息类型 消息;
消息.request.变量名称 = value;//填充请求数据
client.call(消息);
cout << 消息.response.变量名称; //输出响应数据

action

Action is an asynchronous two-way communication mechanism, similar to service, except that it requires a long response after processing the request, and needs to have feedback data in the middle. An action file includes goals, results, and feedback, where goals and results correspond to requests and responses.

Action server

An action server is a node with a goal as input and results and feedback as output.

Action client

An action client is a node with a goal as an output and results and feedback as an input.

CMakeLists.txt

The catkin of the ROS build system basically uses CMake, so the CMakeLists.txt file in the function package directory is used to describe the build environment.

package.xml

A file written in XML encoding format, which includes information such as the function package name, author, license, and dependency package.

Guess you like

Origin blog.csdn.net/qq_42386127/article/details/98587964