WEBVTT

00:00.080 --> 00:05.390
Let's come back to the turtle sim package and experiment a little bit more with services.

00:05.390 --> 00:13.670
So let's run the turtle SIM node first rose to run turtle sim and turtle sim node.

00:14.480 --> 00:18.440
All right I'm going to put it here on the side.

00:18.440 --> 00:23.090
And here let's also run the Teleop turtle node.

00:23.090 --> 00:26.510
So Ros to run turtle SIM.

00:26.510 --> 00:29.210
And it was turtle.

00:30.410 --> 00:31.010
Turtle key.

00:31.040 --> 00:34.010
That's the executable name okay.

00:34.010 --> 00:36.140
Let's make the turtle move a bit.

00:36.920 --> 00:37.790
All right.

00:37.850 --> 00:38.870
That's it.

00:39.380 --> 00:43.970
Now here on this terminal let's see what services we have.

00:43.970 --> 00:48.080
So let's do directly Ros2 service list.

00:49.100 --> 00:51.620
And you can see we have a bunch of services.

00:51.620 --> 00:54.620
So we can find first you see Top Turtle.

00:54.620 --> 01:01.360
We can find those seven services that are linked to most of the parameters for that node.

01:01.450 --> 01:06.400
Then we have the total SIM with those seven parameters for that node.

01:06.400 --> 01:12.520
And so if we remove those you see that we have four services here.

01:12.520 --> 01:14.890
And then we have three more here.

01:14.890 --> 01:18.760
So we have seven services specific to this application.

01:18.790 --> 01:19.060
All right.

01:19.060 --> 01:20.200
So it's already quite a lot.

01:20.230 --> 01:22.030
Now let's try to use one.

01:22.030 --> 01:23.950
Let's try to use the first one here.

01:23.950 --> 01:24.550
Clear.

01:24.550 --> 01:26.290
What is this service.

01:26.290 --> 01:31.090
This service is going to clear the trace that the turtle leaves here.

01:31.090 --> 01:34.750
So let's do ros2 service.

01:34.780 --> 01:35.740
What can we do.

01:35.770 --> 01:40.930
We already have the name we can do type slash clear okay.

01:40.960 --> 01:42.580
We can use the auto completion.

01:42.760 --> 01:47.890
And you see that we have an interface STD service.

01:47.890 --> 01:49.660
So that's standard services.

01:49.660 --> 01:52.270
And then slash SRV and empty.

01:52.360 --> 01:54.880
What do we have inside this interface.

01:54.880 --> 01:58.660
So we can do Ros2 interface show.

01:58.660 --> 02:05.050
And and you can see it's empty as its name suggests, it's empty.

02:05.050 --> 02:06.910
So so we don't have any request.

02:06.940 --> 02:10.120
Actually, it's not that we don't have any request and response.

02:10.120 --> 02:16.540
We have a request and we have a response, but they just contain nothing, which is perfectly valid.

02:16.540 --> 02:18.250
And you see we have three dashes.

02:18.250 --> 02:23.980
So that is the actual minimum thing you can do to write an interface with three dashes.

02:23.980 --> 02:28.000
Here you just say that the request is empty and the response is empty.

02:28.000 --> 02:32.830
So you can just call the service and you don't need to provide anything for the request.

02:32.830 --> 02:33.940
So let's try that.

02:33.940 --> 02:38.920
Let's do a Ros2 service call with slash clear.

02:39.430 --> 02:43.060
And then I should put just the S here and press tab.

02:43.450 --> 02:44.440
It should find it.

02:44.440 --> 02:51.080
And well we could put double quotes and an empty request like that.

02:51.110 --> 02:53.540
You could even omit it if you want.

02:53.570 --> 02:54.980
Let's press enter.

02:55.820 --> 02:57.020
And you see it's working.

02:57.020 --> 02:58.490
So what happened?

02:58.520 --> 03:00.020
You see, we have a log here.

03:00.020 --> 03:01.430
Clearing turtle sim.

03:01.430 --> 03:04.700
So there is a service server here that printed something.

03:04.880 --> 03:10.040
We make the request, we receive the response and the trace here is gone.

03:10.070 --> 03:12.890
Okay let's focus on this window again.

03:12.890 --> 03:14.720
Let's make the turtle move.

03:14.900 --> 03:16.820
You see we have a new trace.

03:16.910 --> 03:20.840
And if I call the service again here, it's gone.

03:20.870 --> 03:23.150
Okay, so this one is quite easy to use.

03:23.150 --> 03:27.200
And as you can see, as I told you, for service names you will use verbs.

03:27.200 --> 03:27.590
You see.

03:27.620 --> 03:28.160
Clear.

03:28.190 --> 03:28.670
Kill.

03:28.670 --> 03:29.120
Reset.

03:29.150 --> 03:29.900
Spawn.

03:29.930 --> 03:30.770
Set.

03:30.800 --> 03:31.610
Teleport.

03:31.640 --> 03:33.200
Those are verbs.

03:33.230 --> 03:34.730
Now let's see what.

03:34.730 --> 03:38.030
We don't need this node anymore.

03:38.030 --> 03:39.470
Let's try to use another one.

