1
00:00:00,660 --> 00:00:06,570
In the last two lectures, we started using the ignition gazebo simulation and customizing our own simulation

2
00:00:06,570 --> 00:00:11,430
by creating PDF files to customize our simulation world and models.

3
00:00:11,610 --> 00:00:16,590
At the time of this recording, Ignition Gazebo does not have a built in model editor, so we'll be

4
00:00:16,590 --> 00:00:20,340
using the older Gazebo Classic to make our robot model.

5
00:00:20,760 --> 00:00:26,370
There are other three D design and CAD software you could use to export into the PDF format, but I'll

6
00:00:26,370 --> 00:00:30,840
try to keep this section constrained to Gazebo and ROS as much as possible.

7
00:00:32,300 --> 00:00:36,830
So for the time being, we can head over to the Gazebo Classic installation page.

8
00:00:36,860 --> 00:00:41,930
The easiest way to go about installing the Zeebo is by running the installation script directly from

9
00:00:41,930 --> 00:00:43,610
the website like so.

10
00:00:44,540 --> 00:00:45,200
Down below.

11
00:00:45,200 --> 00:00:49,970
There are alternative installation methods which you can try out if the insulation script fails for

12
00:00:49,970 --> 00:00:50,900
some reason.

13
00:00:50,900 --> 00:00:54,800
But I'm just going to go ahead and install it like so.

14
00:01:00,890 --> 00:01:02,170
Don't have to put in your password.

15
00:01:09,200 --> 00:01:11,120
And after a bit, that should have installed.

16
00:01:11,120 --> 00:01:12,320
So go ahead and clear the screen.

17
00:01:14,810 --> 00:01:19,280
So now we can go ahead and start Gazebo Classic by simply typing in Gazebo.

18
00:01:25,100 --> 00:01:25,400
All right.

19
00:01:25,400 --> 00:01:26,930
So it appeared behind my terminal.

20
00:01:26,930 --> 00:01:28,730
So this is a gazebo by default.

21
00:01:28,730 --> 00:01:30,980
There is nothing in our scene to navigate.

22
00:01:30,980 --> 00:01:31,370
Gazebo.

23
00:01:31,400 --> 00:01:33,800
Use your left mouse button to pan around the scene.

24
00:01:33,800 --> 00:01:39,140
The right mouse button or scroll wheel to zoom in or out, and then shift left click or press the scroll

25
00:01:39,140 --> 00:01:42,500
wheel button to rotate around a point in the scene.

26
00:01:43,310 --> 00:01:47,330
Gazebo has a series of pre-made models which you can use in your simulations.

27
00:01:47,330 --> 00:01:54,380
If I select insert mode, we can go ahead and head over to the model's gazebo sim dot org dropdown.

28
00:01:54,380 --> 00:02:00,260
This might take a while to load if you've just installed gazebo to connect to the database, but essentially

29
00:02:00,260 --> 00:02:03,800
this dropdown allows me to download these models from Gazebos website.

30
00:02:03,800 --> 00:02:08,390
I can go ahead and select the ambulance and once that's gone ahead and download it, I'll go ahead and

31
00:02:08,390 --> 00:02:09,620
zoom out with my scroll wheel.

32
00:02:09,620 --> 00:02:14,960
We can see I can place it within my scene so I can just go ahead and left click and now it's within

33
00:02:14,960 --> 00:02:16,520
my simulation.

34
00:02:16,550 --> 00:02:20,000
So feel free to check out the other models that are available.

35
00:02:20,000 --> 00:02:20,810
So great.

36
00:02:20,810 --> 00:02:23,330
With that, we have imported a new model in our simulation.

37
00:02:23,330 --> 00:02:26,600
Now this model is actually very basic, so the wheels don't even spin.

38
00:02:26,600 --> 00:02:32,330
It's just it's essentially a cube wrapped with this ambulance skin, so you're not able to drive it

39
00:02:32,330 --> 00:02:32,960
around.

40
00:02:32,960 --> 00:02:36,470
But we could create our own model which would allow us to do that.

41
00:02:36,590 --> 00:02:37,910
So go ahead and click on this ambulance.

42
00:02:37,910 --> 00:02:41,680
You can either hit the delete key on your keyboard or just right click and delete.

43
00:02:41,690 --> 00:02:48,560
Then if we head over to the edit toolbar tab, I can select model editor and here we can create a model

44
00:02:48,560 --> 00:02:50,720
using basic three D shapes.

45
00:02:50,720 --> 00:02:56,500
Let's make a super basic model that is just a box with two wheels and a sphere to act as a caster.

46
00:02:56,510 --> 00:02:58,820
So first is to add a cube.

47
00:02:58,820 --> 00:03:05,000
So if I go over to this left panel here, select box, I can go ahead and place it down in my simulation.

