1
00:00:00,120 --> 00:00:02,850
No, let's start with planning trajectories.

2
00:00:03,240 --> 00:00:09,390
Indeed, it's very interesting for me to do trajectory planning because at the end, when robots smoothly

3
00:00:09,390 --> 00:00:14,100
tracks the trajectory you have imposed to eat, it is very satisfying to watch it.

4
00:00:14,610 --> 00:00:14,940
OK.

5
00:00:14,980 --> 00:00:21,810
Anyway, during trajectory planning, we have to determine two important since the first one is very

6
00:00:21,810 --> 00:00:22,740
obvious for you.

7
00:00:23,080 --> 00:00:26,880
Indeed, it is the paths that robot manipulator has to track.

8
00:00:27,270 --> 00:00:29,940
You all know it, but this is not the end.

9
00:00:30,330 --> 00:00:36,210
There is also one another issue that you have to take into account, and this is how the robot manipulator

10
00:00:36,210 --> 00:00:38,980
will track the trajectory, namely motion lo.

11
00:00:39,540 --> 00:00:40,720
So what?

12
00:00:40,720 --> 00:00:47,850
What will be its speed or acceleration or jerk, which is the derivative of acceleration, how smooth

13
00:00:47,850 --> 00:00:50,160
these variables have to be and so on.

14
00:00:50,520 --> 00:00:54,720
So don't forget these two concepts geometric paths and motion, lo.

15
00:00:55,260 --> 00:00:59,310
Additionally, they have to determine how much smooth trajectory we need.

16
00:00:59,790 --> 00:01:04,680
We will talk about more deeply about this in further minutes.

17
00:01:05,130 --> 00:01:10,620
Generally, while doing trajectory planning, we don't direct the right trajectory as a function of

18
00:01:10,620 --> 00:01:17,550
time, but instead we write it as a function of some parameter, which is indeed directly a function

19
00:01:17,550 --> 00:01:18,060
of time.

20
00:01:18,600 --> 00:01:25,350
We can write it indeed, in this way, as you can see, P, which is workspace trajectory and Q, which

21
00:01:25,350 --> 00:01:33,210
is joint space, trajectory or function of S and sigma parameters respectively, and s and sigma parameters

22
00:01:33,210 --> 00:01:34,320
are a function of time.

23
00:01:34,710 --> 00:01:35,700
Why do we do that?

24
00:01:36,300 --> 00:01:41,580
This is because by changing parameterization, we can change the behavior of trajectory really easily.

25
00:01:42,030 --> 00:01:47,820
Now, as we have said, it is very important to determine degree of smoothness during trajectory planning.

26
00:01:48,330 --> 00:01:52,020
But how can we impose degree of smoothness for the trajectory?

27
00:01:52,410 --> 00:01:55,770
We can do that by using parameters we have seen before.

28
00:01:56,910 --> 00:02:03,180
So by setting trajectory parameters as some and degree polynomial function, we can set the smoothness

29
00:02:03,180 --> 00:02:09,570
of the trajectory by smoothness of the trajectory, the mean smoothness in velocity and smoothness and

30
00:02:09,570 --> 00:02:10,920
acceleration profiles.

31
00:02:11,400 --> 00:02:18,150
So how smooth velocity and acceleration change is there any discontinuities because smooth velocity

32
00:02:18,150 --> 00:02:22,380
or acceleration profiles mean that there is no discontinuities?

33
00:02:23,130 --> 00:02:32,040
OK, here is how this parameter s as in OK, here is how we set parameter as in degree polynomial here

34
00:02:32,040 --> 00:02:43,470
a zero is a zero to a n excuse me r alone coefficients that have to be determined because without them,

35
00:02:43,470 --> 00:02:45,450
we cannot construct the trajectory.

36
00:02:46,770 --> 00:02:51,360
However, we obtain them by utilizing boundary conditions on the trajectory.

