1
00:00:01,020 --> 00:00:01,430
OK.

2
00:00:02,640 --> 00:00:12,120
In this material, we will try to apply this transformation mattresses, which contains also rotation

3
00:00:12,120 --> 00:00:22,320
mattresses inside and also, you know, other angles, ends like this into practice by this video,

4
00:00:22,320 --> 00:00:30,930
I would like to show you how much important and how useful can be the concepts that we have learned

5
00:00:30,930 --> 00:00:31,890
in this chapter.

6
00:00:32,340 --> 00:00:35,220
So let's start for in this tutorial.

7
00:00:35,520 --> 00:00:42,870
I will try to I will try to apply what we have learned or simulate the environment in ROS.

8
00:00:43,920 --> 00:00:52,630
As you know, I don't know whether you know or not, but it is very important for you to know or else

9
00:00:52,650 --> 00:00:58,530
or rules because it is used in robotics very widely.

10
00:00:59,190 --> 00:01:00,900
So you have to know this.

11
00:01:01,200 --> 00:01:08,130
This is not an option, but you have to know this if you want to simulate or coordinate robots, or

12
00:01:09,180 --> 00:01:12,540
how can I say or you want to write software for them?

13
00:01:12,630 --> 00:01:24,300
You have to know this because it contains many of the tools that make your job easier in order to write

14
00:01:24,300 --> 00:01:26,850
software for robots or programmed them.

15
00:01:28,020 --> 00:01:31,800
So that's why you have to learn this during the lesson.

16
00:01:31,800 --> 00:01:38,400
I will apply some concepts in our rules, but I will not teach you the rules.

17
00:01:38,580 --> 00:01:44,550
So you have to learn it by yourself because otherwise the course would be very long.

18
00:01:45,060 --> 00:01:52,410
You can learn it in C++, or you can learn it in Python, but I recommend you to learn in Python because

19
00:01:52,410 --> 00:01:54,210
C++ can be a bit difficult.

20
00:01:54,630 --> 00:02:04,440
But if you know C++, it would also be good because indeed you can apply different modes in our different

21
00:02:05,910 --> 00:02:10,710
programming languages and you can communicate between these nodes.

22
00:02:11,160 --> 00:02:17,670
So, OK, without further ado, let's start to see what first we will do, so we will simulate our program

23
00:02:17,670 --> 00:02:18,610
inside gazebo.

24
00:02:18,630 --> 00:02:25,680
So let's first start our environment, or let's start our environment in gazebo.

25
00:02:25,950 --> 00:02:33,720
So Roseland, first, let me source the environment because this is very important if you don't know

26
00:02:33,750 --> 00:02:34,980
what I am doing here.

27
00:02:36,240 --> 00:02:39,480
You can just watch and see that.

28
00:02:39,480 --> 00:02:40,980
How important is that?

29
00:02:41,910 --> 00:02:46,230
Otherwise, if you want to know, you can learn or else.

30
00:02:46,680 --> 00:02:53,220
But the learning curve of arroyos is steep, so it's a bit difficult.

31
00:02:54,120 --> 00:03:01,890
So I would recommend you to learn the process while also watching this course and programs.

32
00:03:03,030 --> 00:03:04,440
So let's start first.

33
00:03:04,440 --> 00:03:06,550
Let's source the environment below.

34
00:03:06,990 --> 00:03:11,250
Set up the marsh, OK, then roast lunch.

35
00:03:12,460 --> 00:03:17,010
I think you have to be here and tim about three to two.

36
00:03:17,340 --> 00:03:20,280
I will use Turtle about three in the simulation.

37
00:03:21,120 --> 00:03:21,720
OK.

38
00:03:22,560 --> 00:03:27,120
T. Both three, you have to and it is a start robot, not lunch.

39
00:03:28,170 --> 00:03:32,910
But OK, let me first launch the environment.

40
00:03:33,390 --> 00:03:37,750
This will launch otherwise total about three months.

41
00:03:37,760 --> 00:03:39,300
Three Gazebo.

42
00:03:40,170 --> 00:03:45,090
So Turtle bought three books, bought lunch.

43
00:03:45,660 --> 00:03:52,140
I will send you or I will upload this launch file and other programs into GitHub so you can download

44
00:03:52,140 --> 00:03:53,490
it from there and use.

45
00:03:54,750 --> 00:03:57,090
OK, first, let's see our environment.

46
00:03:59,340 --> 00:04:03,380
OK, so we have given a robot, which is Turtle Bot three.