03:39.470 --> 03:43.070
So spawn is going to spawn a new turtle on the screen.

03:43.070 --> 03:45.320
So how can we use that one?

03:45.400 --> 03:50.560
rank two service type with spawn.

03:52.360 --> 03:52.870
Okay.

03:52.900 --> 03:55.570
And that's another interface.

03:55.570 --> 04:00.430
So you can see here we were using the package standard services.

04:00.520 --> 04:08.290
This one is from the package total SIM plus two interface show with spawn.

04:09.370 --> 04:11.860
And that one contains a bit more stuff.

04:11.860 --> 04:13.420
So you see we have the three dashes.

04:13.420 --> 04:17.200
So the request is here we have x, y and theta.

04:17.200 --> 04:19.960
So those are the coordinates for the turtle.

04:19.960 --> 04:22.720
So x is going to be here y is going to be here.

04:22.720 --> 04:25.180
And theta is the orientation of the turtle.

04:25.180 --> 04:27.220
And then we can provide a name if we want.

04:27.250 --> 04:28.480
That's optional.

04:28.480 --> 04:33.310
If you don't provide one a unique name you can see a unique name will be created.

04:33.310 --> 04:35.470
And then as the response you get the name.

04:35.470 --> 04:40.480
So either you've provided the name and you probably get the same one, or you're going to get the name

04:40.480 --> 04:42.620
that was generated for the turtle.

04:42.650 --> 04:47.900
Okay, so you see, we can guess a lot of stuff already using the command line tool with just a running

04:47.900 --> 04:48.230
node.

04:48.230 --> 04:50.120
And we don't have to check the code.

04:50.120 --> 04:56.300
So let's try to use this service Ros2 service call with spawn.

04:56.330 --> 04:58.550
And then we provide the interface.

04:58.550 --> 05:02.060
So from the package total sim let's put T and then tab.

05:02.060 --> 05:05.630
And then let's construct the request.

05:05.630 --> 05:09.470
So zero and zero starts at this point.

05:09.470 --> 05:13.190
If we put five and five it's going to be around the middle.

05:13.190 --> 05:17.990
So let's do x and then space 5.0 okay.

05:18.020 --> 05:20.600
That's a float number y.

05:20.630 --> 05:22.640
Let's put 5.0.

05:22.820 --> 05:26.210
And then well I don't want to provide theta okay.

05:26.240 --> 05:31.130
So theta is going to be zero I don't need to provide it I don't need to provide a name okay.

05:31.160 --> 05:32.330
I could leave it like that.

05:32.330 --> 05:34.520
But I'm going to choose the name.

05:34.520 --> 05:38.310
And let's use single quotes here because we are inside double quotes.

05:38.340 --> 05:40.710
Let's call it my turtle.

05:40.740 --> 05:42.810
Otherwise I think it's going to create.

05:42.930 --> 05:44.340
So this one is turtle one.

05:44.370 --> 05:46.680
And then it's going to create turtle two, etc..

05:46.710 --> 05:48.270
Let's press enter here.

05:48.870 --> 05:55.290
And you see we have a new turtle that was spawned as coordinate five, five and zero means that it's

05:55.290 --> 05:57.810
just facing forward for the orientation.

05:57.810 --> 06:00.000
And as a response we get my turtle.

06:00.000 --> 06:02.160
And you see we have spawning turtle here.

06:02.160 --> 06:07.140
And finally we can use kill to remove that turtle.

06:07.140 --> 06:15.570
So let's see Ross two service type with kill.

06:16.320 --> 06:21.690
And we have the interface Ross two interface show.

06:21.750 --> 06:24.330
So you see it's always the same thing.

06:24.330 --> 06:28.320
So I encourage you to practice and use all the services you see here.

06:28.320 --> 06:28.830
We have.

06:28.830 --> 06:30.390
So this one is a bit easier.

06:30.390 --> 06:34.110
We just provide the name of the turtle and it's going to return nothing.

06:34.120 --> 06:36.250
so rushed to service.

06:36.250 --> 06:38.890
Call with kill.

06:39.190 --> 06:48.130
And then I put t, I press tab and then I put the request inside quotes and curly brackets name.

06:48.520 --> 06:51.100
And well we're going to use the same name.

06:51.100 --> 06:53.620
That's going to be my turtle okay.

06:53.620 --> 06:56.320
So my turtle.

06:56.470 --> 06:59.920
And let's see what we have okay.

06:59.950 --> 07:01.150
And the turtle is gone.

07:01.150 --> 07:03.850
We can do the same for the turtle one okay.

07:03.880 --> 07:05.380
That one is named turtle one.

07:05.380 --> 07:08.020
You can see here on the on the services.

07:08.020 --> 07:10.150
So I can do turtle.

07:12.520 --> 07:16.600
Turtle one and turtle one is gone as well.

07:16.630 --> 07:17.020
Great.

07:17.020 --> 07:22.000
So as you can see here, turtle SIM is great to practice with notes and all topics and services.

07:22.000 --> 07:26.350
If you want at this point to practice more, you can write some code to interact with the topics and

07:26.350 --> 07:27.130
services.

07:27.130 --> 07:31.240
In fact, that's what we will do in the final project of this course.
