1
00:00:00,840 --> 00:00:03,380
OC Let's dive into robotics simulation.

2
00:00:03,390 --> 00:00:06,720
The tool which we will use for this is called Ignition Gazebo.

3
00:00:06,750 --> 00:00:11,940
For those of you who have used ROS1 or RA Foxy, you probably have utilized Gazebo before.

4
00:00:12,180 --> 00:00:16,980
Well, it is in the process of rebranding and integrating with Ignition robotics.

5
00:00:19,360 --> 00:00:24,740
Now, the interesting thing for you as a developer is the usage of this simulation with Ros.

6
00:00:24,760 --> 00:00:29,020
Well, before we get to that, let's have a look at the ignition command line interface.

7
00:00:31,010 --> 00:00:35,810
In order to install the simulator, We'll go ahead and open up a terminal and run the following command.

8
00:00:43,100 --> 00:00:50,540
So here we are installing the Ross ignition package and this Ross distro flag will just resolve to humble.

9
00:00:50,540 --> 00:00:57,230
So let's be Ross Dash humble dash Ross dash IG and here's the ignition gazebo package.

10
00:00:58,070 --> 00:00:59,510
Go ahead and put in your password.

11
00:01:00,530 --> 00:01:02,720
And for most of you, this will take about 5 minutes install.

12
00:01:02,720 --> 00:01:04,130
So feel free to pause this video.

13
00:01:04,160 --> 00:01:07,370
I have gone ahead and installed this beforehand so I can just continue on with the lecture.

14
00:01:07,370 --> 00:01:10,070
But feel free to pause here while you wait for your installation.

15
00:01:10,760 --> 00:01:15,890
You can find a common example tutorial showcasing ignition gazebo at the following page.

16
00:01:16,100 --> 00:01:21,650
So here it has a test world which you can run called Visualize Light R, which will open up this little

17
00:01:21,650 --> 00:01:26,460
world here with a small robot and a play structure environment.

18
00:01:26,480 --> 00:01:28,130
So I'll go ahead and put this on the side.

19
00:01:29,900 --> 00:01:33,920
So that we can copy the commands and paste them into terminal.

20
00:01:36,710 --> 00:01:39,090
So this opens up the gazebo simulation.

21
00:01:39,110 --> 00:01:44,510
I'll go ahead and full screen this and it opens it up just as we saw it in the tutorial page.

22
00:01:44,510 --> 00:01:48,310
So you can use your middle mouse button to rotate around the screen.

23
00:01:48,320 --> 00:01:55,970
You can use your left mouse button to pan and you can use the right mouse button to zoom in and out.

24
00:01:57,030 --> 00:01:59,400
You can also use your scroll wheel to zoom in and out.

25
00:01:59,910 --> 00:02:04,740
If you're using the virtual machine like VMware, there have been reported issues of the render not

26
00:02:04,740 --> 00:02:05,790
properly displaying.

27
00:02:05,790 --> 00:02:11,610
And one of the ways to fix this issue is to use an older version of the rendering engine like so.

28
00:02:13,950 --> 00:02:16,860
So here we see a playground area with a robot that has a lighter on it.

29
00:02:16,860 --> 00:02:22,830
For those of you who don't know, a lighter is a type of sensor which can detect range using near-infrared

30
00:02:22,830 --> 00:02:26,730
light, usually returning a point cloud of nearby objects.

31
00:02:26,760 --> 00:02:31,440
Now we'll get into how to make a simulation like this in a bit, but let's get a feel for it first.

32
00:02:31,500 --> 00:02:35,810
The top right, we see information about visualizing the leader, which is specific to this example.

33
00:02:35,820 --> 00:02:37,650
Usually you wouldn't see this by default.

34
00:02:38,130 --> 00:02:42,600
In the middle section, we see information about the simulation world, so we can see different things

35
00:02:42,600 --> 00:02:47,670
such as the physics and even magnetic fields associated with this simulation.

36
00:02:48,830 --> 00:02:55,570
And below that we have our entity tree, which has the individual components which are within this simulation.

37
00:02:55,580 --> 00:02:57,710
We can even open this dropdown.

38
00:02:57,710 --> 00:03:02,180
And here in the right we can see how the simulation is performing in real time.

39
00:03:02,180 --> 00:03:05,810
So depending on your computer specs and load, this number may fluctuate.

40
00:03:05,810 --> 00:03:12,500
And lastly, in the lower left, we can pause the simulation and even select the step size of time,