47
00:04:03,810 --> 00:04:05,500
This is a very famous robot.

48
00:04:05,610 --> 00:04:08,520
You can what it is differential drive robot.

49
00:04:09,090 --> 00:04:11,120
And this is our object.

50
00:04:11,130 --> 00:04:12,630
So what's our purpose?

51
00:04:12,660 --> 00:04:14,010
OK, this is our object.

52
00:04:14,340 --> 00:04:15,650
So what's our purpose?

53
00:04:15,660 --> 00:04:18,840
Our purpose is to make turtle bots.

54
00:04:18,840 --> 00:04:23,070
Three Robot this robot to follow this object.

55
00:04:23,100 --> 00:04:24,820
This object is dynamic.

56
00:04:24,840 --> 00:04:31,140
I mean, we can change its position and we want the turtle bots three to follow this object.

57
00:04:31,140 --> 00:04:34,410
So if I put it here, it's come to this point.

58
00:04:34,770 --> 00:04:37,050
If I put it here, it come to this point.

59
00:04:37,500 --> 00:04:45,030
Yeah, this can be seen a bit stupid, but it's very important because this is called go to goal behavior

60
00:04:45,030 --> 00:04:45,900
for robots.

61
00:04:46,290 --> 00:04:49,560
What the what do I mean by go to goal behavior?

62
00:04:49,770 --> 00:04:57,690
So in many tasks, for example, in navigation or for searching something or doing something very different,

63
00:04:57,690 --> 00:04:58,290
I don't know.

64
00:04:59,250 --> 00:04:59,940
We have some.

65
00:05:00,020 --> 00:05:02,540
Coordinates and we want the robot to go this.

66
00:05:02,990 --> 00:05:04,610
This is gold, go to gold.

67
00:05:04,970 --> 00:05:06,860
So go to gold, be here.

68
00:05:06,890 --> 00:05:14,180
We just make robot to go to that point, so it simulates that behavior.

69
00:05:15,260 --> 00:05:16,340
So let's start.

70
00:05:16,340 --> 00:05:19,910
And the first let me see in presentation what we want to do.

71
00:05:20,210 --> 00:05:21,740
OK, let's start with this one.

72
00:05:22,070 --> 00:05:26,530
So we are given our robot, which is circle and square.

73
00:05:26,540 --> 00:05:31,250
Our object, what we want for what we will do.

74
00:05:31,250 --> 00:05:34,380
First, we will assign transformations.

75
00:05:34,400 --> 00:05:40,550
Both of these transformations or excuse me, not transformations, but first coordinate frames.

76
00:05:40,760 --> 00:05:49,460
As we have said before, we first have to assign frames for our objects that we are interested in this

77
00:05:49,460 --> 00:05:51,890
case, our robot and our object.

78
00:05:51,890 --> 00:05:55,110
We assign the frames in order to do relations between them.

79
00:05:55,130 --> 00:05:55,610
OK.

80
00:05:55,850 --> 00:06:03,710
So communicate between these frames and know the position and orientation of objects relative to the

81
00:06:03,710 --> 00:06:06,380
robot and the robot relative to object.

82
00:06:06,860 --> 00:06:16,250
OK, then what we want to do, we want we want to find the which is vector between the centers of these

83
00:06:16,370 --> 00:06:25,100
two frames and which is also the distance between the robot and the object.

84
00:06:25,580 --> 00:06:32,040
And also, we want to find Tita why we want to find Peter, because our purpose is first to rotate,

85
00:06:32,300 --> 00:06:36,710
make the orientation of the robot the same as the object's current frame.

86
00:06:37,430 --> 00:06:44,660
And so we want rotated degrees in order to face up with the object.

87
00:06:44,930 --> 00:06:45,410
OK.

88
00:06:45,800 --> 00:06:47,150
And then what?

89
00:06:47,150 --> 00:06:53,750
We want to do it, then we want to apply for the velocity to our robot in order to go that point.

90
00:06:53,960 --> 00:06:57,370
So it's indeed a very easy concept.

91
00:06:57,380 --> 00:06:58,790
So what we are doing.

92
00:06:58,970 --> 00:07:02,480
First, we are correcting our heading angle, which is TITA.

93
00:07:02,690 --> 00:07:10,580
So if our robot watches these side, I mean, if our robot's heading is to decide and the object is

94
00:07:10,580 --> 00:07:21,410
on this side, we first want our robot to watch to have the same orientation with the object.

95
00:07:21,710 --> 00:07:30,320
And then we apply forward velocity in order to account for the distance and come near the object.

