Let's come back to the turtle sim package and experiment a little bit more with services.
So let's run the turtle SIM node first rose to run turtle sim and turtle sim node.
All right I'm going to put it here on the side.
And here let's also run the Teleop turtle node.
So Ros to run turtle SIM.
And it was turtle.
Turtle key.
That's the executable name okay.
Let's make the turtle move a bit.
All right.
That's it.
Now here on this terminal let's see what services we have.
So let's do directly Ros2 service list.
And you can see we have a bunch of services.
So we can find first you see Top Turtle.
We can find those seven services that are linked to most of the parameters for that node.
Then we have the total SIM with those seven parameters for that node.
And so if we remove those you see that we have four services here.
And then we have three more here.
So we have seven services specific to this application.
All right.
So it's already quite a lot.
Now let's try to use one.
Let's try to use the first one here.
Clear.
What is this service.
This service is going to clear the trace that the turtle leaves here.
So let's do ros2 service.
What can we do.
We already have the name we can do type slash clear okay.
We can use the auto completion.
And you see that we have an interface STD service.
So that's standard services.
And then slash SRV and empty.
What do we have inside this interface.
So we can do Ros2 interface show.
And and you can see it's empty as its name suggests, it's empty.
So so we don't have any request.
Actually, it's not that we don't have any request and response.
We have a request and we have a response, but they just contain nothing, which is perfectly valid.
And you see we have three dashes.
So that is the actual minimum thing you can do to write an interface with three dashes.
Here you just say that the request is empty and the response is empty.
So you can just call the service and you don't need to provide anything for the request.
So let's try that.
Let's do a Ros2 service call with slash clear.
And then I should put just the S here and press tab.
It should find it.
And well we could put double quotes and an empty request like that.
You could even omit it if you want.
Let's press enter.
And you see it's working.
So what happened?
You see, we have a log here.
Clearing turtle sim.
So there is a service server here that printed something.
We make the request, we receive the response and the trace here is gone.
Okay let's focus on this window again.
Let's make the turtle move.
You see we have a new trace.
And if I call the service again here, it's gone.
Okay, so this one is quite easy to use.
And as you can see, as I told you, for service names you will use verbs.
You see.
Clear.
Kill.
Reset.
Spawn.
Set.
Teleport.
Those are verbs.
Now let's see what.
We don't need this node anymore.
Let's try to use another one.
So spawn is going to spawn a new turtle on the screen.
So how can we use that one?
rank two service type with spawn.
Okay.
And that's another interface.
So you can see here we were using the package standard services.
This one is from the package total SIM plus two interface show with spawn.
And that one contains a bit more stuff.
So you see we have the three dashes.
So the request is here we have x, y and theta.
So those are the coordinates for the turtle.
So x is going to be here y is going to be here.
And theta is the orientation of the turtle.
And then we can provide a name if we want.
That's optional.
If you don't provide one a unique name you can see a unique name will be created.
And then as the response you get the name.
So either you've provided the name and you probably get the same one, or you're going to get the name
that was generated for the turtle.
Okay, so you see, we can guess a lot of stuff already using the command line tool with just a running
node.
And we don't have to check the code.
So let's try to use this service Ros2 service call with spawn.
And then we provide the interface.
So from the package total sim let's put T and then tab.
And then let's construct the request.
So zero and zero starts at this point.
If we put five and five it's going to be around the middle.
So let's do x and then space 5.0 okay.
That's a float number y.
Let's put 5.0.
And then well I don't want to provide theta okay.
So theta is going to be zero I don't need to provide it I don't need to provide a name okay.
I could leave it like that.
But I'm going to choose the name.
And let's use single quotes here because we are inside double quotes.
Let's call it my turtle.
Otherwise I think it's going to create.
So this one is turtle one.
And then it's going to create turtle two, etc..
Let's press enter here.
And you see we have a new turtle that was spawned as coordinate five, five and zero means that it's
just facing forward for the orientation.
And as a response we get my turtle.
And you see we have spawning turtle here.
And finally we can use kill to remove that turtle.
So let's see Ross two service type with kill.
And we have the interface Ross two interface show.
So you see it's always the same thing.
So I encourage you to practice and use all the services you see here.
We have.
So this one is a bit easier.
We just provide the name of the turtle and it's going to return nothing.
so rushed to service.
Call with kill.
And then I put t, I press tab and then I put the request inside quotes and curly brackets name.
And well we're going to use the same name.
That's going to be my turtle okay.
So my turtle.
And let's see what we have okay.
And the turtle is gone.
We can do the same for the turtle one okay.
That one is named turtle one.
You can see here on the on the services.
So I can do turtle.
Turtle one and turtle one is gone as well.
Great.
So as you can see here, turtle SIM is great to practice with notes and all topics and services.
If you want at this point to practice more, you can write some code to interact with the topics and
services.
In fact, that's what we will do in the final project of this course.