41
00:03:12,500 --> 00:03:14,990
which we want to go forward in.

42
00:03:15,640 --> 00:03:20,450
Now, the interesting thing for you as a ROS developer is the usage of the simulation with Ros.

43
00:03:20,470 --> 00:03:25,450
Well, before we get to that, we have to look at the ignition command line interface with the terminal

44
00:03:25,450 --> 00:03:26,200
open again.

45
00:03:26,650 --> 00:03:28,060
I'll open a new terminal tab.

46
00:03:29,710 --> 00:03:31,700
Again, don't worry about all the messages you may see there.

47
00:03:31,720 --> 00:03:34,420
These are just general messages when running the simulation.

48
00:03:34,420 --> 00:03:41,500
But now in this terminal tab, I can do ignition topic L And here ignition is shorthanded as I g.

49
00:03:41,500 --> 00:03:42,010
N.

50
00:03:44,980 --> 00:03:45,280
All right.

51
00:03:45,280 --> 00:03:49,930
And here we see a series of topics, just like as if we would, if we ran across two topic lists and

52
00:03:49,930 --> 00:03:53,590
had these corresponding topics running on our Ross system.

53
00:03:54,460 --> 00:03:58,630
However, none of these topics are actually connected to Ros, which we could check by running the raw

54
00:03:58,810 --> 00:03:59,770
topic list command.

55
00:04:02,300 --> 00:04:06,920
So here we see none of these corresponding topics are linked to Ros.

56
00:04:07,160 --> 00:04:12,110
That's because any ignition topics we are interested in using in Ross, we need to bridge over which

57
00:04:12,110 --> 00:04:14,130
we can do with the ignition bridge driver.

58
00:04:14,150 --> 00:04:15,950
So let's go ahead and install it.

59
00:04:21,250 --> 00:04:26,050
So if we actually go back to the tutorial page, we can actually scroll down.

60
00:04:28,230 --> 00:04:32,220
And this actually talks about installing the Ross Ignition Bridge like we just mentioned.

61
00:04:32,640 --> 00:04:34,830
And if I scroll down a little bit further.

62
00:04:38,220 --> 00:04:42,400
Can go over to this section talking about visualizing light our data in ROS two.

63
00:04:42,420 --> 00:04:48,330
So here you'll be using the Ros gazebo bridge ROS package, the perimeter bridge node, and then we're

64
00:04:48,330 --> 00:04:56,610
going to be mapping the light sensor message from ignition to a laser scan object in ROS.

65
00:04:56,760 --> 00:05:00,780
So again, if I do the ignition topic L command.

66
00:05:02,000 --> 00:05:05,600
We can see this light hour to topic right here.

67
00:05:07,720 --> 00:05:12,310
And here there are simply specifying the message type, which they are translating it to.

68
00:05:12,340 --> 00:05:15,100
So we're translating it to a sensor message.

69
00:05:15,100 --> 00:05:16,990
Laser scan topic.

70
00:05:17,710 --> 00:05:22,870
And here we specify the ignition message type, which is being transferred from.

71
00:05:23,050 --> 00:05:28,420
So just like Ros topic types, these ignition topics have their own message types, which we are now

72
00:05:28,420 --> 00:05:32,600
bridging over to a topic called laser scan in ROS two.

73
00:05:32,620 --> 00:05:36,040
So let's go ahead and copy this command and try it out for ourselves.

74
00:05:42,030 --> 00:05:42,330
All right.

75
00:05:42,330 --> 00:05:43,890
So let's go on ahead and started running.

76
00:05:43,890 --> 00:05:54,000
And now if we run across two topic list, we can now see we have access to a laser scan topic, which

77
00:05:54,000 --> 00:05:55,710
I can go ahead and echo if I wanted to.

78
00:05:59,520 --> 00:06:01,810
Now notice nothing is being published to.

79
00:06:01,830 --> 00:06:04,770
Well, that's because in the simulation background I paused it.

80
00:06:04,770 --> 00:06:10,380
So if I go ahead and hit play and return back to my terminal, we get a sensor feed being outputted

81
00:06:10,380 --> 00:06:11,870
to our messages.

82
00:06:11,880 --> 00:06:13,500
So I'll go ahead and stop this.

83
00:06:14,070 --> 00:06:19,080
Going back to the tutorial page, it talks a little bit about how you can set up your service instance