96
00:07:30,830 --> 00:07:42,560
So how we will do this task first, we will separate our D vector, or we will project our vector D

97
00:07:42,860 --> 00:07:44,930
onto X and Y axis.

98
00:07:46,010 --> 00:07:47,390
OK, not z axis.

99
00:07:47,390 --> 00:07:51,130
Because as you know, our robot is not a quadcopter or a drone.

100
00:07:51,140 --> 00:07:52,670
It doesn't move in

101
00:07:55,370 --> 00:07:56,300
that dimension.

102
00:07:56,300 --> 00:08:01,000
It moves only in X and Y because it's a differential drive.

103
00:08:01,010 --> 00:08:02,120
It's not flying.

104
00:08:02,120 --> 00:08:07,850
So we have only two dimensions, so we will project on the X, a. y.

105
00:08:08,390 --> 00:08:12,890
And if you remember from our tutorials how we will fund T to A..

106
00:08:12,980 --> 00:08:19,930
So let's see for in order to find Tita Vivo, we use our time to function.

107
00:08:19,970 --> 00:08:20,530
OK.

108
00:08:20,620 --> 00:08:21,740
Item to function.

109
00:08:22,310 --> 00:08:29,090
Um, well, I have a little talk about this one because we have learned it before, so we will use it

110
00:08:29,090 --> 00:08:32,450
on to function and we are given from trigonometry.

111
00:08:32,450 --> 00:08:34,840
You know, we are given d y, d x.

112
00:08:34,850 --> 00:08:39,470
We can find this tita from other countries, but for some reasons we will use it.

113
00:08:39,470 --> 00:08:43,910
And two, I have mentioned these reasons in previous tutorials.

114
00:08:44,300 --> 00:08:49,010
If you want to remember or repeat, you can watch this trial again.

115
00:08:49,550 --> 00:08:49,970
OK.

116
00:08:50,060 --> 00:08:57,450
We are funding to our heading NGOs, and we rotate our robot by to degrees in order to face up with

117
00:08:57,450 --> 00:08:59,720
the AI with our object.

118
00:09:00,020 --> 00:09:01,850
Then how we will calculate deep.

119
00:09:02,180 --> 00:09:04,130
It's very easy from trigonometry.

120
00:09:04,130 --> 00:09:10,460
You know, we will find the this is models of the Vector D. So we are taking a modest more of it, and

121
00:09:10,670 --> 00:09:16,250
this equals the square root of the X squared plus d y squared.

122
00:09:17,840 --> 00:09:22,910
This is our formulas that we need to apply then.

123
00:09:23,270 --> 00:09:25,100
OK, let's come to now.

124
00:09:25,790 --> 00:09:29,300
Uh, the coding part people.

125
00:09:29,300 --> 00:09:33,470
I wrote the code before and this I will send it.

126
00:09:33,890 --> 00:09:42,950
I will attach GitHub link to this so you can download the code and you can analyze by yourself.

127
00:09:43,430 --> 00:09:43,770
OK.

128
00:09:43,790 --> 00:09:50,060
First of all, uh, for this one, we will use this sets our interpreter.

129
00:09:50,720 --> 00:09:56,660
So Python interpreter, because as you know, Python two, there's Python two or Python three and like

130
00:09:56,660 --> 00:09:56,870
that.

131
00:09:57,110 --> 00:09:59,030
So we will use Python to.

132
00:09:59,950 --> 00:10:03,530
OK, so we will import Ross Pay.

133
00:10:03,850 --> 00:10:07,360
Um, as I said before, I will not explain all of this.

134
00:10:08,050 --> 00:10:14,830
I will just explain what we have used here, so we will use the n t f to Ross.

135
00:10:15,040 --> 00:10:21,010
What does t f to t f to is very important in Ross.

136
00:10:21,310 --> 00:10:34,630
What you do is it means relations creates relations between different frames and also the coke leads

137
00:10:35,080 --> 00:10:40,780
these homogeneous transformation matriz or not, it causes homogeneous transformation methods, but

138
00:10:40,780 --> 00:10:43,240
it calculates something like that.

139
00:10:43,450 --> 00:10:48,760
I mean, it calculates orientation and the distance between these two points.

140
00:10:49,000 --> 00:10:57,670
So by using T f two Ross, you can find the relation between two frames, which we need in order to

141
00:10:57,670 --> 00:11:00,460
calculate our T2 and D.

142
00:11:01,930 --> 00:11:02,310
OK.