48
00:03:06,940 --> 00:03:11,650
Now, if I double click on this box, I can edit this properties within the link Inspector tab.

49
00:03:11,650 --> 00:03:15,640
So within the link tab I can scroll down to edit its posts.

50
00:03:15,670 --> 00:03:20,560
Now keep in mind there are two post sections which might be a little bit confusing, so there is a post

51
00:03:20,560 --> 00:03:22,630
subsection within inertial tab.

52
00:03:22,630 --> 00:03:25,270
So usually I just like to close that so I don't get confused.

53
00:03:25,270 --> 00:03:31,840
And here we just see the standard post tab which controls where our square is within the simulation

54
00:03:31,840 --> 00:03:33,030
world coordinates.

55
00:03:33,040 --> 00:03:37,660
So for example, I can try and center it so I can go ahead and put it at zero zero.

56
00:03:40,320 --> 00:03:45,870
Then besides the link tab, we have the visual and collision tabs, so go ahead and expand those.

57
00:03:45,870 --> 00:03:52,020
And basically this is what's going to dictate our properties for how these things look and act within

58
00:03:52,020 --> 00:03:53,010
the simulation.

59
00:03:53,160 --> 00:03:58,680
So here within the visual tab, I can scroll down to geometry and I can change the X, y, Z attributes

60
00:03:58,680 --> 00:04:00,330
of this cube.

61
00:04:00,510 --> 00:04:07,650
So in this case, I can go ahead and set the Y and Z parameters 2.5 meters to make this look more like

62
00:04:07,650 --> 00:04:08,750
a rectangle.

63
00:04:08,760 --> 00:04:13,890
So in the main window we can see our changes, but you notice there's a transparent outline of the original

64
00:04:13,890 --> 00:04:14,510
cube.

65
00:04:14,520 --> 00:04:16,680
Well, that's actually the collision model we are looking at.

66
00:04:16,680 --> 00:04:18,600
So if I switch to the collision tab.

67
00:04:19,740 --> 00:04:24,090
There is again a geometry subtab in which we'd have to change the attributes again.

68
00:04:24,090 --> 00:04:29,820
So sometimes you'll have a visual model which has a rap or looks slightly different compared to the

69
00:04:29,820 --> 00:04:33,890
collision model, which you may simplify or have be slightly modified.

70
00:04:33,900 --> 00:04:36,120
But for now I'm just going to set it to be the same thing.

71
00:04:36,120 --> 00:04:41,700
So 0.5 Y and 0.54 Z, and now we see that matches up.

72
00:04:41,700 --> 00:04:45,270
So this collision model is what's used for the physics engine rendering.

73
00:04:45,270 --> 00:04:49,770
This way you could create a complicated visual appearance, but keep the collision model which will

74
00:04:49,770 --> 00:04:52,290
have physics applied to it in a simple manner.

75
00:04:52,290 --> 00:04:54,360
So moving on, I'll go ahead and hit OC.

76
00:04:54,720 --> 00:04:58,830
So now I'll go ahead and make my two wheels using cylinders.

77
00:04:58,830 --> 00:05:03,540
I will double click on it, edit its pose so we can turn it on its side again.

78
00:05:03,540 --> 00:05:04,830
Remember that there's two poses.

79
00:05:04,830 --> 00:05:08,970
One is for the inertial physics calculation, so be sure to leave that as is.

80
00:05:08,970 --> 00:05:14,370
So go ahead and collapse that and we can head down to the pose that's in its own section and I can change

81
00:05:14,370 --> 00:05:22,650
the roll to 1.570796 radians, which roughly equates to 90 degrees of rotation.

82
00:05:22,830 --> 00:05:24,960
Now we see the cylinder has rotated.

83
00:05:24,960 --> 00:05:31,500
Now I will edit the size of the cylinder by changing the length to 0.25 meters in both the visual and

84
00:05:31,500 --> 00:05:32,580
collisions tab.

85
00:05:37,940 --> 00:05:44,090
So now I have my wheel and you could go ahead and move it however you want in the simulation to configure

86
00:05:44,090 --> 00:05:48,310
where you want to place it relative to your other components.

87
00:05:48,320 --> 00:05:53,170
So I'm actually going to go ahead and double click on this and place it where I want to.

88
00:05:53,480 --> 00:05:56,540
So if I go back into link and into pose.

89
00:05:57,670 --> 00:06:00,880
Set this to -0.375.

90
00:06:01,720 --> 00:06:05,110
-0.4 and 0.5.

91
00:06:06,710 --> 00:06:11,900
And so this now acts as a type of back wheel for our robot.

92
00:06:11,930 --> 00:06:14,540
On the right side, if that's the front.

93
00:06:16,050 --> 00:06:22,560
So I can go ahead and hit OC and now I can duplicate this wheel by clicking on it and right, clicking,