84
00:06:19,080 --> 00:06:24,240
to visualize this laser scan information within the Aave's visualizer.

85
00:06:24,240 --> 00:06:25,680
So go ahead and feel free to do that.

86
00:06:25,680 --> 00:06:27,690
But we already talked a little bit about our views.

87
00:06:27,690 --> 00:06:33,420
So for now, let's just go ahead and move on to some of the other features that Ignition Bridge has

88
00:06:33,420 --> 00:06:34,220
to offer.

89
00:06:34,230 --> 00:06:37,650
So for now, I'm going to go ahead and stop this bridge node from running.

90
00:06:40,420 --> 00:06:41,290
Go and clear the screen.

91
00:06:41,290 --> 00:06:45,850
And with that, we should see that our laser scan topic is no longer being published to.

92
00:06:48,020 --> 00:06:53,600
And I can go ahead and stop this simulation from running simply by hitting control C in the terminal,

93
00:06:53,600 --> 00:06:54,680
which it was running in.

94
00:06:55,820 --> 00:06:57,290
And don't worry if it says Ubuntu has a problem.

95
00:06:57,290 --> 00:07:00,410
Sometimes it says that when you close out of the simulation.

96
00:07:00,440 --> 00:07:04,100
Now let's try a different example such as the camera sensor example.

97
00:07:12,330 --> 00:07:13,320
So this might take a while.

98
00:07:13,330 --> 00:07:17,100
As you can see, the download in the background, it's downloading some of the resources.

99
00:07:17,100 --> 00:07:22,230
So if you have a slow internet connection, just keep that in mind that if your simulation takes a while

100
00:07:22,230 --> 00:07:24,090
to install that, that may be the reason.

101
00:07:31,440 --> 00:07:31,740
All right.

102
00:07:31,740 --> 00:07:34,170
So here we see a bunch of random shapes.

103
00:07:34,170 --> 00:07:35,580
So we see this little cone object.

104
00:07:35,580 --> 00:07:44,070
Here we see this oops, we see this cube object, we see a sphere and we see a little black cube.

105
00:07:44,310 --> 00:07:47,160
So this little black box represents a camera.

106
00:07:47,160 --> 00:07:53,130
So we can use this camera window here in the right to view the camera topic from within the ignition

107
00:07:53,130 --> 00:07:53,700
ecosystem.

108
00:07:53,700 --> 00:07:57,930
So if I hit the refresh button, it'll refresh the available topics that I can subscribe to.

109
00:07:57,930 --> 00:08:05,580
And here we see the cube and the cone and the ball, which are currently sitting within this simulation

110
00:08:05,580 --> 00:08:06,390
we have here.

111
00:08:06,630 --> 00:08:11,670
Or alternatively, we can use the parameter bridge to again view this in Ross.

112
00:08:11,670 --> 00:08:15,300
So again, if I do ignition topic L.

113
00:08:20,600 --> 00:08:23,840
We can see we have this camera topic being published, too.

114
00:08:24,110 --> 00:08:29,600
So if we go back to our old parameter bridge command, all we have to do is change some of these parameters

115
00:08:29,600 --> 00:08:31,430
a bit to match what we're looking for.

116
00:08:31,430 --> 00:08:36,350
So instead of the light hour two topic, we are trying to bridge the camera topic and instead of the

117
00:08:36,350 --> 00:08:43,010
laser scan message type from sensor messages, we are going to be changing this to a image message type.

118
00:08:45,820 --> 00:08:51,580
And instead of this being a laser scan instance in ignition, it's called an image as well.

119
00:08:53,640 --> 00:08:59,670
Then we're passing in some Ross arcs, which all we're doing is mapping the default topic name, which

120
00:08:59,670 --> 00:09:03,330
in this case it will get transferred to the same type of topic name.

121
00:09:03,330 --> 00:09:04,350
So camera.

122
00:09:05,860 --> 00:09:11,590
And we can set it to something else which may match the Rasta ecosystem a bit better, which may be

123
00:09:11,590 --> 00:09:15,760
something along the lines of camera slash image raw.

124
00:09:16,690 --> 00:09:17,380
All right.

125
00:09:17,380 --> 00:09:20,590
And now if I go ahead and do raw topic list.

126
00:09:22,720 --> 00:09:25,960
We have our image raw instance and if I echo it.

127
00:09:29,460 --> 00:09:34,740
We see the pixel information being displayed to the screen and of course we could do something like