143
00:11:02,470 --> 00:11:04,560
We will use t f conversions.

144
00:11:04,570 --> 00:11:06,040
I don't know whether we will use.

145
00:11:06,040 --> 00:11:08,080
I think we will not use OK.

146
00:11:08,110 --> 00:11:13,740
Excuse me, it's something that we will not need in this case, but we will.

147
00:11:13,930 --> 00:11:21,070
Let me explain for what is the purpose of this and how we can use this library in this case.

148
00:11:21,790 --> 00:11:27,910
We will use it if we have given or angles we will use to convert it to cotton use.

149
00:11:29,260 --> 00:11:35,650
And I think you remember the reasons why we use Quaternary is instead of angles.

150
00:11:36,310 --> 00:11:36,760
OK.

151
00:11:37,870 --> 00:11:44,440
Also additionally, Alia's angles are quite earnings are applied to inside are also that's why also

152
00:11:44,440 --> 00:11:50,590
we are converting everything else to cotton spunk and then we will use geometry messages.

153
00:11:51,610 --> 00:11:54,850
You will see why we are importing this model or this message.

154
00:11:54,860 --> 00:11:58,120
OK, then we will use gazebo messages for models.

155
00:11:58,120 --> 00:12:01,030
This and you will see y will need also.

156
00:12:01,630 --> 00:12:03,250
OK, let's start from in.

157
00:12:03,400 --> 00:12:05,890
First of all, we need our mode.

158
00:12:06,580 --> 00:12:12,400
Then we subscribe to gazebo models, states where we are subs, why we are subscribing this.

159
00:12:12,400 --> 00:12:13,210
Let's see.

160
00:12:15,100 --> 00:12:15,600
OK.

161
00:12:16,090 --> 00:12:16,810
Ross topic?

162
00:12:16,810 --> 00:12:20,030
Let's see what's our first of all our topics?

163
00:12:20,080 --> 00:12:21,190
Let's see our topics.

164
00:12:21,190 --> 00:12:26,830
As you can see, these are topics that are published or subscribe.

165
00:12:26,830 --> 00:12:29,290
You can subscribe or publish to these topics.

166
00:12:29,560 --> 00:12:33,130
These are the topics created by this software.

167
00:12:33,550 --> 00:12:35,560
I'm in the process.

168
00:12:36,340 --> 00:12:39,010
So, OK, uh, let's see.

169
00:12:39,910 --> 00:12:41,340
We need here.

170
00:12:41,340 --> 00:12:44,860
A gazebo model states why we need gazebo models this.

171
00:12:45,070 --> 00:12:51,220
We need that in order to get the position of our object relative to the autumn frame.

172
00:12:51,430 --> 00:12:54,730
Autumn frame in this case is like world frame.

173
00:12:55,570 --> 00:12:56,490
Yeah, yeah.

174
00:12:56,680 --> 00:13:03,520
There can be some cases in which Adam Frame is different from world frame, and this is changing depending

175
00:13:03,520 --> 00:13:04,090
on map.

176
00:13:04,420 --> 00:13:09,040
However, in this case, autumn frame is the same as our world frame.

177
00:13:09,040 --> 00:13:15,700
As you can see, this is our inertial frame, as we have said before, and these two frames, as you

178
00:13:15,700 --> 00:13:19,990
can see these frame, this frame is our local frames.

179
00:13:20,260 --> 00:13:25,570
First is belong to the robot and the second belongs to the object.

180
00:13:25,870 --> 00:13:27,340
And we want to.

181
00:13:29,620 --> 00:13:36,630
What we want to do is, first of all, we want to find the object's location relative to the ordem frame

182
00:13:36,640 --> 00:13:40,480
located so relative to these inertial frame real world frame.

183
00:13:40,990 --> 00:13:46,690
So that's why we are subscribing to gazebo models, states, gazebo model states.

184
00:13:46,690 --> 00:13:57,640
As you can see, it lets rules, topic echo, uh, slash gazebo model states gazebo model.

185
00:13:57,760 --> 00:14:07,960
This Stopit gazebo models this, as you can see, show us the objects on the roof on our Um, how can

186
00:14:07,960 --> 00:14:09,880
I say on our environment?

187
00:14:10,060 --> 00:14:11,590
As you can see, this is our box.

188
00:14:11,590 --> 00:14:14,010
As you can see, this is total about three Berger.

189
00:14:14,020 --> 00:14:19,780
This is our robot and it gives us their position and orientation.

190
00:14:20,020 --> 00:14:22,360
This is position and orientation of unit box.