37
00:02:51,750 --> 00:02:58,440
So by using boundary conditions, we will obtain system of equations from where we can determine coefficients

38
00:02:58,860 --> 00:02:59,710
at this moment.

39
00:02:59,730 --> 00:03:04,620
You can ask, OK, perfect, but how will we determine the degree of the polynomial?

40
00:03:04,980 --> 00:03:05,370
OK.

41
00:03:05,400 --> 00:03:06,390
Here is the answer.

42
00:03:06,750 --> 00:03:12,600
First of all, degree of polynomial has to be at least number of boundary conditions minus one.

43
00:03:13,050 --> 00:03:16,860
Otherwise, you will not be able to satisfy your boundary conditions.

44
00:03:17,280 --> 00:03:18,990
However, this is minimum limit.

45
00:03:19,260 --> 00:03:25,190
You can then increase the degree of polynomial as much as you want in theory to get a smoother trajectory.

46
00:03:25,260 --> 00:03:32,580
But don't forget, higher degree means higher number of coefficients to be calculated, which makes

47
00:03:32,580 --> 00:03:35,850
trajectory planning difficult during real time operations.

48
00:03:36,340 --> 00:03:40,800
Anyway, let's see now how we will do trajectory planning here.

49
00:03:40,800 --> 00:03:43,740
I wrote parameter with any degree of polynomial.

50
00:03:44,160 --> 00:03:48,960
We can write this in matrix form like that we are m is a non square matrix.

51
00:03:48,960 --> 00:03:54,450
B is vector of boundary conditions and A is vector of unknown coefficients.

52
00:03:54,900 --> 00:03:58,590
We can find a easily by just finding inverse of M.

53
00:03:59,040 --> 00:04:05,040
Let's assume that we are given these minimal boundary conditions, meaning the initial configuration

54
00:04:05,040 --> 00:04:08,130
and velocity and final position and velocity.

55
00:04:08,550 --> 00:04:13,110
These are scalar variables because we will do trajectory planning for one joint.

56
00:04:13,510 --> 00:04:18,990
However, in future lessons, we will see how to do trajectory planning for more than one joint robots.

57
00:04:19,500 --> 00:04:22,500
So we have for boundary conditions in total.

58
00:04:22,830 --> 00:04:26,910
This means the degree of polynomial M has to be at least three.

59
00:04:27,300 --> 00:04:33,720
So let's choose degree of polynomial as three and the right trajectory as in Equation 1.0.

60
00:04:35,160 --> 00:04:39,570
This trajectory is called cubic trajectory because the degree of polynomial is three.

61
00:04:39,990 --> 00:04:46,170
Let's ride this system of equations by just planning boundary conditions in by plugging, excuse me,

62
00:04:46,170 --> 00:04:48,240
boundary conditions into the polynomial.

63
00:04:48,780 --> 00:04:55,320
We can convert them into matrix form as this and determine M Matrix A and B vectors.

64
00:04:55,920 --> 00:04:59,810
From here, we can easily find a by inverting math.

65
00:05:00,130 --> 00:05:08,350
M, this is the unknown coefficient vector of a after we have done inversion, you can easily apply

66
00:05:08,350 --> 00:05:09,820
this procedure in MATLAB.

67
00:05:10,270 --> 00:05:15,250
If you noticed during these calculations, we have taken initial time as zero.

68
00:05:15,760 --> 00:05:18,310
But what happens if initial time is not zero?

69
00:05:18,730 --> 00:05:21,400
It is very easy to handle in this case.

70
00:05:22,090 --> 00:05:25,960
Excuse me, it's very easy to handle this case also.

71
00:05:26,410 --> 00:05:33,820
We just have to subtract it from time variables in order to consider that for initial time time.

72
00:05:34,300 --> 00:05:37,630
OK, now let's go to the lab and investigate more.

73
00:05:37,750 --> 00:05:42,370
OK, now let's see how people construct could be polynomial in.

74
00:05:42,700 --> 00:05:46,810
Excuse me, quick trajectory in MATLAB.

