In your roster application, you may want to launch the same node multiple times, but with a different
configuration.
For example, if you have a node that you've written for a temperature sensor and if you have five temperature
sensors, then you will want to launch the same node five times and of course with a different name
for each sensor.
Because what I just told you in the previous lesson is that you cannot have two nodes with the same
name.
Actually, let's try that first.
So I'm going to run my pi node executable from the Python package in this terminal.
And then I'm going to run it again in that terminal.
And let's see what happens.
So I run it here.
It works.
I run it here.
And it also works.
We don't have any error here.
But then let's do a ros2 node list.
And you see we have here a warning.
Be aware that there are nodes in the graph that share an exact name, which can have unintended side
effects.
Okay, so you might have weird errors if you have stuff like this.
Okay, so better to avoid it and how to solve that.
Well, very simply you can rename the node at runtime when you start it with Ros2 run.
Okay.
So that's what we're going to do.
So let's clear that first and how to rename a node.
Well let's go back to that command Ros2.
Run package name and executable name.
Then we can add arguments after this command with dash dash ros dash args.
Okay.
So every time we add arguments we're going to see later.
Also for parameters and other stuff you will first need to add ros args once only once after the ros
args.
Now let's do a renaming or also called a remapping.
So to do that you need to provide a dash R option.
And then to rename a node you need to do underscore underscore node like that colon equal.
And then the new name.
So for example let's name it a, b, c.
Okay, so if I press enter here, you see that the node is started.
But this time you see the name is ABC.
If I do a ros2 node list I have ABC and I can start, for example, the other one with no renaming.
And this time we have py test and ABC.
So we have no name conflicts okay.
And then I can do Ctrl c again here and let's come back to this.
So the dash R is actually the small variation for the dash dash remap okay.
So that's gonna also work okay.
So you can use dash dash remap or just dash R.
And here let's say that it's going to be a temperature sensor node okay.
Let's imagine you have written a temperature sensor node.
And let's say you want to name it temperature sensor one okay.
And you're going to run that one with.
So you're going to do this and then dash dash Ross AGS dash r underscore underscore node and temperature
sensor two.
Okay.
So you can run the two like that.
And you see now we have temperature sensor one and temperature sensor two.
So that's an example of what you can do if you have a sensor like that.
So as you can see renaming a node at runtime is quite useful because first while you don't have to change
anything in the code okay, the value we have written in the code.
So here it's by test.
This value is not completely hardcoded okay.
You can change it at runtime.
So it's quite dynamic and you don't need to reinstall or recompile any code.
And we're going to come back often to this Ross args and all the arguments we can add after here during
this course.
Because we can also rename more things.
We can rename communications.
So topics services etc. we can also add parameters.
So we're going to come back to this all along the course.