191
00:14:22,600 --> 00:14:29,200
This is depending on index because the second or first index is four units bookstore.

192
00:14:29,440 --> 00:14:34,900
The first will be for the position and orientation of unit box.

193
00:14:35,080 --> 00:14:38,950
And the second index is our robot and this is for our robot.

194
00:14:39,160 --> 00:14:40,630
Also, it gives us twist.

195
00:14:40,960 --> 00:14:46,210
Twist Twist is a combination of linear and angular velocity of our objects.

196
00:14:46,210 --> 00:14:47,950
In this case, we will not need that.

197
00:14:47,950 --> 00:14:51,760
We will just need the position and orientation of the object.

198
00:14:51,760 --> 00:14:59,350
We will need only to find the position orientation of objects because turtle bolts three itself.

199
00:14:59,390 --> 00:15:06,000
We can get its position and orientation from by subscribing, it's all on topic, we will say it.

200
00:15:06,040 --> 00:15:07,910
Uh, no.

201
00:15:09,020 --> 00:15:12,950
OK, so we subscribed to this topic.

202
00:15:13,190 --> 00:15:17,080
And as you can see, we have called back for our subscribers.

203
00:15:17,090 --> 00:15:22,070
This is called our handle object posts, so we are going to explain this one.

204
00:15:22,310 --> 00:15:25,730
And this is our callback function, the handle object pause.

205
00:15:25,730 --> 00:15:28,730
And this accepts message from this topic.

206
00:15:29,000 --> 00:15:37,850
This is the message that published by this model states topics topic, and we subscribe this topic for

207
00:15:37,850 --> 00:15:38,630
this message.

208
00:15:38,960 --> 00:15:42,040
So, OK, first of all, we get are we.

209
00:15:42,530 --> 00:15:50,810
We get the name of the objects in our environment and we find index of the unit books because we just

210
00:15:50,810 --> 00:15:54,830
need the unit books object to find its position and orientation.

211
00:15:55,010 --> 00:15:56,300
So we get its indexed.

212
00:15:56,300 --> 00:16:00,800
And from this index, we find it's positive x y position.

213
00:16:01,340 --> 00:16:01,910
OK.

214
00:16:02,210 --> 00:16:06,790
And this is it's orientation x, y z and W.

215
00:16:06,800 --> 00:16:08,510
This is in what term you?

216
00:16:08,660 --> 00:16:09,200
OK.

217
00:16:09,410 --> 00:16:10,780
This is in cocoa attorney.

218
00:16:10,790 --> 00:16:11,380
Be careful.

219
00:16:11,390 --> 00:16:14,240
It is not in other angles, but it's in quaternary.

220
00:16:15,680 --> 00:16:19,130
OK, so then what?

221
00:16:19,190 --> 00:16:26,120
What we are doing, then we are publishing this frame.

222
00:16:26,300 --> 00:16:29,420
So what do I mean by publishing?

223
00:16:29,900 --> 00:16:36,050
So we get the orientation of this object and position of this object relative to other frame.

224
00:16:36,260 --> 00:16:38,930
So what we are doing, we are doing what we are doing.

225
00:16:39,110 --> 00:16:44,030
We are creating this frame as you can see this local frame and publish it.

226
00:16:44,330 --> 00:16:53,810
So we broadcast it so other objects can see this frame and calculate their position and orientation

227
00:16:53,810 --> 00:16:55,140
relative to this frame.

228
00:16:55,160 --> 00:17:04,100
For example, if Turtle bought, our robot wants to find its position and orientation relative to this

229
00:17:04,100 --> 00:17:09,230
object, it will listen to this frame.

230
00:17:09,410 --> 00:17:11,850
So this broadcast of frame?

231
00:17:11,870 --> 00:17:20,150
OK, its local frame, and it will calculate the difference between orientation and position in its,

232
00:17:20,180 --> 00:17:25,280
uh, the object's local frame and the robot's local frame.

233
00:17:26,360 --> 00:17:33,920
You know, OK, if you want to understand clearly this because surely I just assume that you know something

234
00:17:33,920 --> 00:17:39,590
about it, because as as I have said before, I don't want to explain all of these things here.

235
00:17:39,590 --> 00:17:49,160
I just want to show you how important it is that you can go to the t f to transformation in Ross tutorials,

236
00:17:49,160 --> 00:17:54,020
official stores, and they have beginner explanation of this.

237
00:17:54,020 --> 00:17:59,300
You can understand from there, and you can watch again this tutorial and try to understand the code

