So in this lecture I will have two computers.
Both are using the Ubuntu operating system on it and have ROS two installed.
Basically, we're going to have one computer, run a publisher and see ways we can configure our network
so that the second computer can receive ROS communications from it.
Both computers are connected to the same router, in this case via ethernet cable.
You can also do this over wi fi if you want it as well.
So you can't see the modem since it's off camera, but it essentially looks like this.
So here I am on my main Linux machine, which I have been recording all the previous lectures on.
First thing I will do is confirm to you that the two devices I will be using are on the same network.
We can check this by either going into our network settings and viewing our connection details.
So in this case I'm connected via Ethernet, so if I head over to here.
You can see my IPV four address which my router assigned to my device.
Or alternatively, if you want it to do this in a terminal environment, you could open up a terminal
and run IP a.
And in this case, this is my Ethernet adapter, which shows my IPV four address we saw earlier.
The main thing to keep in mind is that we want to be on the same subnet, so we want to have the same
three sets of digits.
So 19216 8.50.
This would be different depending on your computer and router configuration.
So now go ahead and clear the screen and start a ROS node.
You can start one of the nodes we've made in section four, but for simplicity, I'll run the example
talker and listener nodes.
We ran back when we first installed Ros to Humble.
Okay, So we see that this node is running, it's going to start printing.
So let's head over to our second device to try and subscribe to the values being published.
All right, So here I am on my second device.
So first thing I'm going to do is verify that I'm on the same network subnet.
So again, you could open up your settings and here I am in my network and we see I'm on that same 19216
8.50 subnet.
And again, you could do the same exact thing in terminal with IP A and on this device I have lots of
virtual connectors, but here we're interested in my ethernet connection, which here we see is on the
19216850 subnet.
So I'll go ahead and clear this and let's try and subscribe to the messages coming in from that Hello
world node.
We started on the first computer, so I'm going to go ahead and run the corresponding listener node.
And here we get our hello messages printing, which are being published by the other computer.
And if I go ahead and show both computers on the screen right now, I can go ahead and stop the talker
node on the first computer and we stop receiving messages on the second one.
And of course, I could go ahead and restart the node.
And we see the corresponding messages printing again to the subscriber on this second computer.
Och great.
We have two devices on the same local network with ROS nodes able to communicate with each other.
So I will go ahead and stop these nodes from running and clear the screen.
Do the same thing on my second device.
Now, what happens if we had multiple robots which ran the same task and Ross nodes on the same network?
Well, we could implement different names for each similarly named topic and node.
Or we could instead create a separate domain for the ROS nodes to communicate across on the same network.
We can do this by setting a domain ID in each set of environments.
We want to communicate with each other.
You can find out more information about domain IDs on the ROS Docs page, but we will jump straight
into implementing it on these two computers.
All we need to do is export a Ross domain ID environment variable.
This will generally be within the values of one and 101.
So for example, I can set the ROS domain ID of my first computer to a value of one while I set the
domain ID on the second computer to two.
Now let's try rerunning our ROS nodes on each computer.
So this time we see nothing happens on our listener side, even though the networks and nodes remain
unchanged.
So if I were to go ahead and stop the listener node on the second computer and I'll go ahead and instead
export the domain ID to match my first computer, which was one, and rerun the listener node.
Now I'm getting those Hello world messages that are being published by the first computer.
So I'll go ahead and stop these nodes and clear the screen.
You can also use this feature on the same computer.
So on my first computer, I can go ahead and open up a second terminal.
And if I set the domain ID to something that does not match, for example, three.
Just remind you, this first terminal has a domain ID of one, so I can actually echo that.
So there we go.
We see we have a domain ID value of one.
And so here we have a cross domain value of three.
So we're on the same exact computer.
But if I go ahead and run that publisher and now I run the listener on this terminal.
We can see no messages are received unless I were to change the domain ID to match.
And now we get our Hello world messages.
So again, this can work on the same local host instance as well as across your local network on your
router.
So with that you can see how you can interact with other computers running ROS on a local network connection
and how you can set up ROS domain IDs to have better control over which ROS nodes are able to communicate
with each other on the same network.