128
00:09:34,740 --> 00:09:38,790
our go to visualizations image view.

129
00:09:41,600 --> 00:09:44,680
Can refresh the topics and select the camera image raw.

130
00:09:44,690 --> 00:09:50,690
We see that same image feed we were seeing in the ignition ecosystem, but now we're able to utilize

131
00:09:50,690 --> 00:09:52,100
it within Ross.

132
00:09:52,170 --> 00:09:53,300
I'll go ahead and close this.

133
00:09:55,390 --> 00:09:55,660
All right.

134
00:09:55,660 --> 00:10:01,630
So that should give you a gist of the workflow and ROS integration of this ignition gazebo simulation.

135
00:10:01,660 --> 00:10:06,670
You can find the PDF files that come with the ignition gazebo installation at the following location.

136
00:10:16,980 --> 00:10:22,490
So here we see a series of PSD files with different examples that you can run.

137
00:10:22,500 --> 00:10:27,810
For example, let's try and look at the camera sensor as a file we have here running in the background.

138
00:10:35,210 --> 00:10:41,930
So here in VW's code, we can simply see that this PDF file follows an XML syntax to it, and it has

139
00:10:41,930 --> 00:10:47,570
several things such as a world attribute, physics attributes and a series of plug ins.

140
00:10:50,240 --> 00:10:54,890
Instances which we are rendering the 3D scene and more plugins.

141
00:10:55,160 --> 00:10:56,900
And if we scroll down further.

142
00:10:57,640 --> 00:11:02,890
We can see there are models such as this box model, which is that red cube we saw earlier.

143
00:11:04,630 --> 00:11:09,430
We see a sphere model which has different geometry attributes to it.

144
00:11:10,280 --> 00:11:16,970
And we see our camera model, which in this case has just a simple box geometry to it.

145
00:11:17,780 --> 00:11:25,010
But it also has this sensor tag to it, which links to the sensor plugin, which gives it attributes

146
00:11:25,010 --> 00:11:32,180
such as the width and height of the image as well as the frame rate and field of view and even the topic

147
00:11:32,180 --> 00:11:32,480
name.

148
00:11:32,510 --> 00:11:37,520
Now, one of the biggest issues I have with this new user interface with Ignition Gazebo is that it

149
00:11:37,520 --> 00:11:42,620
does not have a built in model editor to help automatically generate these PSD files.

150
00:11:42,620 --> 00:11:46,850
So this can be a pain when you have to generate your own PSD files and then continuously run it to see

151
00:11:46,850 --> 00:11:48,250
what it looks like in the simulation.

152
00:11:48,260 --> 00:11:54,010
So for now, let's try to create our own SDF world file to run in ignition gazebo.

153
00:11:54,020 --> 00:11:59,270
So I'll go ahead and set up our package to hold the files we are going to be creating in folders called

154
00:11:59,270 --> 00:12:01,130
Worlds and Models.

155
00:12:01,880 --> 00:12:05,510
And if I go ahead and open up a new file Explorer window and take a look at this.

156
00:12:08,000 --> 00:12:12,740
We can see we have these new world and models folders which are empty.

157
00:12:13,650 --> 00:12:18,840
So within Vsco, I can create a new world file, which I'll just call Test World.

158
00:12:20,780 --> 00:12:25,580
First thing I will do is set my language syntax in the bottom right to XML.

159
00:12:26,210 --> 00:12:29,470
And if you ever want to, you can always set this as the default setting.

160
00:12:29,480 --> 00:12:35,930
You can always configure the file association for SDA to always be XML and this way VTS code will remember

161
00:12:35,930 --> 00:12:36,290
it.

162
00:12:36,320 --> 00:12:41,750
Now there's actually some handy functionality in this code for HTML files, which look very similar

163
00:12:41,750 --> 00:12:45,890
to XML in which it will auto close tags for us when we create them.

164
00:12:45,890 --> 00:12:49,850
So for the time being I will configure SDF files to be treated as HTML.

165
00:12:51,570 --> 00:12:54,870
You can always just do this manually for each file like so.

166
00:12:57,250 --> 00:13:01,180
And now we see the icon has changed to simulate the HTML five logo.

167
00:13:01,180 --> 00:13:04,360
And for now, I'll go ahead and set my tab size to two.

168
00:13:05,720 --> 00:13:13,010
So first things first, I'm going to put in a Steph and world tag and I will set Steph version to 1.7

169
00:13:13,010 --> 00:13:15,050
and call my World Test World.