94
00:06:22,560 --> 00:06:25,920
doing copy and we can right click and paste.

95
00:06:26,070 --> 00:06:34,500
And now I have a cylinder with the same attributes and I'll go ahead and click on it and edit its position.

96
00:06:35,380 --> 00:06:35,860
Again.

97
00:06:35,860 --> 00:06:37,840
Don't edit the inertial posts.

98
00:06:37,870 --> 00:06:39,070
Close this tab.

99
00:06:39,220 --> 00:06:40,450
This is the pose we want to edit.

100
00:06:45,620 --> 00:06:46,130
All righty.

101
00:06:46,130 --> 00:06:50,810
Now, to complete this model, I'm going to go ahead and add in the sphere caster.

102
00:06:51,170 --> 00:06:53,750
So I'll go ahead and add a sphere.

103
00:06:54,590 --> 00:06:57,950
And set the size to 0.25 metres.

104
00:07:06,300 --> 00:07:06,640
All right.

105
00:07:06,660 --> 00:07:09,270
So I've gone ahead and done that and I'm actually going to replace the sphere.

106
00:07:09,270 --> 00:07:12,030
So it's at the front of our robot chassis.

107
00:07:18,850 --> 00:07:22,070
All right, So now I've gone ahead and place it in my simulation.

108
00:07:22,090 --> 00:07:25,180
Now, the other thing I'm actually going to do is I'm going to double click on this one more time and

109
00:07:25,180 --> 00:07:26,290
go into collision.

110
00:07:26,290 --> 00:07:31,570
And if we scroll down, we'll see there's surface friction for these attributes on how we want this

111
00:07:31,570 --> 00:07:33,820
to interact within our simulation.

112
00:07:33,820 --> 00:07:37,960
So we want this to nicely slide against the ground plane.

113
00:07:37,960 --> 00:07:43,300
So I'm going to have to set these friction variables MU and mu two to be something smaller because the

114
00:07:43,300 --> 00:07:48,040
value of one is similar to having a very rough surface, which is hard to slide across.

115
00:07:48,040 --> 00:07:50,410
So I want this to be more of a smooth interaction.

116
00:07:50,410 --> 00:07:54,790
So I'll go ahead and cut this down to say 0.1 for both of them.

117
00:07:57,990 --> 00:07:59,640
So go ahead and hit Ock.

118
00:07:59,970 --> 00:08:03,720
And to make this look a little bit less awkward, I'm actually going to extend my cube out a little

119
00:08:03,720 --> 00:08:04,170
bit.

120
00:08:07,040 --> 00:08:13,760
So I'll set the X direction to instead be 1.5 and make sure to change it in the collision tab as well.

121
00:08:15,930 --> 00:08:17,130
Okay, that looks a little bit better.

122
00:08:17,130 --> 00:08:23,820
So we have this little rectangular chassis with two wheels and a spherical caster meant for sliding.

123
00:08:24,060 --> 00:08:29,220
Now we have to create joints in order for these different shapes to be combined together.

124
00:08:29,220 --> 00:08:32,790
So we can do this by selecting the joint icon in the top.

125
00:08:36,600 --> 00:08:40,200
Then we'll have to choose our parent link, which in this case is our box.

126
00:08:40,200 --> 00:08:44,540
And then the child will be the wheel, which in this case is closer to me.

127
00:08:44,550 --> 00:08:46,830
So the back right wheel.

128
00:08:47,740 --> 00:08:51,310
So above we can see it selected as a resolute type.

129
00:08:51,310 --> 00:08:56,290
We could change this to one of the other available joints, but note that fixed, resolute and prismatic

130
00:08:56,290 --> 00:08:57,910
are the most supported joints.

131
00:08:57,910 --> 00:09:03,610
If you wanted to control these joints and Ross, I will leave it as resolute and I will select negative

132
00:09:03,610 --> 00:09:06,400
Z axis for the rotation.

133
00:09:08,640 --> 00:09:12,210
So you can actually see how this changes in our.

134
00:09:13,610 --> 00:09:14,960
X, Y, and Z.

135
00:09:15,310 --> 00:09:19,490
So now we have this yellow axis pointing here in our axis of rotation.

136
00:09:20,890 --> 00:09:25,330
I'll go ahead and hit, create and do the same thing for our other wheel.

137
00:09:35,520 --> 00:09:36,240
Then last thing.

138
00:09:36,240 --> 00:09:38,940
I need to fix this sphere to the box.

139
00:09:43,220 --> 00:09:46,070
So for joint type we will use type fixed.

140
00:09:46,070 --> 00:09:52,070
So we don't need to worry about any axes of rotation because it's just going to stay right there.

141
00:09:52,110 --> 00:09:53,270
And I'll go ahead and hit create.