238
00:17:59,510 --> 00:18:00,830
by running it yourself.

239
00:18:01,280 --> 00:18:04,790
OK, then we are creating our frame.

240
00:18:04,820 --> 00:18:11,000
As you can see, we are creating our frame here and then we will send this frame what we are doing here.

241
00:18:11,150 --> 00:18:16,470
We first put the stamp of our frame.

242
00:18:16,640 --> 00:18:18,440
So this frame is taken in.

243
00:18:18,440 --> 00:18:22,620
This time this is needed for various purposes.

244
00:18:22,640 --> 00:18:30,230
This can be synchronisation or some other things that it is not needed in this case, but they will

245
00:18:30,230 --> 00:18:33,920
be needed in something in different situations.

246
00:18:34,340 --> 00:18:39,260
So we just append the time to it, stamp different stamp of the frame.

247
00:18:39,500 --> 00:18:40,550
Then this is frame.

248
00:18:40,940 --> 00:18:44,880
This shows us what is the current frame?

249
00:18:44,900 --> 00:18:45,380
OK.

250
00:18:45,740 --> 00:18:48,980
So, um, for example, what do I mean?

251
00:18:49,010 --> 00:18:49,970
The pound frame?

252
00:18:50,210 --> 00:18:57,740
We are getting the position and orientation of this frame, OK, but it is relative to what it can be

253
00:18:57,740 --> 00:18:59,150
relative to our robot.

254
00:18:59,330 --> 00:19:02,330
It can be relative to some other fixed frame.

255
00:19:02,570 --> 00:19:09,950
But in this case, this is relative to, I mean, the position and orientation we get by subscribing

256
00:19:09,950 --> 00:19:11,390
to module states.

257
00:19:11,390 --> 00:19:13,490
Topic is relative to ordem frame.

258
00:19:13,500 --> 00:19:17,180
So relative to our world frame, OK?

259
00:19:18,110 --> 00:19:22,700
So that's why we are writing it here, and this is our child frame.

260
00:19:22,700 --> 00:19:23,900
What's our child frame?

261
00:19:23,900 --> 00:19:27,440
Child frame is the local frame of our object.

262
00:19:27,710 --> 00:19:35,480
We are just so that's why we are giving the name unit box the name of the object to as a child frame.

263
00:19:35,840 --> 00:19:41,990
Then we are, uh, setting it's x y z, uh, coordinates.

264
00:19:42,230 --> 00:19:47,060
As you can see there, we put that zero point zero because we are in two dimension.

265
00:19:47,060 --> 00:19:52,850
Yeah, it's in three dimension if you watch, but the object moves into dimension.

266
00:19:52,850 --> 00:19:58,610
The robot is also moved to dimension in x y plane, not in that plane because it's not a quadcopter

267
00:19:58,820 --> 00:19:59,210
drone.

268
00:19:59,340 --> 00:20:07,750
On something else, if you were controlling a plane, you would then use the zip also.

269
00:20:08,620 --> 00:20:20,500
And we said also our orientation, as you can see in Quattrone and we then sent this frame or we are

270
00:20:20,890 --> 00:20:31,510
broadcasting this frame in all the other frames and other objects can listen to this frame and calculate

271
00:20:31,510 --> 00:20:35,140
their position and orientation relative to this frame.

272
00:20:35,170 --> 00:20:35,620
OK.

273
00:20:35,950 --> 00:20:38,920
So this is the final code.

274
00:20:39,490 --> 00:20:42,040
The distrust by spin is for.

275
00:20:42,040 --> 00:20:45,730
It is just like, um, just like a loop.

276
00:20:46,030 --> 00:20:50,860
So our program doesn't finish here and continues until we stop it.

277
00:20:51,130 --> 00:20:55,120
So let's not write the code for listeners.

278
00:20:55,870 --> 00:20:59,920
What do I mean listeners saw in the previous code?

279
00:21:00,130 --> 00:21:02,200
We have broadcasted this frame.

280
00:21:02,200 --> 00:21:11,380
OK, this local frame now our turtle bought our robot have to listen to this frame and calculate its

281
00:21:11,380 --> 00:21:17,050
relative, its relative position and orientation to this one.

282
00:21:17,320 --> 00:21:17,800
OK?

283
00:21:18,460 --> 00:21:21,760
With respect to local frame of objects.

284
00:21:21,760 --> 00:21:26,060
So by doing that, we will get our D vector.

285
00:21:26,080 --> 00:21:26,620
OK?