75
00:05:48,100 --> 00:05:50,560
First of all, we will specify.

76
00:05:50,560 --> 00:05:55,320
Sure, our boundary conditions, as you can see, this is nothing but the initial position, initial

77
00:05:55,450 --> 00:05:59,670
and final position, and also the same initial velocity and final.

78
00:05:59,950 --> 00:06:04,420
As you can see, the initial lows at the end final velocity are specified as zero.

79
00:06:04,690 --> 00:06:08,320
And we will execute our trajectory for long term unit.

80
00:06:09,970 --> 00:06:12,910
This is a function for concrete court efficiency.

81
00:06:13,270 --> 00:06:14,980
OK, four cubic polynomial.

82
00:06:16,380 --> 00:06:18,610
And this is this is the function.

83
00:06:18,850 --> 00:06:25,780
So the input is nothing but position velocity and also the time.

84
00:06:26,170 --> 00:06:26,560
Yes.

85
00:06:27,020 --> 00:06:34,540
And I mean, this position can contains initial and final positions.

86
00:06:34,840 --> 00:06:40,000
This initial final velocities and this is for initial and final time.

87
00:06:40,540 --> 00:06:49,360
After that, we can't rewrite it to be Vector B vector, which is nothing but our boundary conditions.

88
00:06:49,360 --> 00:06:49,750
Vector.

89
00:06:49,840 --> 00:06:50,170
OK.

90
00:06:50,980 --> 00:06:53,600
This is our aim and metrics.

91
00:06:53,620 --> 00:06:54,370
We know it.

92
00:06:54,460 --> 00:06:54,940
OK.

93
00:06:56,110 --> 00:06:57,550
And this is our A..

94
00:06:57,730 --> 00:07:00,690
As you can see, we find it by inversion matrix.

95
00:07:00,700 --> 00:07:01,150
OK?

96
00:07:02,200 --> 00:07:04,690
Because a matrix is our vector.

97
00:07:04,690 --> 00:07:06,790
Excuse me, is our unknown vectors?

98
00:07:07,030 --> 00:07:07,870
OK, perfect.

99
00:07:08,900 --> 00:07:15,820
But now, after we have calculated and obtained a which is our unknown coefficients, we can construct

100
00:07:15,830 --> 00:07:19,910
our trajectory and run it.

101
00:07:19,930 --> 00:07:20,350
OK.

102
00:07:20,770 --> 00:07:26,170
So what we are going to do is we specify a time limit, OK for ourselves.

103
00:07:26,770 --> 00:07:36,460
This is my zero point two is in order to see what is in order to see the trajectory before zero and

104
00:07:36,580 --> 00:07:43,330
after the, uh, before the initial time and after the initial time, you will see this is a necessary

105
00:07:43,330 --> 00:07:44,430
detail for plotting.

106
00:07:44,440 --> 00:07:45,970
You can do it even this way.

107
00:07:46,240 --> 00:07:49,480
No problem, but you will see why we have done it in this way.

108
00:07:50,770 --> 00:07:51,100
OK?

109
00:07:51,310 --> 00:07:57,400
Did people, uh, create our vectors for, uh, position, velocity and acceleration?

110
00:07:57,400 --> 00:07:57,910
OK?

111
00:07:58,900 --> 00:08:05,350
Then what we are doing at is during the time, uh, you are our unit, OK?

112
00:08:06,190 --> 00:08:09,130
During our time samples, OK?

113
00:08:09,200 --> 00:08:15,370
Each time and each time sample, we are, uh, calculating, uh, our trajectory.

114
00:08:15,640 --> 00:08:16,100
OK.

115
00:08:16,540 --> 00:08:23,530
Here, and as I have said it, we have subtract zero point from the initial time.

116
00:08:23,740 --> 00:08:28,390
So as our initial time is zero, it will be, um, less than zero.

117
00:08:28,630 --> 00:08:39,850
And also this is, uh, we uh, we started with zero point two and the final time.

