1
00:00:00,980 --> 00:00:06,080
In this lecture, we will take our Simple World file a little bit further by adding in some sensors

2
00:00:06,080 --> 00:00:07,760
and utilizing plug ins.

3
00:00:09,240 --> 00:00:14,820
So let's take our Simple World file a bit further by adding in some sensors, and we can do this by

4
00:00:14,820 --> 00:00:20,460
going back to the example PSD file for the camera sensor that we were looking at earlier as a reference.

5
00:00:20,580 --> 00:00:24,870
Just a reminder that you can find this file in the following folder on your computer.

6
00:00:25,050 --> 00:00:26,430
So go to other locations.

7
00:00:26,430 --> 00:00:30,840
Computer User Share Ignition, Mission, Gazebo, six and Worlds.

8
00:00:30,840 --> 00:00:35,040
And this is where you will find all of these example world files.

9
00:00:35,040 --> 00:00:38,250
And we're going to be going off the camera sensor, SDF.

10
00:00:38,280 --> 00:00:43,380
Now, keep in mind, in order to utilize sensors, you must have included the sensor plugin within your

11
00:00:43,390 --> 00:00:44,010
SDF file.

12
00:00:44,010 --> 00:00:47,730
So now let's try to implement some of these features in our simple test world SDF file.

13
00:00:47,820 --> 00:00:53,460
The main thing I will copy over are the physics sensor, user commands and scene broadcasts or plug

14
00:00:53,460 --> 00:00:55,710
ins, and I'll place them near the top of my file.

15
00:01:03,170 --> 00:01:08,150
And just to tidy this up a bit, I'm going to go ahead and delete all the things we have commented out

16
00:01:08,150 --> 00:01:12,470
here from that example model that we've created earlier.

17
00:01:13,370 --> 00:01:19,970
So instead we're just going to be including the Sun model for some lighting and our ground plane model,

18
00:01:19,970 --> 00:01:22,610
which we made earlier in the previous lecture.

19
00:01:22,700 --> 00:01:28,100
So now let's go back to the camera sensor SDF file, and I'm going to scroll down till we get to this

20
00:01:28,100 --> 00:01:29,390
camera model.

21
00:01:29,390 --> 00:01:34,430
So we're just going to go ahead and copy and paste it directly into our file to see if we can get it

22
00:01:34,430 --> 00:01:36,230
working in our test world.

23
00:01:38,640 --> 00:01:44,520
Now, one of the tags I didn't go over yet is the post tag which we see here near the top of the model,

24
00:01:44,520 --> 00:01:48,120
and we also can have poses for our individual links.

25
00:01:48,330 --> 00:01:53,280
These post tags allow you to place your object within the desired x, y, z role.

26
00:01:53,280 --> 00:01:55,640
Pitch your space in your simulation.

27
00:01:55,650 --> 00:02:05,250
So here we see our camera is at an X position of for a y position of zero, a z position of 1.0 and

28
00:02:05,250 --> 00:02:15,960
a roll of zero degrees in radiance your of 0.0 degrees and 3.14 radians in the Z or your axis of rotation.

29
00:02:16,170 --> 00:02:20,280
And for those of you who don't know, 3.14 radians is 180 degrees.

30
00:02:20,280 --> 00:02:26,730
So basically the camera normally faces in the positive X direction, but in this case it is turned around

31
00:02:26,730 --> 00:02:28,500
to face towards the origin.

32
00:02:28,980 --> 00:02:34,140
I can also go ahead and change the attributes of our image to be a slightly higher resolution to say

33
00:02:34,170 --> 00:02:35,370
for AP.

34
00:02:39,230 --> 00:02:39,470
All right.

35
00:02:39,470 --> 00:02:40,970
That's all the changes I'll make for right now.

36
00:02:40,970 --> 00:02:46,220
So I'll go ahead and save what we have so far and we can go ahead and try to run this in terminal.

37
00:02:54,230 --> 00:02:59,450
And we want to make sure that we are properly including our models which we have imported in such as

38
00:02:59,450 --> 00:03:00,250
this ground plane.

