In this lesson, we will experiment with turtle SIM so you can practice more with parameters and discover
more command line tools for ros2 params.
It's also a good opportunity to see how you can interact with parameters from existing nodes, where
you don't have access to the code.
So let's start turtle sim here.
Ros to run turtle sim and turtle sim node.
I just need that one.
We want run the Teleop turtle just that one.
And then in that terminal I'm going to run Ros two param list.
So we've already seen that command is going to list all of the parameters for actually all of the nodes.
So you can see we have the turtle SIM node here.
If I do Ros two node list you see we have turtle sim.
So for each node you will get the name of the node and then a colon.
And then you have all the parameters.
So you might see some that we've already seen before.
For example use SIM time start type description service.
Those parameters will exist for all the nodes that you start.
And then we also have this shows Cuz of the rights that we have seen in the C plus plus node.
So basically those parameters.
Well, we exist for almost every node and we can just ignore them for now.
And we can see that in the application in the code itself we have those four parameters okay.
Background.
B background.
G background.
Uh so that's going to be basically to set the background color with a red, green and blue.
And also that one now well once we have all those parameters how can you get the value for one parameter.
Well you have the Ros2 param get.
And you need to provide two things.
First the name of the node.
So the name of the node is slash turtle sim.
And you can use the autocompletion of course.
And then you need to provide the name of the parameter.
So let's say I want that one.
So ros2 get name of the node, the complete name including the slash here, and the name of the parameter.
And you can see we have first the type.
It's an integer value is and you can see it's 86.
Let's do the same thing with the B.
And so the blue and the red.
So you can see we have a red green.
So we have an RGB value for the screen for the background of the screen.
And it seems that it's a number between 0 and 255.
And with this you can see the default values for the parameters.
So actually it means you can modify the value.
You can modify the background color when you start talking.
And by default if you don't provide any parameter, well those values are going to be used because it's
probably what has been declared as default values in the code.
Now let's stop this.
Let's run again.
Let's do ros args, then dash p and let's provide one parameter value.
For example, let's set the background value to zero.
So background underscore b is equal to zero.
If I do this it means that I'm only going to change that parameter here.
And the rest.
So the two other ones will stay at their default values.
I could change all three if I wanted to.
And you can see now the color is completely different.
Well, because I have removed the blue part.
Now if I do so the r you see is still the same.
And then the green is still the same.
And the blue now is zero.
You can see it was 255.
But then I provided a value.
So now it's zero.
And then what.
You can also add another dash.
Be back ground.
Let's say r.
Let's put this one to I don't know 200.
And you can see we have yet another color.
So you can basically choose any color you want with any combination of red, green and blue.
And you can see that's very useful because first of all we didn't need to compile any code again.
And secondly, we actually didn't even need to check the code.
We don't know what's the code of turtles.
We just know they have parameters.
And with those two param lists we can see the list.
We can then get their values.
And we can basically know what we need to provide so that we can start the same node, but with a different
configuration.
Now there is one more thing I'm going to come back to if I do Ros2 service list.
If I list the services.
So those are all the services from the same node.
Okay.
This is just one node.
And you can see that we have all those services, most of them actually using you see parameter stuff.
So I told you that those are services to interact with the parameter functionality.
And now that we are there let's actually see what it is.
So you have a service for example list parameters.
Let's do Ros2 service type to see what is the type of this parameter.
The type is what RCL interfaces service list parameter.
So that's yet a new package that we haven't used yet.
We can do Ros2 interface show with that one and what you see quite a lot of stuff, but basically what
you can just provide an empty request and it's going to return the name.
So the list of all parameters.
So if I do Ros2 service call, the name was turtle sim slash list parameters.
If I forgot to type I just press tab twice I see RCL, so I type RCL okay.
And then I'm just going to omit the request here.
And you see we have a request and the response you see list parameters and we see the background B background
g background R okay.
So you can also use those services.
And that's going to do the same thing as Ros2 param list in this case.
Now you might think why do you want to use those services.
It's much easier with the command line.
Well that's true if you are using the terminal.
But let's say you want to interact within a node with the parameters of another node.
Then you can use the service so you know what's the name of the service.
You know, what's the interface you have seen previously how to create a service client.
So then if you ever want to interact with the parameters of a node from another node, you could do
that using those services here.
So Ros2 service list.
You see we have services for each node so you can interact programmatically with the parameters.
So I just mentioned this here quite quickly.
You will actually not really need to use that that often okay.
I basically almost never use it.
So I would say it's not the most important thing to focus at the beginning, but it's good to know that
you can do that.
All right.
So that's going to be it for the tutorial and parameters I encourage you to practice a bit more okay.
To run the node with different parameters, try different values.
Maybe try to call some of the service here to get, maybe get some parameters and then see the values
for all those parameters here.
Well, you can experiment a bit more on your own.