当前位置:网站首页>Ros- learn basic knowledge of 0 ROS - nodes, running ROS nodes, topics, services, etc

Ros- learn basic knowledge of 0 ROS - nodes, running ROS nodes, topics, services, etc

2022-07-05 08:45:00 m0_ forty-six million ninety-three thousand eight hundred and t

One 、 node

1.1 rosmaster

ros The system is composed of various nodes , Each node is equivalent to a subroutine , In addition to performing their respective duties, each node should also cooperate with each other , They communicate by delivering topic messages or providing services . Then each node is not human , They don't cook themselves , So we need an intermediary to help them contact . This intermediary is rosmaster. Every ros The system must have rosmaster, And there has to be only one rosmaster. Every ros The node needs to be started before it works rosmaster.

That's important rosmaster How does it work ? adopt roscore Instructions .

roscore

  function roscore The following page is displayed after the command :

function roscore It will start automatically after the command :rosmaster,Parameter Server,rosout. See :

roscore - ROS Wiki.

We can also pass rosnode list Command to see Currently active The node of

 1.2 function ros node

Run one ros Nodes have 2 Ways of planting :

1. rosrun ~

2.roslaunch ~

Among them rosrun You need to run manually before the command roscore Command to start rosmaster, But run roslaunch Don't use before instructions , because roslaunch Instructions can be automatically detected when running rosmaster Is it activated , If not, it will run automatically roscore.

For example, I take starting the little turtle as an example

When I started the little turtle node, I was using rosnode list View the currently active nodes :

  Two 、 package package

A package can contain multiple nodes ,ros When the application is published , Usually, the unit is package , In our little turtle example , Package is turtlesim, How many nodes are there in this package , You can check through the following instructions :

rosrun turtlesim, Then press... Twice Tab key , Pictured :

Each node may be a publisher node , Subscriber node , Client node 、 Server node . These nodes with names will be introduced one by one below .

  3、 ... and 、 topic of conversation topic

The topic and node are ros There are two basic components in the system , Nodes are basic processing units , Topic is one of the basic communication units between nodes . Among them, the nodes about publishing topics have special names called publisher nodes and subscriber nodes , How to program and define a publisher node in your own function package 、 The subscriber node is detailed in the learning notes below . It should be noted that the topic is the pipeline of data transmitted by the publisher node and the subscriber node , The data that is actually transmitted is called a message , among ros The system provides us with some common messages , We can also customize messages . We can go through rosmsg To see what we can do about the message .

 

  Then back to the topic :

  There are many operations for topics in a function package , You can enter rostipic Then press enter to check the specific operations .

About how to create a publisher node 、 Subscriber nodes and customized messages are detailed in the following : 

ROS Study 2- Programming implementation of publisher node _m0_46093829 The blog of -CSDN Blog

ROS Study 3 subscriber Subscriber Programming of nodes _m0_46093829 The blog of -CSDN Blog

ROS Study 3 Custom message _m0_46093829 The blog of -CSDN Blog

It can be done by rostopic list View the current ros Active topics in the system , When I launched the little turtle Feature Pack draw_square After node , The active topics in my current system are as follows :

  Four 、 service

service Service It is a way of synchronous communication between nodes ; Among them, there are also special names for the server and the served node, which are called the server node and the client node , client Client Nodes can issue requests Request; By the server Server Feedback response after node processing Response.

Services provided by the server node to the client node , that ros The system also defines some common services for us , We can also define service types by ourselves . That's about the type of service , We can go through rossrv To view the functions of relevant instructions .

When I started turtlesim Function pack , And run draw_square After node , We can go through rosservice list Check it out. Active services in the current system .

The active services in my current system are as follows :

  There are many operations for services in a function package , You can enter rosservice Then press enter to check the specific operations .

Be careful : Be careful to distinguish rosservice and rossrv. The former is used with Currently, services provided by some nodes interact . The latter name comes from the extension used to declare the service data type file .srv, It is used to view service data types , Whether or not there is such a type of service available .

No matter the topic or the service , You can call it alone

  Then I don't know if there will be any friends who have questions and say yes rosservice list I can only know that there is this service , How can I know exactly how to use it ?

Can pass rosservice call Service name Then press 2 Time tab, The system will automatically show you what parameters this service needs , Just use it according to the situation , For example, I want to use /kill This service , But I don't know how to use it, so I just tab 了 2 Next . Then see the display name:' ', So I input my kill The name of the tortoise , And then OK 了 .

How to program and define a publisher node in your own function package 、 The subscriber node is detailed in the learning notes below .

ROS Study 4- Client Programming of nodes _m0_46093829 The blog of -CSDN Blog

ROS Study 5 -Service Programming of nodes _m0_46093829 The blog of -CSDN Blog

原网站

版权声明
本文为[m0_ forty-six million ninety-three thousand eight hundred and t]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202140540130601.html