39
00:03:00,260 --> 00:03:04,160
So I'll be sure to set the ignition gazebo resource path environment variable.

40
00:03:14,750 --> 00:03:17,060
All right, Let's test out what we have so far.

41
00:03:24,670 --> 00:03:30,310
So we see our total ground plane and a small black cube which represents our camera.

42
00:03:30,340 --> 00:03:34,780
Now, keep in mind that this black cube, which is representing our camera, also has physics and collision

43
00:03:34,780 --> 00:03:35,620
models enabled on it.

44
00:03:35,620 --> 00:03:39,230
So if we actually play the simulation, we'll see it falls to the ground.

45
00:03:39,250 --> 00:03:43,590
If you didn't want this, you could set these static property to true within our model.

46
00:03:43,600 --> 00:03:48,090
But let's see if we're able to successfully integrate our camera sensor into ROS.

47
00:03:48,100 --> 00:03:50,110
So I'll be sure to play the simulation.

48
00:03:50,140 --> 00:03:52,780
Head over to our terminal, Open a new terminal tab.

49
00:03:53,590 --> 00:03:56,830
And let's go ahead and list some of the topics that we have available in ignition.

50
00:03:59,620 --> 00:03:59,950
All right.

51
00:03:59,950 --> 00:04:02,140
And we see the camera topic here.

52
00:04:04,450 --> 00:04:08,620
Now, I know we took a look at this topic in the last lecture, but in case you ever wanted to find

53
00:04:08,620 --> 00:04:14,950
information about a particular ignition topic, simply do the dash I flag for info and pass in the particular

54
00:04:14,950 --> 00:04:18,400
topic you're interested in, which in this case we're interested in camera.

55
00:04:19,540 --> 00:04:21,490
So this will tell you things such as that.

56
00:04:21,490 --> 00:04:24,130
It's a publisher and then the address and the message type.

57
00:04:24,130 --> 00:04:29,500
So it's giving you the TCP address as well as the type of ignition message type that it is.

58
00:04:29,500 --> 00:04:34,180
And that might be useful if we're trying to bridge our topic into ROS, which we'll go ahead and do

59
00:04:34,180 --> 00:04:34,780
right now.

60
00:04:45,840 --> 00:04:49,920
So again, we saw this command in the last lecture, but essentially here I'm running the perimeter

61
00:04:49,920 --> 00:04:57,090
bridge node from the Ross Gazebo Bridge Ross package, and I'm taking the camera topic from ignition

62
00:04:57,090 --> 00:05:02,940
and converting it to a sensor messages image message type in Ross And then we are passing it from that

63
00:05:02,940 --> 00:05:07,200
ignition messages image type, which we saw right here.

64
00:05:07,980 --> 00:05:15,540
Then I'm passing in Ross Arcs to simply remap the topic name from camera to camera image raw, which

65
00:05:15,540 --> 00:05:18,840
is a type of format you would normally see within raw systems.

66
00:05:18,960 --> 00:05:21,150
So I'll go ahead and hit enter.

67
00:05:22,440 --> 00:05:24,210
Open up a third terminal tab.

68
00:05:26,140 --> 00:05:27,700
And I'll go ahead and run our.

69
00:05:31,860 --> 00:05:33,690
And here we already had it set up from the last lecture.

70
00:05:33,690 --> 00:05:38,750
But again, if you needed to get to this point, simply go to plugins, visualization, image view,

71
00:05:38,760 --> 00:05:42,760
and from here you can refresh the topics and select the one from above.

72
00:05:42,780 --> 00:05:47,700
So here we just see a ground upper rectangle and a teal lower rectangle.

73
00:05:47,700 --> 00:05:51,180
And that's just what our world looks like from the perspective of our camera.

74
00:05:52,030 --> 00:05:52,720
Now I can actually.

75
00:05:52,720 --> 00:05:53,500
Go ahead.

76
00:05:54,660 --> 00:05:55,950
And I'll pause the simulation.

77
00:05:57,440 --> 00:05:59,750
And I'll see if I can move our camera.

78
00:06:03,970 --> 00:06:06,010
I'll go ahead and move this back up.

