Hello now we will learn about ros service 2
ros service is another form of communications unlike the ros topic it does not 3
sends a stream of the data in this service do not communicate via requests and the responce 4
and here you can see the nice illustration where we have a service client it sends a message to 5
the service server and then it responses back that will be received by the service client and 6
here tow nodes are communicating and it can be multiple Node and here you can see there are 7
multiple nodes they are communicating our one service open up the terminal 8
okay we will run our ros2 run turtlesim 9
Turtlesim node now we will see what are the services are available ros2 service list 10
just like we have seen in ros2 topic list ros2 node list 11
now we are seeing ros service list so here are a bunch of services that we can 12
utilize we have to find out the type ros2 service type clear hit enter 13
and here we have the service type of clear service if you want to see the type of all 14
the services in the list what we will do type ros2 service list -t it will display the 15
type of all these Services okay if we want to find out all the services with the same type 16
okay we can also do that ros2 service find and then the type of the service 17
yes here we can see there are two services that have similar type just like we saw 18
the interface in ros topic it can also show the interface in ros service ros2 interface 19
show and this service type which was this is the service type 20
and dot SRV indicating the service it does not have any type of request and 21
responce and spawn service has this type I will just copy and 22
paste it here dot SRV so here we can see it has a lot of things in it the things that will see 23
here are the request they are separated by these three dashes and here we have response 24
if we want to spawn our turtlesim in a window we will have to input the X Y and the Theta of 25
the robot in the turtlesim window and we also have to mention the name of the turtle and 26
in the return it will just give us the name the next terminal and we will launch uh the teleop 27
yes here we can try the robot around and now we will see how the clear service Works 28
ros service this minus t and we will see the type of this and we have to is utilize this 29
ros2 service call and we are going to call this service which is declared clear and the 30
type of the service which is STD slash SRV slash empty we will just call 31
and it has erased the path that turtlesim drawn now I would like to utilize the spawn service which is 32
here and this is the type of this service we will again see the interface ros2 interface show 33
the type of the service SRV 34
and it has displayed all the constant values that 35
it takes and we will have to input ros2 service call spawn and the service type 36
and then again the same Convention as we published the topic in the previous lecture and we will 37
type bracket X how do we know we have to input the X here it's mentioned uh X colon space 2.5 38
comma 39
y colon 3.4 comma parameter that we have to mention Theta colon 1 comma name colon inverted 40
commas and we can mention here like turtle underscore 2. and we will just close the bracket 41
fail to populate the field spawn request object has no attribute here I think the this face is 42
missing here yeah so I will just give it a space here and also there is a space in the name 43
yeah now it is called here I can move it here if I want to move uh the other Turtle I will 44
have to remap the ros topic of turtle one slash cmd_vel as we have done in the previous lecture 45
there is also a method to call this service as we have went through the rqt 46
here we have the service caller we can see the spawn service 47
and we have this Turtle here if we mention like 48
there is another turtle so you can bring as many Turtle as you want so that was 49
all about the service so if you have learned how to find out the type of a service how to 50
find the services that have the same type and 51
how to show the interface of a service and how to call it