118
00:08:40,270 --> 00:08:40,690
OK.

119
00:08:41,080 --> 00:08:43,030
Here we just check it out.

120
00:08:43,450 --> 00:08:44,890
The mean thing?

121
00:08:44,920 --> 00:08:45,350
OK.

122
00:08:46,150 --> 00:08:48,780
I mean, the this part is as part.

123
00:08:48,790 --> 00:08:54,380
We have seen it on the uh, we are in, um, in our slides.

124
00:08:54,400 --> 00:08:54,850
OK.

125
00:08:54,910 --> 00:08:59,920
During talking about quick trajectory, as you can see, if you are calculating, uh, first of all,

126
00:08:59,920 --> 00:09:03,460
Kutty, this is our normal quick, uh, trajectory.

127
00:09:03,730 --> 00:09:06,640
These coefficients, uh, put it here.

128
00:09:06,670 --> 00:09:07,180
OK.

129
00:09:07,720 --> 00:09:11,200
We know these kind of connections because we calculated them here.

130
00:09:11,410 --> 00:09:11,800
OK?

131
00:09:12,490 --> 00:09:16,150
And we calculate the velocity and acceleration in these cases.

132
00:09:16,420 --> 00:09:24,760
If the trajectory is what will happen with the trajectory before the initial time, before the initial

133
00:09:24,760 --> 00:09:25,300
time.

134
00:09:25,630 --> 00:09:29,810
As you can see, a position will be equal the initial positions.

135
00:09:29,950 --> 00:09:36,280
However, velocity and acceleration will be zero because, um, because the robot doesn't, it didn't

136
00:09:36,280 --> 00:09:38,440
start to move yet.

137
00:09:38,830 --> 00:09:45,880
And after the final time, the robot will again stop so bills that inflation will be zero and the position

138
00:09:45,880 --> 00:09:47,530
will be cute final.

139
00:09:47,830 --> 00:09:50,800
Then we are just using support common.

140
00:09:50,810 --> 00:09:53,560
We are plotting the and our trajectory.

141
00:09:54,040 --> 00:09:55,150
So let's do that.

142
00:09:55,240 --> 00:09:56,470
Let's run this section.

143
00:09:56,620 --> 00:09:59,620
And as you can see, this is our orientation.

144
00:09:59,900 --> 00:10:09,780
As you can imagine, if we put zero here, it would be if we didn't subtract 0.2 and he didn't add zero

145
00:10:09,800 --> 00:10:11,390
point to the final time.

146
00:10:12,530 --> 00:10:19,340
The trajectory will still be correct, but you know, these situations will not appear and it will be

147
00:10:19,340 --> 00:10:20,060
a bit difficult.

148
00:10:20,390 --> 00:10:22,130
It would start from here.

149
00:10:22,220 --> 00:10:25,550
So in order to make our plotting a bit beautiful, we have done this.

150
00:10:25,880 --> 00:10:32,840
So we see that before the initial turn, the position was an orientation or position of configuration.

151
00:10:32,840 --> 00:10:34,100
OK was 10.

152
00:10:34,400 --> 00:10:37,490
Then it started to increase up to 30 to the final.

153
00:10:37,610 --> 00:10:38,120
OK?

154
00:10:38,540 --> 00:10:42,200
And you can see the velocity also an acceleration.

155
00:10:42,200 --> 00:10:45,590
As you can see, acceleration is what I exploration is.

156
00:10:46,280 --> 00:10:50,150
This continues, OK, our velocity is continuous.

157
00:10:50,270 --> 00:10:51,130
OK, OK.

158
00:10:51,530 --> 00:10:55,040
This passenger levels for point to point trajectory planning.

159
00:10:55,430 --> 00:11:00,590
Namely, we have one initial point and one final point, and that's all.

160
00:11:01,010 --> 00:11:02,420
But what happens for Malta?