286
00:21:26,650 --> 00:21:28,240
We will get our D vector.

287
00:21:28,420 --> 00:21:31,510
Also, the X, the Y we have from here, I will.

288
00:21:31,690 --> 00:21:32,080
I can.

289
00:21:32,150 --> 00:21:38,770
I mean, we will get the X D Y from where we can find Peter and the absolute value of the.

290
00:21:40,030 --> 00:21:41,530
OK, let's do that.

291
00:21:41,620 --> 00:21:44,710
So what we are doing here is let's start first.

292
00:21:44,710 --> 00:21:46,180
We need our load.

293
00:21:47,050 --> 00:21:47,590
OK.

294
00:21:47,980 --> 00:21:51,100
This is buffer transformation buffer.

295
00:21:51,100 --> 00:21:57,850
This is needed in order to get our transformations and listen to them.

296
00:21:58,180 --> 00:21:58,690
OK.

297
00:21:59,350 --> 00:22:06,550
And this is listener which we'll use in order to lessen our transformations.

298
00:22:07,510 --> 00:22:10,900
OK, then we are publishing the C and D.

299
00:22:10,900 --> 00:22:12,820
Well, what is C and D?

300
00:22:12,820 --> 00:22:14,470
Will C and D?

301
00:22:14,590 --> 00:22:17,430
Well, this is common velocity.

302
00:22:17,440 --> 00:22:19,230
This means common velocity.

303
00:22:19,270 --> 00:22:21,400
And this message part is twist.

304
00:22:21,670 --> 00:22:24,570
So we will command velocity.

305
00:22:24,760 --> 00:22:30,460
I mean, angular velocity and linear velocity to our robot in order to go to that object.

306
00:22:30,760 --> 00:22:31,390
OK.

307
00:22:31,660 --> 00:22:36,580
So let's calculate, um, let's first look up transform.

308
00:22:36,590 --> 00:22:40,960
So we are looking up for transforms from which to reach.

309
00:22:40,990 --> 00:22:41,440
OK.

310
00:22:41,470 --> 00:22:42,880
This is very important.

311
00:22:42,880 --> 00:22:48,580
We want transformation from the frame of our object.

312
00:22:48,820 --> 00:22:55,200
Let's, uh, from frame of our robot to frame of our object.

313
00:22:55,210 --> 00:22:59,510
As you can see it, this is we want to find this the.

314
00:22:59,530 --> 00:22:59,920
Yeah.

315
00:23:00,280 --> 00:23:07,390
So we have to look for the transforms from robot's frame to objects frame.

316
00:23:08,410 --> 00:23:13,200
And we are doing that here from Bayes footprint.

317
00:23:13,210 --> 00:23:19,550
What's based footprint based footprint is local frame of our robot.

318
00:23:19,570 --> 00:23:25,240
This is given default to this, uh, robot.

319
00:23:26,020 --> 00:23:26,420
OK?

320
00:23:26,440 --> 00:23:29,590
The programmers of this robot created that frame.

321
00:23:30,100 --> 00:23:36,370
It is attached to the our robot, so it is based footprint is local frame of this robot.

322
00:23:36,700 --> 00:23:38,130
And there we go.

323
00:23:38,230 --> 00:23:43,450
If we want transformation from base footprint to object.

324
00:23:43,630 --> 00:23:44,170
OK.

325
00:23:44,530 --> 00:23:46,090
This is our object.

326
00:23:46,240 --> 00:23:47,980
Uh, frame.

327
00:23:48,820 --> 00:23:49,390
OK.

328
00:23:50,010 --> 00:23:59,050
Um, and then what we are doing after we get this transformation, we are creating new message for twist.

329
00:23:59,170 --> 00:24:02,110
Our twist message, new message, twist message.

330
00:24:02,440 --> 00:24:07,330
Then we are setting our angular velocity and our linear velocity.

331
00:24:07,540 --> 00:24:11,050
Our angle of velocity is proportional as you can see it.

332
00:24:11,410 --> 00:24:18,730
Or it's equal, let's say, equals the Method eight to as you can see, we calculated by using Item

333
00:24:18,730 --> 00:24:27,730
two and we get from D, Y and the X by calculating the 8m to we get our T to and we assign it to our

334
00:24:27,730 --> 00:24:38,470
angular velocity and our, um, linear velocity is we equals it to the distance between these two objects.

335
00:24:38,770 --> 00:24:47,170
So we are how we calculate by calculating D x squared plus d was squared and we find the square root.

336
00:24:47,400 --> 00:24:49,330
And this gives us distance.