79
00:06:13,120 --> 00:06:13,450
All right.

80
00:06:13,450 --> 00:06:14,860
So nothing seems to have changed.

81
00:06:14,860 --> 00:06:16,900
But if I go ahead and put this to the side.

82
00:06:18,280 --> 00:06:19,540
Move this a bit over.

83
00:06:19,570 --> 00:06:23,590
If I hit play, we'll see that the live image feed had changed.

84
00:06:23,590 --> 00:06:29,170
And I can also prove this by placing down additional shapes within the simulation like so.

85
00:06:29,350 --> 00:06:30,650
All right, so that's simple enough.

86
00:06:30,670 --> 00:06:35,920
Now, let's go ahead and see how we can change up this simulation to include things such as a image

87
00:06:35,920 --> 00:06:38,700
view window directly within the simulation.

88
00:06:38,710 --> 00:06:43,600
So I'll go ahead and stop this from running and head back to our VS code instance.

89
00:06:43,600 --> 00:06:47,500
So if we head back to that sample camera sensor SDF file.

90
00:06:47,830 --> 00:06:51,280
So if we scroll up to the top here, we can actually see this gooey tags.

91
00:06:51,280 --> 00:06:53,620
It stands for a graphical user interface.

92
00:06:53,620 --> 00:06:55,480
So we scroll down.

93
00:06:55,480 --> 00:07:01,150
So within these tags we have a series of plug ins related to interfacing with the user interface and

94
00:07:01,150 --> 00:07:01,870
modifying it.

95
00:07:01,870 --> 00:07:06,760
So we have things such as what type of engine and scene renderer we're utilizing and you can do things

96
00:07:06,760 --> 00:07:09,700
such as change the title of the ignition gazebo window.

97
00:07:11,110 --> 00:07:17,710
And here we see things such as the entity context menu, gazebo, scene manager and interactive view

98
00:07:17,710 --> 00:07:18,280
Control.

99
00:07:18,280 --> 00:07:20,170
So a few of these are what I'm actually interested in.

100
00:07:20,170 --> 00:07:25,600
And to get a feel for this, let's actually go ahead and run this example simulation.

101
00:07:25,600 --> 00:07:26,800
So ignition.

102
00:07:28,550 --> 00:07:29,200
Gazebo.

103
00:07:31,070 --> 00:07:32,450
Camera sensors.

104
00:07:34,580 --> 00:07:39,020
And this is not in our world file, but it'll automatically default to that default worlds directory,

105
00:07:39,020 --> 00:07:40,160
which we looked at earlier.

106
00:07:42,190 --> 00:07:47,080
So here we see a few things within the user interface, which we may not have had earlier.

107
00:07:47,440 --> 00:07:49,780
Specifically this image display window.

108
00:07:49,780 --> 00:07:52,690
So if we actually go ahead and hit play, we'll see these things fall down.

109
00:07:52,690 --> 00:07:57,340
If we go ahead and refresh, we see the camera topic and we have this image viewer directly in the user

110
00:07:57,340 --> 00:07:59,140
interface, which might be useful to you.

111
00:07:59,290 --> 00:08:01,990
So let's go ahead and add that in to our Test world file.

112
00:08:01,990 --> 00:08:06,610
So for now, I'm just going to go ahead and copy all the contents within this goofy tag.

113
00:08:11,610 --> 00:08:15,660
And we'll place it just below the other plugins that we put in our file earlier.

114
00:08:17,370 --> 00:08:22,710
Now let's say I want to switch things up a bit and remove the entity tree and component inspector so

115
00:08:22,710 --> 00:08:26,870
that the simulation window only contains the viewport and the image display.

116
00:08:26,880 --> 00:08:31,230
So all I have to do is remove the corresponding plugins.

117
00:08:32,280 --> 00:08:40,140
One of the properties I can modify for this display is I can change the state tag from docked to floating,

118
00:08:40,440 --> 00:08:45,480
and instead of locking it to the right sidebar in the simulation, this will give us a floating window

119
00:08:45,480 --> 00:08:46,680
within the simulation.

120
00:08:47,040 --> 00:08:52,560
So now if I save our test world file and relaunch it in our terminal.