142
00:09:54,830 --> 00:09:55,280
All right.

143
00:09:55,280 --> 00:10:01,400
That about covers it for this simple model so I can go to file and exit model editor, and it's going

144
00:10:01,400 --> 00:10:03,320
to ask if you want to save changes before exiting.

145
00:10:03,320 --> 00:10:06,320
So we're going to go ahead and hit, save and exit.

146
00:10:06,320 --> 00:10:11,570
And here we see we're going to be naming our model where it gets saved by default in our home folder

147
00:10:11,570 --> 00:10:14,030
in a folder called Model Editor Models.

148
00:10:14,030 --> 00:10:19,850
So I'm just going to go ahead and call this wheeled model and hit save.

149
00:10:22,030 --> 00:10:25,720
Once I hit Save, we are now back in our simulation world.

150
00:10:27,210 --> 00:10:33,540
If I go over to the left panel, we now see that the wheel model is part of our list of models, and

151
00:10:33,540 --> 00:10:38,280
it shows all of our individual links as well as joint relationships.

152
00:10:38,310 --> 00:10:42,780
If I wanted to interact with these joints, I can drag out the right panel here that's hidden.

153
00:10:43,830 --> 00:10:49,260
And if I select my robot, we can actually see we can interact with each joint by either applying a

154
00:10:49,260 --> 00:10:52,980
force, setting a position or a velocity.

155
00:10:53,010 --> 00:10:57,930
So before I set everything, I will make sure my simulation is paused, which you can check by looking

156
00:10:57,930 --> 00:11:01,330
at the bottom left where we see this is still the play button.

157
00:11:01,350 --> 00:11:02,940
Our timer is not playing.

158
00:11:03,300 --> 00:11:09,430
So I'll go ahead and set the velocity for the first two joints to one meter per second.

159
00:11:09,450 --> 00:11:14,490
Then on the right, I can set the values of the PID controller, which will try to apply the force of

160
00:11:14,490 --> 00:11:16,570
the wheel to get it to maintain that speed.

161
00:11:16,590 --> 00:11:19,500
In this case, I'll increase the gain to three for both of them.

162
00:11:19,530 --> 00:11:25,200
Now, if I go ahead and play the simulation, we should see the model begin to drive because we are

163
00:11:25,200 --> 00:11:29,040
turning the wheels with this particular velocity.

164
00:11:29,520 --> 00:11:29,970
Great.

165
00:11:29,970 --> 00:11:33,180
With that we are able to set our wheels to move at a certain rate.

166
00:11:33,210 --> 00:11:34,830
I'll go ahead and pause this for now.

167
00:11:34,830 --> 00:11:39,660
If I wanted to spin our robot around, I could change the speed to be negative on one wheel in order

168
00:11:39,660 --> 00:11:42,180
to make our little wheeled bot turn.

169
00:11:42,210 --> 00:11:43,560
So now if I hit play.

170
00:11:44,330 --> 00:11:51,110
We see it is now rotating because one wheel is going forward and the other wheel is going backwards.

171
00:11:53,700 --> 00:12:00,210
If I wanted to place the robot back to the way it was, I can go to edit and select reset model poses

172
00:12:00,210 --> 00:12:03,250
and that will place it back at the center of my simulation.

173
00:12:03,270 --> 00:12:08,070
Anyway, this is a good introduction to Gazebo Classic for those of you who have not used it before,

174
00:12:08,070 --> 00:12:14,160
and hopefully more of these features that you're seeing here get included into the newer ignition gazebo

175
00:12:14,160 --> 00:12:15,150
interface.

176
00:12:15,150 --> 00:12:21,600
For now, we have an SDF of our simple wheeled robot model, so I'll go ahead and close out of Gazebo

177
00:12:21,600 --> 00:12:22,410
Classic.

178
00:12:24,960 --> 00:12:26,880
You know, we'll go ahead and close our browser.

179
00:12:27,960 --> 00:12:30,030
Now I'll open up the file Explorer.

180
00:12:30,450 --> 00:12:39,000
And here in our home folder, we have a model editor models folder which contains our wheeled modeled

181
00:12:39,000 --> 00:12:43,140
robot folder that has the SDF and config file.

182
00:12:43,290 --> 00:12:50,940
Now, go ahead and take this model, copy it over and place it into our ROS package within the models

183
00:12:50,940 --> 00:12:51,600
folder.

184
00:12:56,180 --> 00:13:02,330
So here we have our ground plane from earlier and now we have this wheeled model within our package.

185
00:13:02,360 --> 00:13:09,380
Now let's open up V's code and create a new PDF World file to include this model in our underworld.

186
00:13:09,410 --> 00:13:15,020
I'll hit new file and I'm just going to call this new file wheeled model world that SDF.

187
00:13:16,490 --> 00:13:19,610
Then I'll copy over the contents from our test world from earlier.

