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