1
00:00:00,830 --> 00:00:03,350
So in this lecture I will have two computers.

2
00:00:03,350 --> 00:00:07,340
Both are using the Ubuntu operating system on it and have ROS two installed.

3
00:00:07,610 --> 00:00:12,710
Basically, we're going to have one computer, run a publisher and see ways we can configure our network

4
00:00:12,710 --> 00:00:17,510
so that the second computer can receive ROS communications from it.

5
00:00:18,020 --> 00:00:23,600
Both computers are connected to the same router, in this case via ethernet cable.

6
00:00:24,200 --> 00:00:26,990
You can also do this over wi fi if you want it as well.

7
00:00:27,470 --> 00:00:31,850
So you can't see the modem since it's off camera, but it essentially looks like this.

8
00:00:34,750 --> 00:00:39,680
So here I am on my main Linux machine, which I have been recording all the previous lectures on.

9
00:00:39,700 --> 00:00:45,290
First thing I will do is confirm to you that the two devices I will be using are on the same network.

10
00:00:45,310 --> 00:00:50,860
We can check this by either going into our network settings and viewing our connection details.

11
00:00:50,860 --> 00:00:54,280
So in this case I'm connected via Ethernet, so if I head over to here.

12
00:00:55,100 --> 00:00:59,330
You can see my IPV four address which my router assigned to my device.

13
00:00:59,510 --> 00:01:04,130
Or alternatively, if you want it to do this in a terminal environment, you could open up a terminal

14
00:01:04,310 --> 00:01:06,620
and run IP a.

15
00:01:07,510 --> 00:01:14,680
And in this case, this is my Ethernet adapter, which shows my IPV four address we saw earlier.

16
00:01:14,710 --> 00:01:19,120
The main thing to keep in mind is that we want to be on the same subnet, so we want to have the same

17
00:01:19,120 --> 00:01:20,300
three sets of digits.

18
00:01:20,300 --> 00:01:22,500
So 19216 8.50.

19
00:01:22,510 --> 00:01:26,710
This would be different depending on your computer and router configuration.

20
00:01:26,800 --> 00:01:31,320
So now go ahead and clear the screen and start a ROS node.

21
00:01:31,330 --> 00:01:35,860
You can start one of the nodes we've made in section four, but for simplicity, I'll run the example

22
00:01:35,860 --> 00:01:37,510
talker and listener nodes.

23
00:01:37,510 --> 00:01:40,570
We ran back when we first installed Ros to Humble.

24
00:01:42,980 --> 00:01:45,320
Okay, So we see that this node is running, it's going to start printing.

25
00:01:45,320 --> 00:01:50,450
So let's head over to our second device to try and subscribe to the values being published.

26
00:01:51,470 --> 00:01:52,970
All right, So here I am on my second device.

27
00:01:52,970 --> 00:01:56,390
So first thing I'm going to do is verify that I'm on the same network subnet.

28
00:01:56,390 --> 00:02:02,030
So again, you could open up your settings and here I am in my network and we see I'm on that same 19216

29
00:02:02,030 --> 00:02:04,310
8.50 subnet.

30
00:02:04,310 --> 00:02:09,950
And again, you could do the same exact thing in terminal with IP A and on this device I have lots of

31
00:02:09,950 --> 00:02:15,800
virtual connectors, but here we're interested in my ethernet connection, which here we see is on the

32
00:02:15,800 --> 00:02:18,140
19216850 subnet.

33
00:02:18,470 --> 00:02:23,990
So I'll go ahead and clear this and let's try and subscribe to the messages coming in from that Hello

34
00:02:23,990 --> 00:02:24,500
world node.

35
00:02:24,500 --> 00:02:29,780
We started on the first computer, so I'm going to go ahead and run the corresponding listener node.

36
00:02:33,820 --> 00:02:39,060
And here we get our hello messages printing, which are being published by the other computer.

37
00:02:39,070 --> 00:02:44,890
And if I go ahead and show both computers on the screen right now, I can go ahead and stop the talker

38
00:02:44,890 --> 00:02:49,570
node on the first computer and we stop receiving messages on the second one.