188
00:13:21,520 --> 00:13:27,070
And I'll paste it in and I'm going to delete the camera model that we were playing with earlier so that

189
00:13:27,070 --> 00:13:33,850
our environment only contains this ground plane and a sun model and our normal plug ins.

190
00:13:35,530 --> 00:13:38,770
And now we'll include our wheeled robot model.

191
00:13:46,260 --> 00:13:53,040
So now I'll go ahead and save this and open up our terminal and set up our gazebo environment variable.

192
00:14:05,290 --> 00:14:09,100
And let's go ahead and run our wheeled model world file.

193
00:14:13,920 --> 00:14:18,030
So here we see our model partly wedged into the ground here.

194
00:14:18,270 --> 00:14:21,870
So I can just go into translate mode and pull it out of the ground.

195
00:14:23,690 --> 00:14:31,340
But we indeed see that the model we created in Gazebo Classic is able to transfer over to Ignition Gazebo.

196
00:14:31,370 --> 00:14:35,660
So in this lecture off, let's take a quick look at how we can use plug ins to allow us to use the joints

197
00:14:35,660 --> 00:14:36,350
that we made.

198
00:14:36,350 --> 00:14:40,550
To show an example of this, we can check out the diff drive example PSD file.

199
00:14:43,770 --> 00:14:47,970
So again, here is the world directory with the example PDF files from earlier.

200
00:14:47,970 --> 00:14:49,980
So again, go into other locations.

201
00:14:49,980 --> 00:14:54,920
Computer user share, Ignition, Ignition, gazebo, six and Worlds.

202
00:14:54,930 --> 00:15:00,230
And the file that we're interested in this time around will be diff drive dot SDF.

203
00:15:00,240 --> 00:15:03,720
So I'm going to go ahead and open this in a standard text editor.

204
00:15:03,990 --> 00:15:09,390
Now let's also go ahead and launch this in ignition just so that you can see what this file entails

205
00:15:09,390 --> 00:15:10,740
within the simulation.

206
00:15:17,810 --> 00:15:18,110
All right.

207
00:15:18,110 --> 00:15:23,810
So here we see two wheeled models somewhat similar to what we just made.

208
00:15:23,840 --> 00:15:26,330
So if I go ahead and hit play, nothing really happens.

209
00:15:26,330 --> 00:15:31,990
But we can actually go ahead and control these two robots by publishing messages to them.

210
00:15:32,000 --> 00:15:35,570
And if we can control it through ignition, you already know we can just bridge the topic to work in

211
00:15:35,570 --> 00:15:37,570
ROS using the parameter bridge.

212
00:15:37,580 --> 00:15:43,610
But for now we will just try this out by copying the command that it actually shows within the top of

213
00:15:43,610 --> 00:15:44,180
the file.

214
00:15:44,180 --> 00:15:47,510
So here it says Differential drive plug in demo.

215
00:15:47,510 --> 00:15:52,250
Try sending the commands ignition topic dashed and you specify the topic, which in this case we're

216
00:15:52,250 --> 00:15:55,790
commanding the blue vehicle from the command velocity topic.

217
00:15:56,120 --> 00:16:02,720
The message type is a twist message, and we're publishing a linear and angular part to twist.

218
00:16:02,720 --> 00:16:08,120
And in this case we're saying go forward in the x direction 0.5 meters a second about and give it an

219
00:16:08,120 --> 00:16:12,500
angular velocity in the Z axis direction of 0.05.

220
00:16:12,500 --> 00:16:14,750
So I'll go ahead and copy this.

221
00:16:15,530 --> 00:16:17,030
Open a second terminal.

222
00:16:19,760 --> 00:16:22,220
And I'll go ahead and run this message.

223
00:16:23,840 --> 00:16:32,030
And now we see this purple robot moving forward and slightly to the left since we had that Z angular

224
00:16:32,030 --> 00:16:33,290
aspect to it.

225
00:16:35,120 --> 00:16:40,940
And now if I go ahead and go up and set these back to zero, I.

226
00:16:44,500 --> 00:16:47,470
We should see that the model stops moving.

227
00:16:48,610 --> 00:16:54,520
And again, this particular simulation is set up with a blue vehicle and a green vehicle with these

228
00:16:54,520 --> 00:16:59,650
topics already nicely set up for us so we could go ahead and move the second vehicle if we wanted to

229
00:16:59,650 --> 00:17:01,180
by simply changing that name.

230
00:17:01,780 --> 00:17:08,530
And I'll just go forward in this case a little bit and change it from blue to green.

231
00:17:11,730 --> 00:17:16,470
And now we see the green robot moving directly forward.

232
00:17:16,470 --> 00:17:22,350
And again, we can stop this by changing all the values to zero and publishing it again.