170
00:13:20,230 --> 00:13:25,390
One of the easiest ways to get up and running is to include existing models, which we can find on the

171
00:13:25,390 --> 00:13:26,920
Ignition Models page.

172
00:13:30,940 --> 00:13:35,440
So if you ever want to look into easily exportable models for your simulation, you can check them out

173
00:13:35,440 --> 00:13:35,890
here.

174
00:13:35,920 --> 00:13:41,570
For now, I will include a sun instance to light our scene and a ground plane from open robotics.

175
00:13:41,590 --> 00:13:44,620
You can always search these up within the models instance here.

176
00:13:45,370 --> 00:13:50,860
So if I search up sun, we see the one from open robotics here and we can see here, we can easily copy

177
00:13:50,860 --> 00:13:53,650
the SDF snippet to our clipboard.

178
00:13:56,050 --> 00:13:57,700
And include it in our world.

179
00:14:00,250 --> 00:14:07,270
So here we've created our include tags and then specified a URI, which in this case is the location

180
00:14:07,270 --> 00:14:09,040
of this particular model.

181
00:14:10,530 --> 00:14:14,160
We'll go back to the instance and I will search for a ground plane.

182
00:14:19,190 --> 00:14:24,800
And I will just choose this simple gray one from open robotics and we'll do the same exact thing.

183
00:14:27,660 --> 00:14:30,210
With that, I can go ahead and save the file.

184
00:14:31,930 --> 00:14:37,600
Go into our terminal and I'll stop the current simulation that's running and the parameter bridge.

185
00:14:40,320 --> 00:14:45,180
Go ahead and make some extra space for now and we'll change into the directory where our world file

186
00:14:45,180 --> 00:14:46,020
is located.

187
00:14:46,650 --> 00:14:51,780
So here we can see our test world PSD file and we can run it just like we did with the other files with

188
00:14:51,860 --> 00:14:56,400
Iron Gazebo and the name of the world, which is Test World SDF.

189
00:14:58,080 --> 00:15:00,990
Oh, and I forgot to set the version to 1.7.

190
00:15:06,590 --> 00:15:07,940
Let's go ahead and save that.

191
00:15:08,150 --> 00:15:09,140
Let's try this again.

192
00:15:12,910 --> 00:15:14,060
And there we go.

193
00:15:14,080 --> 00:15:21,610
So here we see nothing special, just a blank world with a sun and ground plain object, which is this

194
00:15:21,610 --> 00:15:23,990
gray square we see here.

195
00:15:24,010 --> 00:15:26,440
Now, this doesn't really teach you much on how to make your own models.

196
00:15:26,440 --> 00:15:29,020
So let's create a model within our world file.

197
00:15:29,170 --> 00:15:34,140
Let's start with something simple, like making our own ground plane that we can customize.

198
00:15:34,150 --> 00:15:40,210
So I'll go ahead and comment out the ground plane, include statement by hitting control and forward

199
00:15:40,210 --> 00:15:45,280
slash, which will do this format for doing a multi line comment.

200
00:15:45,280 --> 00:15:50,320
And let's go ahead and create our own ground plane, which we start off with a model tag.

201
00:15:52,540 --> 00:15:55,150
The model will contain attributes and links.

202
00:15:55,150 --> 00:16:00,490
For example, one attribute we will want to set is called static to True, which will fix this object

203
00:16:00,490 --> 00:16:02,620
in the simulation so it doesn't move.

204
00:16:04,440 --> 00:16:06,720
Now let's go ahead and create a link for our model.

205
00:16:13,420 --> 00:16:17,680
Now, in order for our ground plane to be visible in our simulation, we will need to create visual

206
00:16:17,680 --> 00:16:19,240
attributes within our link.

207
00:16:22,320 --> 00:16:24,960
Then I need to give this a geometry attribute.

208
00:16:25,050 --> 00:16:29,160
In which case I want this to be a plane so I can format it like so.

209
00:16:33,270 --> 00:16:36,190
Now I need to pass in attributes for this form.

210
00:16:36,210 --> 00:16:39,360
You will have different attributes depending on which geometry you chose.

211
00:16:39,360 --> 00:16:43,650
But in the case of the plane, I need to specify a normal, which is the direction the top part of the

212
00:16:43,650 --> 00:16:44,540
plane points.

213
00:16:44,550 --> 00:16:51,120
So in our case, I want the plane to be flat on the XY plane and I will specify the Z section as one,