121
00:08:58,130 --> 00:08:58,310
Here.

122
00:08:58,310 --> 00:09:01,790
We have a test file, but we don't have all the normal components we would normally have here on the

123
00:09:01,790 --> 00:09:02,550
right side.

124
00:09:02,570 --> 00:09:06,770
Instead, we have this floating window, which is for our image display.

125
00:09:06,770 --> 00:09:08,260
So now we've subscribed to camera.

126
00:09:08,270 --> 00:09:12,440
If I hit play, we will see the image feed directly within the simulation.

127
00:09:12,770 --> 00:09:18,590
And so this might be useful so that you don't have to bridge the camera topic every time and look through

128
00:09:18,590 --> 00:09:19,770
it in RCT.

129
00:09:19,850 --> 00:09:25,370
You can simply look at what your camera feed sees in your simulation within this simulation window.

130
00:09:25,460 --> 00:09:31,700
Now, that was a lot of code to put into our world file just so that we could configure our user interface.

131
00:09:31,700 --> 00:09:37,220
So optionally, you can save the configuration to an external file within the ignition gazebo simulation

132
00:09:37,220 --> 00:09:39,590
by hitting to this left tab over here.

133
00:09:39,590 --> 00:09:43,400
And we can save client configuration as.

134
00:09:43,670 --> 00:09:46,460
And here you can select a location to save it.

135
00:09:46,460 --> 00:09:50,030
And I'll just set mine as test sim gui config.

136
00:09:52,250 --> 00:09:54,770
And for now, I'll just save it to my home directory.

137
00:09:56,970 --> 00:09:58,260
So that's gone ahead and saved.

138
00:09:58,260 --> 00:10:00,840
And so now if I go ahead and close this.

139
00:10:01,650 --> 00:10:06,540
And now, if I were to go ahead and actually delete all the things we just pasted in for configuring

140
00:10:06,540 --> 00:10:07,860
our user interface.

141
00:10:08,850 --> 00:10:09,120
Right?

142
00:10:09,120 --> 00:10:14,670
So now we're just back to our normal physics plugins and then our models that we're including.

143
00:10:16,420 --> 00:10:18,370
So if I go ahead and save this.

144
00:10:21,040 --> 00:10:22,540
And rerun our test world.

145
00:10:24,300 --> 00:10:29,160
Right, we get this standard configuration, but if we wanted to load that config file we just saved,

146
00:10:29,160 --> 00:10:31,230
all we have to do is pass it an extra parameter.

147
00:10:32,070 --> 00:10:40,140
So when we go to launch our test world SDF, we can type gooey dash config and then we can put in the

148
00:10:40,140 --> 00:10:46,200
location of our config file, which in this case is test sim gui config.

149
00:10:49,260 --> 00:10:52,710
And now we see that it is configured as we had it earlier.

150
00:10:53,930 --> 00:11:00,980
So I have this now floating image view window without having to have all the necessary backbone code

151
00:11:00,980 --> 00:11:03,320
directly here in my test world file.

152
00:11:03,320 --> 00:11:09,650
It's instead within the config file, which we could simply include within our package.

153
00:11:09,650 --> 00:11:16,730
And so this has a lot of attributes just to simply match exactly what you had in your client interface

154
00:11:16,730 --> 00:11:19,700
to make sure it matches when somebody else opens it.

155
00:11:19,700 --> 00:11:24,410
So we didn't have to include any of this within our Test SIM world file.

156
00:11:24,410 --> 00:11:27,800
So that helps us out a little bit, keep things a little bit cleaner.

157
00:11:28,960 --> 00:11:34,540
Now that was a bit take taken, but essentially we added some code to our PSD files to do things such

158
00:11:34,540 --> 00:11:40,510
as configure our simulation user interface and even include sensors, which we could include on our

159
00:11:40,510 --> 00:11:41,140
robot.

160
00:11:41,530 --> 00:11:46,540
In the next lecture, we'll take a look at one of the ways we can create our own robot models so that

161
00:11:46,540 --> 00:11:49,690
we can include them in our ignition gazebo simulation.
