1
00:00:00,690 --> 00:00:04,940
In this lesson we will be connecting the web UI and the drone.

2
00:00:04,980 --> 00:00:10,290
Let's start off by setting the Singleton and the drone manager which is set under the model's folder

3
00:00:10,400 --> 00:00:12,690
and the drone app folder.

4
00:00:12,810 --> 00:00:20,540
Once you open the drone manager scroll all the way up here we will set to import from drone app models

5
00:00:20,550 --> 00:00:22,620
base and import Singleton.

6
00:00:23,760 --> 00:00:30,480
Once we set to import we need to change the drone manager object to middle class singleton.

7
00:00:30,480 --> 00:00:34,380
We've successfully set the Singleton into this project.

8
00:00:34,380 --> 00:00:40,470
Now let's go on to server P Y which is under the controllers folder in this file.

9
00:00:40,470 --> 00:00:48,330
We will be setting the drone manager to be invoked scroll all the way to the top and import from drone

10
00:00:48,420 --> 00:00:49,890
app models.

11
00:00:49,950 --> 00:00:51,260
Drone manager.

12
00:00:51,390 --> 00:00:53,880
Import drone manager.

13
00:00:53,880 --> 00:01:00,890
We can invoke Singleton directly although the most common way will be defining get drone and return

14
00:01:00,900 --> 00:01:02,910
drone manager.

15
00:01:02,910 --> 00:01:09,330
We can invoke the get drone function from other functions such as command or controller to access the

16
00:01:09,330 --> 00:01:11,240
drone manager.

17
00:01:11,820 --> 00:01:18,960
The global function will be defined here once the function axis is the drone manager Singleton can be

18
00:01:18,960 --> 00:01:20,970
used in each function.

19
00:01:20,970 --> 00:01:26,810
You can also edit the drone manager after generating or change the settings altogether.

20
00:01:26,880 --> 00:01:29,900
Lets start using the get drone function.

21
00:01:30,330 --> 00:01:35,730
Go to the command and creative variable drone and set get drone.

22
00:01:35,730 --> 00:01:41,130
Next we set and if statement to if the command is take off drone take off.

23
00:01:41,130 --> 00:01:43,460
Function will be invoked.

24
00:01:43,470 --> 00:01:49,430
This will be the same for land we have set the speed in our previous lessons.

25
00:01:49,450 --> 00:01:57,460
Let's add on an if statement if the speed is invoked the drone set speed will be set with the speed

26
00:01:57,520 --> 00:01:59,910
as an integer.

27
00:01:59,980 --> 00:02:03,460
Let's open up some rows so we can finish all the commands.

28
00:02:03,550 --> 00:02:07,730
If the command is up the drone up function will be invoked.

29
00:02:08,020 --> 00:02:09,910
It'll be same for down.

30
00:02:10,000 --> 00:02:13,000
We also have forward then we have back

31
00:02:17,460 --> 00:02:20,670
we have clockwise also clockwise

32
00:02:26,360 --> 00:02:29,240
other commands were left right

33
00:02:33,770 --> 00:02:37,460
Flip front and flip back.

34
00:02:37,460 --> 00:02:45,400
I'll copy and paste these lines and change the command names flip left flip right.

35
00:02:45,420 --> 00:02:48,210
We also had patrol and stop patrol

36
00:02:53,910 --> 00:02:55,910
now let's delete all these blank bro's

37
00:02:58,820 --> 00:03:01,560
once the commands are successfully process.

38
00:03:01,610 --> 00:03:05,990
We will be sending the text success to the front end side.

39
00:03:05,990 --> 00:03:11,390
Now that we've finished connecting the commands let's run the code and try flying the drone using the

40
00:03:11,390 --> 00:03:17,810
web UI first run this code go to the controller page.

41
00:03:17,810 --> 00:03:22,190
I'm going to click on takeoff and you'll see the drone takeoff.

42
00:03:22,190 --> 00:03:25,370
Try some of the buttons and see how your drone flies.

43
00:03:26,270 --> 00:03:29,750
I just hit the down button so you can see my drone flying down.

44
00:03:30,860 --> 00:03:34,590
Try using the clockwise button to see your drone rotate.

45
00:03:34,670 --> 00:03:41,240
The default is set to 10 degrees so the rotation may be small.

46
00:03:41,330 --> 00:03:44,120
Let's also press forward and back.

47
00:03:44,120 --> 00:03:46,430
Right and Left.

48
00:03:46,430 --> 00:03:52,090
Make sure you also check the flip buttons forward to flip from ways.

49
00:03:55,080 --> 00:04:00,120
And back to flip backwards now left flip and right foot.

50
00:04:03,380 --> 00:04:07,520
You can also change the speed to see if the drone speeds up.

51
00:04:07,730 --> 00:04:09,320
Let's check on patrol.

52
00:04:09,380 --> 00:04:18,470
We set the drone to fly up then rotate 90 degrees then fly down and the process will be repeated this

53
00:04:18,470 --> 00:04:24,050
time we will just do the patrol once and hit the stop patrol button.

54
00:04:24,080 --> 00:04:29,460
We went through all the buttons so let's hit the land button to finish this test.

55
00:04:29,540 --> 00:04:34,090
If you try all the buttons and see your drone fly correctly you've succeeded.

56
00:04:34,130 --> 00:04:35,090
In this lesson.

57
00:04:35,360 --> 00:04:36,990
Congratulations.

58
00:04:37,100 --> 00:04:38,540
Now I'll see you in the next lesson.