214
00:16:51,420 --> 00:16:56,280
then specify the size attribute which takes in the length and width, and I'll just set it to 25 by

215
00:16:56,280 --> 00:16:57,540
25 metres.

216
00:16:59,770 --> 00:17:00,240
Great.

217
00:17:00,250 --> 00:17:05,110
Now let's set a material attribute outside of the geometry tag, but still within the visual tag.

218
00:17:05,690 --> 00:17:11,900
Then there are three attributes to specify which are ambient, diffuse and specular, which reference

219
00:17:11,900 --> 00:17:15,500
different ways which light can interact or emit from our model.

220
00:17:15,710 --> 00:17:19,520
Each of these can take in a red, green, blue and alpha value.

221
00:17:19,520 --> 00:17:24,920
So to set it to blue and not be transparent, I will set the last two numbers to be one.

222
00:17:27,260 --> 00:17:31,070
And we can copy this between the diffuse and specular attribute names.

223
00:17:37,460 --> 00:17:41,600
So I'll simply alt click to get multiple cursors and I can change the name like so.

224
00:17:44,180 --> 00:17:45,090
All right, that's it.

225
00:17:45,110 --> 00:17:51,010
We created a new model called ground plane set static to true, so it doesn't move within the simulation.

226
00:17:51,020 --> 00:17:56,510
And then we created a link which has a visual geometry of plane where we specify the size and material

227
00:17:56,510 --> 00:17:57,380
properties.

228
00:17:57,380 --> 00:18:01,190
Let's save this file and rerun the simulation in our terminal.

229
00:18:04,440 --> 00:18:07,350
So go ahead and clear the screen and rerun it.

230
00:18:09,710 --> 00:18:16,040
So notice this looks very similar, except now we have a blue plane since we've changed the color attributes

231
00:18:16,040 --> 00:18:18,830
within our SDF file here.

232
00:18:20,900 --> 00:18:23,150
And if you went ahead and clicked on this model.

233
00:18:25,150 --> 00:18:30,820
We can select the visual attribute of this particular ground link, go down to material, and we can

234
00:18:30,820 --> 00:18:35,200
see here it is specifying the colors that we specified within the code editor.

235
00:18:35,860 --> 00:18:39,100
And if you wanted to, you could go ahead and change the colors.

236
00:18:40,570 --> 00:18:44,400
I'll go ahead and see what it looks like when I change all of those different types of ways light can

237
00:18:44,400 --> 00:18:46,080
bounce off to orange.

238
00:18:46,110 --> 00:18:50,640
Now, there's something I want to show you in which I can add a cube to the simulation by clicking on

239
00:18:50,640 --> 00:18:54,720
this box in the upper left corner and placing it down.

240
00:18:55,080 --> 00:19:00,030
And I'll actually go ahead and click on it, translate it, and I'll put it slightly above.

241
00:19:02,370 --> 00:19:06,210
And I'll put it slightly above our ground plane.

242
00:19:08,750 --> 00:19:14,660
Now if I hit play to start the simulation, notice it falls straight through our ground plane and begins

243
00:19:14,660 --> 00:19:18,440
falling down below so we can see it falling very far away.

244
00:19:18,860 --> 00:19:20,840
Now, that's hardly useful for us, right?

245
00:19:20,840 --> 00:19:25,640
So we see this plane here, but it's not actually interacting with any of our physical objects.

246
00:19:25,670 --> 00:19:27,910
Let's go ahead and pause this for now so the cube stops falling.

247
00:19:27,920 --> 00:19:31,400
So in order to prevent this, we have to create collision tags.

248
00:19:31,670 --> 00:19:33,440
So let's go ahead and add that now.

249
00:19:33,620 --> 00:19:39,410
So outside of the visual scope of our model, I will create our collision tags and call this a collision

250
00:19:39,410 --> 00:19:39,980
ground.

251
00:19:43,420 --> 00:19:48,400
Then within the tags I will copy the same geometry attributes I have in my visual model.

252
00:19:51,810 --> 00:19:52,110
All right.

253
00:19:52,110 --> 00:19:57,810
So it's just a plane with a size of 25 by 25 and the Z normal pointing upwards.

254
00:19:58,870 --> 00:20:04,240
Now, the reason we have to repeat this is because you can have different visuals from your collision.

255
00:20:04,270 --> 00:20:09,700
Sometimes people will create complex meshes to make their simulation models look highly realistic,