161
00:11:02,420 --> 00:11:07,870
Segment trajectories, for example, what happens if we have middle points to consider?

162
00:11:07,880 --> 00:11:12,530
Also, as in this case, it is very easy to handle this case.

163
00:11:12,530 --> 00:11:19,130
Also, as we know how to the trajectory planning for one segment, we just need to split the trajectory

164
00:11:19,130 --> 00:11:24,440
into multiple segments and do trajectory planning for each segment individually.

165
00:11:24,980 --> 00:11:29,480
Sorry, I have missed one point, but anyway, I think you have to understand what I mean.

166
00:11:30,080 --> 00:11:35,330
So for the first segment, the Q Zero will be initial and Q1 will be final.

167
00:11:35,330 --> 00:11:42,020
Configuration for segment to Q1 will be the initial and the Q2 will be the final configuration and so

168
00:11:42,020 --> 00:11:42,290
on.

169
00:11:43,220 --> 00:11:49,580
Another problem I want to note is that until here we have assumed that we will be given initial final

170
00:11:49,580 --> 00:11:50,810
and middle velocities.

171
00:11:51,320 --> 00:11:52,740
But this is not always true.

172
00:11:52,760 --> 00:11:57,890
Generally, we are given on the initial and final velocities and we have to figure out a middle point

173
00:11:57,890 --> 00:11:59,300
velocities automatically.

174
00:11:59,870 --> 00:12:05,270
Generally, initial and final velocities are zero because the robot starts from steady state and execute

175
00:12:05,270 --> 00:12:09,570
the trajectory and becomes again for the middle points.

176
00:12:09,590 --> 00:12:14,090
We can use the slope of the trajectory to determine the velocities automatically.

177
00:12:14,630 --> 00:12:18,620
Calculating slope is given by this formula, which is nothing but velocity.

178
00:12:19,220 --> 00:12:22,310
People calculate slope for two sequential lines.

179
00:12:22,730 --> 00:12:29,660
If these two lines have different slopes, namely one increases while another decreases or vice versa,

180
00:12:29,900 --> 00:12:32,930
we just said the middle point velocity at zero.

181
00:12:33,380 --> 00:12:39,350
Otherwise, if these two lines are both increasing or decreasing, namely they have the same slope,

182
00:12:39,710 --> 00:12:43,610
then we assign the middle point velocity as average of them.

183
00:12:44,540 --> 00:12:47,840
OK, now let's go to the map and investigate this more.

184
00:12:47,930 --> 00:12:51,150
OK, now let's see how we can do the same thing.

185
00:12:51,170 --> 00:12:56,360
So it can be an calculation for the world segment trajectory for math sigman trajectory.

186
00:12:56,390 --> 00:12:58,730
Here is our boundary conditions, OK?

187
00:12:59,030 --> 00:13:02,720
And these are the time points where these boundary conditions are met.

188
00:13:02,990 --> 00:13:03,410
OK.

189
00:13:04,010 --> 00:13:13,430
And um, so here let me make it in this way.

190
00:13:15,230 --> 00:13:16,240
OK, for now.

191
00:13:16,250 --> 00:13:17,690
OK, this is our velocity.

192
00:13:18,800 --> 00:13:20,240
We will talk about this now.

193
00:13:20,400 --> 00:13:20,900
OK.

194
00:13:21,200 --> 00:13:23,690
This is for automatic calculation of the velocities.

195
00:13:23,690 --> 00:13:28,460
But first, let's see with the given velocities.

196
00:13:28,490 --> 00:13:32,970
OK, boundary conditions or middle point conditions?

197
00:13:32,990 --> 00:13:36,410
OK, then these are just time samples.

198
00:13:36,420 --> 00:13:44,540
And here again, what we are doing is calculating the trajectory for velocity, excuse me, position

199
00:13:44,540 --> 00:13:53,480
velocity and this acceleration and the V for each time segment, as you can see for each segment, excuse

200
00:13:53,480 --> 00:13:54,490
me, in the time segment.