233
00:17:22,710 --> 00:17:22,980
All right.

234
00:17:22,980 --> 00:17:27,540
For now, go ahead and pause the simulation and we're going to head back to the C file so we can see

235
00:17:27,540 --> 00:17:29,420
how this plugin is implemented.

236
00:17:29,430 --> 00:17:33,510
So this plugin is called twice in this file one for each robot, but for now I'm just going to scroll

237
00:17:33,510 --> 00:17:38,250
all the way down to the bottom where the second declaration is, since it's easiest to navigate to.

238
00:17:39,260 --> 00:17:47,870
So here within this secondary model tags, right, we have a plugin called Ignition Gazebo Diff Drive

239
00:17:47,870 --> 00:17:51,290
System and it points to the particular driver.

240
00:17:51,290 --> 00:17:56,600
And here we see a couple of attributes such as the left, joint right, joint wheel separation wheel

241
00:17:56,600 --> 00:18:01,820
radius and as well as some max and minimums for acceleration and velocity.

242
00:18:02,120 --> 00:18:06,080
If you want more info on the available parameters for the diff drive plugin, you can check out the

243
00:18:06,080 --> 00:18:11,040
gazebo Simu GitHub repository and check out the comments in the diff drive header file.

244
00:18:11,060 --> 00:18:17,880
But for now, let's implement this plugin into our wheeled robot model we created to make it more interactive.

245
00:18:17,900 --> 00:18:19,850
So I'll copy this code snippet.

246
00:18:23,720 --> 00:18:30,230
And put it towards the end of the model file of our wheeled model.

247
00:18:32,260 --> 00:18:37,150
Now, if you ever get errors like this, some of the namespaces for HTML does not match up.

248
00:18:37,360 --> 00:18:43,240
So all we have to do is set this back to XML and we lose some of that functionality to automatically

249
00:18:43,240 --> 00:18:48,820
autocomplete some scripting for us, but at least it will get rid of that those red error message lines.

250
00:18:48,820 --> 00:18:50,830
But I'll go ahead and scroll all the way down.

251
00:18:53,320 --> 00:18:58,510
And right before the model tag ends, we'll go ahead and paste in our plugin.

252
00:18:59,230 --> 00:19:02,230
So now I'll go ahead and change the parameters to match our setup.

253
00:19:02,230 --> 00:19:07,360
So if you follow along with my setup, each wheel was 0.4 meters away from the origin, so my wheel

254
00:19:07,360 --> 00:19:13,150
separation is 0.8 meters and I'll set the wheel radius to 0.5.

255
00:19:13,420 --> 00:19:17,560
Then our joint names were automatically created in the gazebo model editor.

256
00:19:17,950 --> 00:19:19,810
So if we scroll up to the top.

257
00:19:24,200 --> 00:19:27,800
We can see after our model tag we have a link tag.

258
00:19:27,920 --> 00:19:30,530
This link is the box we started off with.

259
00:19:30,560 --> 00:19:32,930
As we can see specified in the geometry tag.

260
00:19:33,110 --> 00:19:36,940
So let's do some renaming in this file so that it makes a bit more sense.

261
00:19:36,950 --> 00:19:42,050
So if I hit control H in V's code, this will pull up the find and replace window.

262
00:19:42,110 --> 00:19:49,790
You could also go into the edit tab and go to replace and let's rename link zero so it makes more sense.

263
00:19:49,790 --> 00:19:55,280
In this case I will name it to chassis since this box acts like a robot chassis that everything is mounted

264
00:19:55,280 --> 00:19:55,730
to.

265
00:19:56,000 --> 00:20:00,680
And the reason we are utilizing this replace all functionality is we want to make sure we keep together

266
00:20:00,680 --> 00:20:02,540
all of our linked connections.

267
00:20:02,540 --> 00:20:06,950
So all of our joints which are utilizing these link names, we want to make sure that these all get

268
00:20:06,950 --> 00:20:08,320
changed correctly.

269
00:20:08,330 --> 00:20:10,160
So I'll just go ahead and hit replace all.

270
00:20:10,760 --> 00:20:13,070
And if you're unsure, you could actually go ahead and check this.

271
00:20:13,070 --> 00:20:16,040
So here we see the joint name link zero to Joint zero.

272
00:20:16,040 --> 00:20:22,490
So now it'll change it to chassis to join zero and it'll change the parent name link zero to match chassis

273
00:20:22,490 --> 00:20:25,760
and it does that for each of our corresponding joints.

274
00:20:25,760 --> 00:20:27,830
So I'll go ahead and hit replace all.

275
00:20:28,460 --> 00:20:33,470
So now if we go over to the next link, it should be called Link one.

276
00:20:33,740 --> 00:20:36,370
And this is the first will we put onto our robot.