256
00:20:09,700 --> 00:20:15,910
but want to keep the collision geometry simple so that the physics engine does not have to try to calculate

257
00:20:15,910 --> 00:20:20,440
physics for complex shapes with different components and densities.

258
00:20:21,730 --> 00:20:27,460
But with that done, let's save the file and go ahead and rerun our simulation.

259
00:20:32,700 --> 00:20:35,070
All right, So we see our blue plane again.

260
00:20:37,560 --> 00:20:38,730
Put our cube down.

261
00:20:41,750 --> 00:20:43,190
Raise it up above our plane.

262
00:20:43,190 --> 00:20:48,960
And this time if I hit play, it doesn't go falling through the plane like it did earlier.

263
00:20:48,980 --> 00:20:53,840
It's also worth noting you can interact with attributes of the simulation itself, such as gravity.

264
00:20:54,410 --> 00:21:01,160
So in this case I can set gravity to be positive 0.5 meters per second squared in the Z direction.

265
00:21:02,310 --> 00:21:05,220
So saving that and restarting our world.

266
00:21:09,920 --> 00:21:16,820
So now if I place the cube down, hit play, we see the cube begins to float above the plane upwards

267
00:21:16,820 --> 00:21:19,100
because we made gravity positive.

268
00:21:19,100 --> 00:21:25,540
In this instance, instead of the -9.8 meters per second squared we're used to in real life.

269
00:21:25,700 --> 00:21:30,200
Now I'll go back to our code and comment that out so that our simulations don't behave like that in

270
00:21:30,200 --> 00:21:30,860
the future.

271
00:21:30,860 --> 00:21:33,920
But keep it here so that you know, you can interact with it if you need it.

272
00:21:34,460 --> 00:21:39,110
Now, you can probably imagine that if we keep adding all these model tags and all their attributes

273
00:21:39,110 --> 00:21:44,930
within our world file, that this file will begin to get really crowded and we may end up editing attributes

274
00:21:44,930 --> 00:21:46,160
from the wrong model.

275
00:21:46,250 --> 00:21:52,670
So let's go ahead and separate our model into a separate file so we can simply include it into our world

276
00:21:52,670 --> 00:21:53,330
instead.

277
00:21:54,800 --> 00:21:59,300
I can do this by creating a new folder in our models folder called Ground Plane.

278
00:21:59,300 --> 00:22:03,200
Then within this new folder, create a file called Model SDF.

279
00:22:03,710 --> 00:22:09,770
We'll start this file off with some SDF tag and then in between the tags we can paste in the contents

280
00:22:09,770 --> 00:22:12,370
of our model from our test world.

281
00:22:12,380 --> 00:22:18,560
So I'll go ahead and comment this out from our test world file and place them into our model that SDF

282
00:22:18,560 --> 00:22:20,750
file that we created here in the ground plane folder.

283
00:22:20,750 --> 00:22:24,970
With that done, we now have to create a model config file within that same folder.

284
00:22:24,980 --> 00:22:28,010
So I'll click new file model config.

285
00:22:29,700 --> 00:22:32,940
And I will configure this file as XML.

286
00:22:35,640 --> 00:22:37,920
Oh, and be sure to set this to HTML.

287
00:22:38,460 --> 00:22:39,120
Here we go.

288
00:22:42,380 --> 00:22:47,810
Then I can add a model tag which will contain information about your model's name, version and PSD

289
00:22:47,960 --> 00:22:48,500
file.

290
00:22:59,550 --> 00:23:05,210
Now, the nice thing is by default, you should specify your model as model SDF here in the config file.

291
00:23:05,220 --> 00:23:09,200
But thanks to this config file, you can rename it to something that makes more sense.

292
00:23:09,210 --> 00:23:13,980
That way if you have multiple files open for different models in your code editor, you have a better

293
00:23:13,980 --> 00:23:16,320
idea what each one is that you're editing.

294
00:23:16,320 --> 00:23:23,670
So just to prove that this works, I can change this to say, ground plane, SDF or here, I'll do better,

295
00:23:23,670 --> 00:23:25,410
I'll do my ground plane at SDF.

296
00:23:25,410 --> 00:23:27,420
So don't get confused with the standard ground plane.

297
00:23:28,160 --> 00:23:32,180
And then rename this model that PDF file here to match.

298
00:23:36,200 --> 00:23:36,530
All right.