201
00:13:54,710 --> 00:13:59,090
But for each segment, we are calculating coefficients.

202
00:13:59,120 --> 00:13:59,480
OK?

203
00:13:59,690 --> 00:14:04,550
Because at each segment, conditions will be different, so coefficients will be different.

204
00:14:04,550 --> 00:14:12,770
So different in polynomials will be used with different in the same degree of polemic will be used,

205
00:14:12,770 --> 00:14:14,310
but with different coefficients.

206
00:14:14,330 --> 00:14:14,630
OK.

207
00:14:14,960 --> 00:14:23,270
We calculated the coefficients and we are OK writing them in the matrix.

208
00:14:23,270 --> 00:14:30,530
OK, which hold for each segment the configuration, configuration, velocity and acceleration.

209
00:14:30,770 --> 00:14:34,160
Then we have to just combining these.

210
00:14:35,540 --> 00:14:41,130
OK, combining these position velocity and acceleration for each time segment.

211
00:14:41,210 --> 00:14:41,870
OK.

212
00:14:42,230 --> 00:14:44,180
And then we are just plotting them.

213
00:14:44,810 --> 00:14:45,200
OK.

214
00:14:45,770 --> 00:14:47,540
Let's see how we can.

215
00:14:47,840 --> 00:14:49,310
What is the result?

216
00:14:49,340 --> 00:14:50,150
Let's run this.

217
00:14:50,150 --> 00:14:54,740
As you can see, this is the trajectory, OK?

218
00:14:55,040 --> 00:14:57,960
As you can see, this consists of multiple segments.

219
00:14:57,980 --> 00:14:59,180
OK, here.

220
00:14:59,650 --> 00:15:03,040
Here, here, here, here, here, here to here.

221
00:15:03,460 --> 00:15:03,940
OK.

222
00:15:05,920 --> 00:15:06,400
OK.

223
00:15:06,460 --> 00:15:10,870
And this is the velocity, as you can see, acceleration again is discontinuous.

224
00:15:10,960 --> 00:15:19,300
OK, let's see how we can calculate the velocity is not with the given ones, but with automatically

225
00:15:19,300 --> 00:15:20,190
calculated once.

226
00:15:21,760 --> 00:15:24,380
OK, automatically calculated once.

227
00:15:24,850 --> 00:15:27,190
Let's, erm, comment this one also.

228
00:15:30,330 --> 00:15:30,720
OK.

229
00:15:32,160 --> 00:15:36,690
As you can see, this is the automatic for automatic calculation, as you can see, this is much more

230
00:15:36,690 --> 00:15:37,290
smoother.

231
00:15:37,410 --> 00:15:37,950
OK?

232
00:15:37,980 --> 00:15:42,540
The velocity profile hardware acceleration profile is again what this continues.

233
00:15:43,140 --> 00:15:43,650
OK.

234
00:15:44,160 --> 00:15:51,780
Let's see how we can do that so that each time segment again we are calculating VK and VeeKay plus one

235
00:15:51,900 --> 00:15:54,510
for, as we have said, we are calculating just

236
00:15:57,810 --> 00:16:07,800
we are calculating the slope of the lines at each time sample and that at each condition middle condition.

237
00:16:08,130 --> 00:16:08,610
OK.

238
00:16:08,910 --> 00:16:13,580
Subsequent middle conditions possibly could be K plus one, and we just checked there.

239
00:16:13,590 --> 00:16:16,080
So if you are not equal?

240
00:16:16,380 --> 00:16:16,890
OK.

241
00:16:17,100 --> 00:16:20,820
We put the velocity for that instant as zero.

242
00:16:21,270 --> 00:16:29,050
If they are there are equal, then we are just finding their middle, OK?

243
00:16:29,100 --> 00:16:31,470
They are not middle, but they're average.

244
00:16:32,760 --> 00:16:36,390
And then again, we are doing the same thing and we're just plotting them.