277
00:20:36,380 --> 00:20:41,120
So if you consider the cluster as a part of the front of the robot, I believe I started with the right

278
00:20:41,120 --> 00:20:44,240
wheel so I can change it as such.

279
00:20:47,140 --> 00:20:52,750
So now notice if we hit this arrow button, we see another link called Link one clone.

280
00:20:53,110 --> 00:20:58,350
Now, that's because I clone the original link, which was our wheel to create a secondary wheel.

281
00:20:58,360 --> 00:21:05,590
So actually what I'll go ahead and do is go to link one and set it to underscore clone so that we only

282
00:21:05,590 --> 00:21:10,090
get two of these matches and set that to our corresponding left wheel link.

283
00:21:10,960 --> 00:21:16,450
And now the normal link one will be our right, we'll link.

284
00:21:17,860 --> 00:21:23,290
And again, it's just the name of the link that's changing and the child parameter within our joints.

285
00:21:24,070 --> 00:21:31,240
Then our last link should be link two, which is our caster, so I can just change it as such.

286
00:21:33,470 --> 00:21:34,370
Great with that.

287
00:21:34,370 --> 00:21:36,980
All of our linked names make a bit more sense.

288
00:21:36,980 --> 00:21:42,110
So now let's take a look back at our joint names from our Diff drive plugin.

289
00:21:42,710 --> 00:21:48,650
So here it's looking for the left joint with a name left wheel joint so we can change this to match

290
00:21:48,650 --> 00:21:50,900
or if we go back to our joints.

291
00:21:53,770 --> 00:21:59,050
We can see here Joint zero, joint one and joint two and what each one is doing.

292
00:22:00,680 --> 00:22:03,440
So we can see chassis joint zero.

293
00:22:03,470 --> 00:22:06,350
He's combining the chassis to the right.

294
00:22:06,350 --> 00:22:13,670
We'll link so we can just simply change the name for simplicity to right wheel joint.

295
00:22:19,210 --> 00:22:24,220
And we can go down to our second joint, which combines the chassis and the left wheel link and we can

296
00:22:24,220 --> 00:22:27,520
just simply change it to left wheel joint.

297
00:22:28,450 --> 00:22:35,020
Now we can make sure that these names match up with what we have here for our ignition gazebo plug in,

298
00:22:35,020 --> 00:22:37,780
which in this case I actually made them a match.

299
00:22:37,780 --> 00:22:44,290
So left wheel joint here corresponds to the left wheel joint that we have here within the model PSD

300
00:22:44,470 --> 00:22:47,080
file, which combines the chassis and left wheel link.

301
00:22:47,080 --> 00:22:52,660
So ideally, this driver will now take control of that particular wheel whenever it needs to.

302
00:22:52,760 --> 00:22:55,390
Last thing I want to do here is set a post for our robot.

303
00:22:55,390 --> 00:22:59,520
Since if you remember when we launched our simulation, our robot was partially in the ground.

304
00:22:59,530 --> 00:23:06,220
So I'll go ahead and save this model file and head over to our wheeled model world file and I will add

305
00:23:06,220 --> 00:23:13,410
a post tag right after the include tag to put us half a metre off the ground in the Z direction.

306
00:23:13,420 --> 00:23:18,250
So again, each number represents X, y, z position followed by roll, pitch, yaw.

307
00:23:18,850 --> 00:23:19,180
All right.

308
00:23:19,180 --> 00:23:24,490
We'll go ahead and save everything and relaunch our wheeled model world simulation file.

309
00:23:32,680 --> 00:23:38,800
So here we see our total ground plane and our wheeled model we created in gazebo.

310
00:23:40,430 --> 00:23:43,490
So I'll go ahead and clear this second screen here.

311
00:23:43,760 --> 00:23:48,410
So we can control this robot by using the ignition topic command we had used earlier.

312
00:23:48,410 --> 00:23:49,970
But change the topic name.

313
00:23:49,970 --> 00:23:56,360
So if I hit up, we can see we use this ignition topic to model vehicle green command velocity.

314
00:23:56,360 --> 00:24:02,240
So by default, if you check out the GitHub repo notes, if you don't specify a topic within the parameters,

315
00:24:02,240 --> 00:24:03,320
this simply gets changed.

316
00:24:03,320 --> 00:24:08,720
The name of our model, which in this case is just called wheeled model here.

317
00:24:11,850 --> 00:24:18,720
So let's go ahead and change the X parameter to 0.5 so that we can drive forward and we will change

318
00:24:18,720 --> 00:24:21,930
vehicle green to wheeled model.

319
00:24:22,620 --> 00:24:24,060
So go ahead and publish that.

320
00:24:24,630 --> 00:24:30,630
Now, of course, to make sure the simulation is playing and we see our robot goes down and starts driving

321
00:24:30,630 --> 00:24:31,440
forward.