299
00:23:36,530 --> 00:23:41,210
So here we're specifying the My Ground plan, that PDF file, and we've specified that name as such

300
00:23:41,210 --> 00:23:41,860
right here.

301
00:23:41,870 --> 00:23:46,310
Then last thing to include is information about the model author, as well as a brief description of

302
00:23:46,310 --> 00:23:47,720
what this model is.

303
00:24:05,260 --> 00:24:08,230
Now I can be sure that both these files are saved.

304
00:24:08,980 --> 00:24:11,290
Go into my test file.

305
00:24:13,280 --> 00:24:14,090
And I'll copy over.

306
00:24:14,090 --> 00:24:21,470
This includes statement with the URI strings and the URI, we will instead be specifying will be in

307
00:24:21,470 --> 00:24:25,760
the model's slash ground plane folder.

308
00:24:26,540 --> 00:24:30,920
And just to make this a bit more clean, I'll go ahead and format it like so.

309
00:24:31,040 --> 00:24:36,500
And just to prove that this is using our new ground plane PSD file instead of the one we created directly

310
00:24:36,500 --> 00:24:40,820
within the world file earlier, I can actually go ahead and change up the colors a little bit, so I'll

311
00:24:40,820 --> 00:24:42,140
change this to teal.

312
00:24:43,040 --> 00:24:45,800
And so I'll save the my ground plane PSD file.

313
00:24:46,100 --> 00:24:47,540
So again, this is being included here.

314
00:24:47,540 --> 00:24:51,410
I'm not modifying any of the commented alt model that was here before.

315
00:24:51,440 --> 00:24:56,930
And if I go back to our terminal, stop our test world from running, rerun it.

316
00:24:59,250 --> 00:25:05,130
We see we now have this world with a total ground plane model associated with it.

317
00:25:07,370 --> 00:25:11,090
And we see the source file path is my ground plane dot SDF.

318
00:25:11,120 --> 00:25:16,400
Now, this is great, but keep in mind, the thing I use for the location model won't always work.

319
00:25:16,430 --> 00:25:24,230
For example, if I went a directory back and then tried to rerun these simulation like so.

320
00:25:29,260 --> 00:25:32,590
We get an error message saying unable to find Yuri.

321
00:25:32,620 --> 00:25:37,450
That's because the path is relative to the current working directory, not the world file.

322
00:25:37,660 --> 00:25:42,280
The way we can resolve this is by instead setting an environment variable to point to the resource path

323
00:25:42,280 --> 00:25:43,420
for our simulation.

324
00:25:43,750 --> 00:25:49,750
In this case it is our model's directory, which I can get by printing the current directory and then

325
00:25:49,750 --> 00:25:52,210
setting the environment variable like so.

326
00:25:59,830 --> 00:26:02,110
Then I can go into the PDF file.

327
00:26:03,000 --> 00:26:04,710
And delete the folder name.

328
00:26:05,220 --> 00:26:07,320
So I'll go ahead and save this.

329
00:26:08,930 --> 00:26:10,280
Rerun our simulation.

330
00:26:13,890 --> 00:26:18,600
And here now, even though we're in a different directory, the simulation loads just fine because it's

331
00:26:18,600 --> 00:26:24,090
able to load in the resource path since we set the particular environment variable.

332
00:26:25,510 --> 00:26:25,900
All right.

333
00:26:25,900 --> 00:26:27,880
This is a good place to stop this lecture.

334
00:26:27,880 --> 00:26:33,340
So far, we've learned some basics about the ignition gazebo simulator, as well as how we can create

335
00:26:33,340 --> 00:26:36,070
PSD files for the simulator to process.

336
00:26:36,310 --> 00:26:41,800
We created a simple ground plane model which we learned how to include within our SDA file so that we

337
00:26:41,800 --> 00:26:45,340
can keep all the code related to our models separate from our world file.

338
00:26:45,610 --> 00:26:51,460
We also ran through the intro tutorial of an example simulation of a robot on a playground that used

339
00:26:51,460 --> 00:26:57,940
a LIDAR sensor, and so how Ignition Gazebo has its own ecosystem of commands and topics which we can

340
00:26:57,970 --> 00:26:59,860
then bridge into ROS.

341
00:26:59,860 --> 00:27:05,380
So in the next lecture we'll be taking a closer look at how we can implement sensors and plug ins into

342
00:27:05,380 --> 00:27:10,210
our SDF files to make them much more useful for us as robotics developers.
