1
00:00:03,810 --> 00:00:09,720
So now let's have a look at the pendulum, the system, a simple pendulum system has a mass that suspended

2
00:00:09,720 --> 00:00:12,870
from a pivot point that allows it to freely swing back and forth.

3
00:00:13,980 --> 00:00:19,710
Breaking the system down, that's a shame that we have a weight of mass m at the end of this weightless

4
00:00:19,710 --> 00:00:26,730
arm of length L from a pivot point, the angle that the arm is can be described by the angle theta and

5
00:00:26,730 --> 00:00:29,700
its velocity is described by the angular right theta dot.

6
00:00:30,390 --> 00:00:35,970
The forces tau can be applied to the system as the input or just left as zero for the free response

7
00:00:35,970 --> 00:00:38,300
or unforced response of the system.

8
00:00:39,640 --> 00:00:45,520
The equation of motion, of the angle of motion can be derived from the forces and inertia which results

9
00:00:45,520 --> 00:00:51,280
in the nonlinear differential equations that describe the motion of the dynamic system as shown here.

10
00:00:52,560 --> 00:00:58,410
You can see from the equation that is a non-linear due to this time here, ordinary differential equation.

11
00:00:59,000 --> 00:01:04,290
So the first step in modeling this system is to break it down into the state's best representation of

12
00:01:04,290 --> 00:01:05,880
two first order systems.

13
00:01:06,600 --> 00:01:13,260
So the states X1 and x2 of the system become theta and theta dot with the state right dynamics for X1

14
00:01:13,500 --> 00:01:16,410
and x2 described by using these equations here.

15
00:01:17,680 --> 00:01:24,190
Now, if we assume that our state X1 or Theta is always going to be a small angle, so say within 15

16
00:01:24,190 --> 00:01:29,860
degrees, then we can approximate this sine Theta X here using this small angle approximation and we

17
00:01:29,860 --> 00:01:33,140
just can approximate it to be theta or X1.

18
00:01:34,030 --> 00:01:39,610
So the system expressed in the linear continuous space form is approximately given by this linear states

19
00:01:39,610 --> 00:01:40,460
based system here.

20
00:01:40,900 --> 00:01:47,980
So we can say we replace the sign X with just X or Theta and we've ended up with this date space from

21
00:01:47,980 --> 00:01:48,310
here.

22
00:01:49,060 --> 00:01:54,760
Now we can turn this continuous linear system into a discrete form using the matrix exponential relationship

23
00:01:54,760 --> 00:01:57,550
for filtering an estimation as we've done in the past.

24
00:01:58,630 --> 00:02:04,390
So let's build a path, a model for the non-linear and linear approximation of the system and simulate

25
00:02:04,390 --> 00:02:07,000
the dynamics of both systems and see the responses.

26
00:02:08,120 --> 00:02:13,310
So here we have the Python script called Assignment to underscore Sim's Peiyi.

27
00:02:13,640 --> 00:02:19,940
Now this simulation script simulates a free or unforced response of the linear and nonlinear versions

28
00:02:19,940 --> 00:02:21,590
of the pendulum dynamic system.

29
00:02:22,730 --> 00:02:24,770
So we have a look at the code here, we can see.

30
00:02:24,800 --> 00:02:31,490
We first set up the simulation properly, so we set up a time set up date of our point, zero one seconds,

31
00:02:31,490 --> 00:02:33,370
a simulation time of 10 seconds.

32
00:02:33,710 --> 00:02:36,500
So we're going to simulate the dynamics for over ten seconds.

33
00:02:37,220 --> 00:02:39,740
We set up our system properties for the pendulum.

34
00:02:39,740 --> 00:02:46,100
So we define our gravitational constant being a nine point eight one, we have the length of the pendulum

35
00:02:46,100 --> 00:02:47,420
pain point five meters.

36
00:02:47,780 --> 00:02:52,130
And then we also set up the initial theta for the initial condition of the pendulum.

37
00:02:52,140 --> 00:02:53,840
And we've said it to be ten degrees.

38
00:02:55,520 --> 00:02:58,520
This part of the curve here, this is where we define the linear system.

39
00:02:58,530 --> 00:03:05,410
So this is the linear approximation and on the system and we use the continuous form to work out the

40
00:03:05,420 --> 00:03:08,420
straight matrix using our matrix exponential.

41
00:03:09,690 --> 00:03:13,060
And then lower in the code, we can actually see where we do the integration.

42
00:03:13,080 --> 00:03:15,770
So this is a simulation code that steps through time.

43
00:03:16,200 --> 00:03:22,680
We work at the linear system dynamics by basically propagating our X linear state, using our F matrix

44
00:03:22,680 --> 00:03:24,660
multiplied by our current X matrix.

45
00:03:25,350 --> 00:03:28,310
Our nonlinear equations are calculated here.

46
00:03:28,320 --> 00:03:32,550
So we work out our theta acceleration and we integrate that to get our theta dot.

47
00:03:32,820 --> 00:03:39,040
And then we do the same thing for Theta and then we have some code down here that just does animation.

48
00:03:40,020 --> 00:03:42,720
So let's run this simulation as is.

49
00:03:42,730 --> 00:03:47,090
So we're starting off our simulation with the pendulum being at 10 degrees.

50
00:03:47,100 --> 00:03:48,030
So let's run this.

51
00:03:50,940 --> 00:03:57,630
So you can see we have an animation pop up and there's actually a red line and a blue line in this animation,

52
00:03:57,900 --> 00:04:03,030
the red line is the linnaeus' system, the blue line is the nonlinear system.

53
00:04:03,690 --> 00:04:09,590
So we can see when we started this simulation off at 10 degrees, both systems are fairly well aligned.

54
00:04:09,600 --> 00:04:14,010
They both agree there's not too much variation between the two different systems.

55
00:04:14,310 --> 00:04:15,390
So we'll run us again.

56
00:04:16,420 --> 00:04:21,630
So you can see that both of the non-linear and linear responses pretty much track each other.

57
00:04:21,660 --> 00:04:23,430
So there's little error between the two.

58
00:04:24,450 --> 00:04:29,520
Now, if we were to run this with a different initial angle, so let's say instead of 10 degrees, we

59
00:04:29,520 --> 00:04:31,480
set this to be 45 degrees.

60
00:04:32,160 --> 00:04:38,360
Now I angle of 45 degrees is going to be definitely outside the linear zone of the sine function.

61
00:04:38,880 --> 00:04:44,460
So it will be a bad approximation to use a small angle approximations on angles such as 45 degrees.

62
00:04:44,820 --> 00:04:46,560
So now let's run the simulation.

63
00:04:49,530 --> 00:04:54,670
OK, now we're getting a very big difference between a linear system and nonlinear system.

64
00:04:54,690 --> 00:04:57,690
So, again, the red line here is the linear system.

65
00:04:57,930 --> 00:05:00,360
The blue line here is the nominee system.

66
00:05:01,050 --> 00:05:03,920
So you can see quite a dramatic difference between the two.

67
00:05:04,200 --> 00:05:09,460
And the longer you run, this is just going to continuously be out of phase and offset and drift.

68
00:05:10,380 --> 00:05:15,620
So we have to be careful when we're using a litany, linear approximation of a nominee system.

69
00:05:15,810 --> 00:05:21,240
We have to make sure that we are operating inside the linear range for the linear approximation to be

70
00:05:21,240 --> 00:05:21,660
valid.

71
00:05:23,010 --> 00:05:28,590
So when we use a common Thawra to estimate our angle theta, we just have to be wary of these limitations.