39
00:02:49,570 --> 00:02:52,210
And of course, I could go ahead and restart the node.

40
00:02:53,600 --> 00:02:58,490
And we see the corresponding messages printing again to the subscriber on this second computer.

41
00:02:59,030 --> 00:02:59,660
Och great.

42
00:02:59,660 --> 00:03:04,590
We have two devices on the same local network with ROS nodes able to communicate with each other.

43
00:03:04,610 --> 00:03:09,350
So I will go ahead and stop these nodes from running and clear the screen.

44
00:03:10,230 --> 00:03:11,900
Do the same thing on my second device.

45
00:03:15,860 --> 00:03:22,460
Now, what happens if we had multiple robots which ran the same task and Ross nodes on the same network?

46
00:03:22,550 --> 00:03:27,890
Well, we could implement different names for each similarly named topic and node.

47
00:03:28,130 --> 00:03:34,340
Or we could instead create a separate domain for the ROS nodes to communicate across on the same network.

48
00:03:34,370 --> 00:03:38,390
We can do this by setting a domain ID in each set of environments.

49
00:03:38,390 --> 00:03:40,280
We want to communicate with each other.

50
00:03:40,880 --> 00:03:46,190
You can find out more information about domain IDs on the ROS Docs page, but we will jump straight

51
00:03:46,190 --> 00:03:48,470
into implementing it on these two computers.

52
00:03:50,120 --> 00:03:54,030
All we need to do is export a Ross domain ID environment variable.

53
00:03:54,050 --> 00:03:57,770
This will generally be within the values of one and 101.

54
00:03:57,770 --> 00:04:05,210
So for example, I can set the ROS domain ID of my first computer to a value of one while I set the

55
00:04:05,210 --> 00:04:07,970
domain ID on the second computer to two.

56
00:04:11,580 --> 00:04:14,820
Now let's try rerunning our ROS nodes on each computer.

57
00:04:22,780 --> 00:04:27,910
So this time we see nothing happens on our listener side, even though the networks and nodes remain

58
00:04:27,910 --> 00:04:28,840
unchanged.

59
00:04:29,260 --> 00:04:35,920
So if I were to go ahead and stop the listener node on the second computer and I'll go ahead and instead

60
00:04:35,920 --> 00:04:41,770
export the domain ID to match my first computer, which was one, and rerun the listener node.

61
00:04:42,550 --> 00:04:47,260
Now I'm getting those Hello world messages that are being published by the first computer.

62
00:04:50,460 --> 00:04:53,850
So I'll go ahead and stop these nodes and clear the screen.

63
00:04:57,840 --> 00:05:01,260
You can also use this feature on the same computer.

64
00:05:01,260 --> 00:05:05,160
So on my first computer, I can go ahead and open up a second terminal.

65
00:05:05,490 --> 00:05:09,360
And if I set the domain ID to something that does not match, for example, three.

66
00:05:12,180 --> 00:05:16,290
Just remind you, this first terminal has a domain ID of one, so I can actually echo that.

67
00:05:22,880 --> 00:05:23,370
So there we go.

68
00:05:23,390 --> 00:05:25,970
We see we have a domain ID value of one.

69
00:05:25,970 --> 00:05:29,810
And so here we have a cross domain value of three.

70
00:05:31,490 --> 00:05:33,140
So we're on the same exact computer.

71
00:05:33,140 --> 00:05:39,080
But if I go ahead and run that publisher and now I run the listener on this terminal.

72
00:05:45,030 --> 00:05:50,070
We can see no messages are received unless I were to change the domain ID to match.

73
00:05:54,090 --> 00:05:55,650
And now we get our Hello world messages.

74
00:05:55,650 --> 00:06:02,820
So again, this can work on the same local host instance as well as across your local network on your

75
00:06:02,820 --> 00:06:03,450
router.

76
00:06:05,380 --> 00:06:11,740
So with that you can see how you can interact with other computers running ROS on a local network connection

77
00:06:11,740 --> 00:06:18,400
and how you can set up ROS domain IDs to have better control over which ROS nodes are able to communicate

78
00:06:18,400 --> 00:06:20,470
with each other on the same network.