322
00:24:31,450 --> 00:24:36,120
And of course we can always stop it by setting this to zero.

323
00:24:37,380 --> 00:24:38,340
And there we go.

324
00:24:38,340 --> 00:24:39,990
The model stops.

325
00:24:40,020 --> 00:24:43,260
Now, currently we are controlling this robot with ignition commands.

326
00:24:43,260 --> 00:24:49,650
So all we have to do to port this over to Ros is use the ignition gazebo bridge and specify the corresponding

327
00:24:49,680 --> 00:24:50,490
topic.

328
00:24:50,520 --> 00:24:56,580
Basically, we are taking the ignition topic and then the ampersand symbol, then the ROS message type,

329
00:24:56,670 --> 00:24:58,590
which in this case is the twist.

330
00:24:58,590 --> 00:25:01,590
Message type is from geometry messages ROS package.

331
00:25:01,590 --> 00:25:06,150
And then I'll include another symbol and then the ignition message type.

332
00:25:06,510 --> 00:25:12,210
Then I'm passing in ros args with the dash r flag which is remapping the topic name from the current

333
00:25:12,210 --> 00:25:15,360
topic name to just command velocity.

334
00:25:15,810 --> 00:25:20,460
Keep in mind the ampersand symbol between the ROS message and the ignition message means that communication

335
00:25:20,460 --> 00:25:24,630
can come over and received between Ros and an ignition over this topic.

336
00:25:24,630 --> 00:25:28,530
Whereas if I only use the left square bracket, that means I can only receive messages from ignition

337
00:25:28,530 --> 00:25:29,340
to ROS.

338
00:25:29,340 --> 00:25:33,710
And the right bracket means only messages from Ros get sent to ignition.

339
00:25:33,720 --> 00:25:37,140
I just do the ampersand symbol for both because it's easier for me to remember.

340
00:25:37,140 --> 00:25:40,650
But just keep that in mind if you ever want to restrict which way data flows.

341
00:25:40,650 --> 00:25:44,130
So I'll go ahead and run this, then open a third terminal window.

342
00:25:47,120 --> 00:25:50,090
And we should be able to see this new command of topic.

343
00:25:52,400 --> 00:25:54,270
Which we do right here.

344
00:25:54,290 --> 00:25:58,070
So for simplicity, I'm going to open up our cut and publish this topic.

345
00:26:00,680 --> 00:26:03,310
So go ahead and close our image plugin from the last lecture.

346
00:26:03,610 --> 00:26:08,380
Head over to topics message publisher and refresh our topic list.

347
00:26:08,410 --> 00:26:11,020
Head over to command, fill the addition symbol.

348
00:26:11,170 --> 00:26:17,500
And now if we hit these dropdowns, we have the linear and angular portions of our topic, so I'll go

349
00:26:17,500 --> 00:26:19,120
ahead and minimize this a bit.

350
00:26:23,110 --> 00:26:26,890
And now let's go ahead and set the speed to say 0.5.

351
00:26:28,330 --> 00:26:32,950
And as soon as I hit the check mark, this will begin publishing and we should see our robot move.

352
00:26:33,460 --> 00:26:35,710
And I can set this back to zero again.

353
00:26:36,100 --> 00:26:38,880
And if we wanted to, we could make our robot spin for fun.

354
00:26:38,890 --> 00:26:44,650
So if I set this Z aspect to one, we should see our robot rotate around.

355
00:26:44,650 --> 00:26:48,790
And if I hit negative one, we will go in the opposite direction.

356
00:26:50,250 --> 00:26:57,000
And of course, we can add multiple components at the same time to have our robot both try to drive

357
00:26:57,150 --> 00:26:59,780
and spin around at the same time.

358
00:26:59,790 --> 00:27:03,120
Now I guess it's wants to spin around more than it wants to move.

359
00:27:07,820 --> 00:27:08,560
So there we go.

360
00:27:08,660 --> 00:27:11,960
We can see it's just slightly reversing and slightly wanting to turn.

361
00:27:11,960 --> 00:27:15,140
And of course, I'm going to set these both to zero.

362
00:27:16,710 --> 00:27:19,470
So congratulations on making it through this lecture.

363
00:27:19,470 --> 00:27:25,830
I know it was quite the stretch from making our model in the Gazebo Classic editor to learning about

364
00:27:25,830 --> 00:27:31,710
the differential drive plug in to then implementing that plug in into our model we made to then bridging

365
00:27:31,710 --> 00:27:37,710
the ignition topic that interacts with the plug in over Ros using the ignition parameter bridge.

366
00:27:38,010 --> 00:27:43,290
Just a reminder that if you want to check out more built in plug ins, check out the gazebo sim and

367
00:27:43,290 --> 00:27:45,960
gazebo sensors, GitHub repos.