337
00:24:49,420 --> 00:24:54,130
However, why we are doing here and we are assigning maximum velocity.

338
00:24:54,130 --> 00:24:59,160
Maximillian University, why we are doing that because as distance increase.

339
00:24:59,250 --> 00:25:07,650
Uses our linear velocity increases, and if the distance is too big, it calls some anomalies in the,

340
00:25:08,430 --> 00:25:11,910
you know, the robot becomes very fast, so it drifts.

341
00:25:11,910 --> 00:25:17,490
And instead of reaching to the given desired point, it just does something.

342
00:25:18,120 --> 00:25:22,020
It just drifts and because its velocity is too much.

343
00:25:22,230 --> 00:25:23,730
So that's why it creates problems.

344
00:25:23,730 --> 00:25:27,800
So we try to keep its velocity in some range.

345
00:25:27,810 --> 00:25:38,100
OK, so that's why we are finding minimum of this velocity and between our maximum linear velocity.

346
00:25:38,880 --> 00:25:45,540
After that, we just publish this comment, this velocity to our robot.

347
00:25:46,560 --> 00:25:47,100
OK.

348
00:25:47,670 --> 00:25:49,780
After speaking that much?

349
00:25:49,800 --> 00:25:52,230
OK, let's create our launch file.

350
00:25:52,620 --> 00:26:01,220
So we launch here our two nodes, which is our first of all, its object to broadcaster.

351
00:26:01,740 --> 00:26:06,000
By doing that, we broadcast our local frame of our object.

352
00:26:06,240 --> 00:26:12,120
And by doing that, we listen and by launching team bots to lease their node.

353
00:26:12,120 --> 00:26:18,990
We listened to this transformation and calculated desired heading angle and distance between this object.

354
00:26:19,980 --> 00:26:21,930
OK, let's try to run then.

355
00:26:22,920 --> 00:26:23,820
Let's do.

356
00:26:24,210 --> 00:26:26,010
I hope it will work.

357
00:26:26,760 --> 00:26:27,330
OK.

358
00:26:27,870 --> 00:26:29,280
Indeed, I have checked before.

359
00:26:29,280 --> 00:26:31,320
Surely roast lunch.

360
00:26:31,950 --> 00:26:33,750
Let's do that.

361
00:26:34,260 --> 00:26:36,000
So what was OK?

362
00:26:36,450 --> 00:26:42,160
T both three t f two and the start robot launch?

363
00:26:42,310 --> 00:26:52,180
OK, let's bring our here and let's run this book, but let's see what's happening.

364
00:26:52,200 --> 00:26:52,710
OK?

365
00:26:53,040 --> 00:26:58,080
As you can see, our robot now comes to object and it touches and stop it.

366
00:26:58,650 --> 00:27:02,550
So if you make it like that, OK, as you can see it, come to this.

367
00:27:03,210 --> 00:27:14,540
If you make it in this way, it will all and come closer to object by just calculating the, um uh,

368
00:27:15,150 --> 00:27:18,540
relative orientation and distance between this object.

369
00:27:18,750 --> 00:27:23,790
As you can see, this is how important to understand these transformations.

370
00:27:24,030 --> 00:27:32,880
I mean, the um homogeneous transformation matrix rotation matrix, ail or angles, Quattrone and angles.

371
00:27:32,880 --> 00:27:36,030
And this is a very simple example of it.

372
00:27:36,030 --> 00:27:43,650
We will use them as you will see, we will use them in our future left since very, very, very frequently

373
00:27:43,650 --> 00:27:47,010
and they are needed in robotics very, very frequently.

374
00:27:47,160 --> 00:27:56,030
And if you start to learn our OS or Ross, you will see that they are also used, um, you know, uh,

375
00:27:56,100 --> 00:28:03,190
very, very frequently in our office, in robot programming, because this is something like, um,

376
00:28:03,420 --> 00:28:09,720
communication between they are, you know, they are like eyes of the robots and objects.

377
00:28:09,720 --> 00:28:15,810
You know, based on these frames, they can calculate what's my position orientation relative this frame,

378
00:28:15,810 --> 00:28:19,800
that frame and like that, OK?

379
00:28:20,340 --> 00:28:31,890
I hope that with that tutorial, you can understand how important for us to know the homogeneous transformation

380
00:28:31,890 --> 00:28:36,420
mattresses, rotation, mattresses, aler angles, continuous and so on.

381
00:28:38,340 --> 00:28:41,670
I hope that I will see you in the next lesson.
