In this lesson we will be connecting the web UI and the drone.
Let's start off by setting the Singleton and the drone manager which is set under the model's folder
and the drone app folder.
Once you open the drone manager scroll all the way up here we will set to import from drone app models
base and import Singleton.
Once we set to import we need to change the drone manager object to middle class singleton.
We've successfully set the Singleton into this project.
Now let's go on to server P Y which is under the controllers folder in this file.
We will be setting the drone manager to be invoked scroll all the way to the top and import from drone
app models.
Drone manager.
Import drone manager.
We can invoke Singleton directly although the most common way will be defining get drone and return
drone manager.
We can invoke the get drone function from other functions such as command or controller to access the
drone manager.
The global function will be defined here once the function axis is the drone manager Singleton can be
used in each function.
You can also edit the drone manager after generating or change the settings altogether.
Lets start using the get drone function.
Go to the command and creative variable drone and set get drone.
Next we set and if statement to if the command is take off drone take off.
Function will be invoked.
This will be the same for land we have set the speed in our previous lessons.
Let's add on an if statement if the speed is invoked the drone set speed will be set with the speed
as an integer.
Let's open up some rows so we can finish all the commands.
If the command is up the drone up function will be invoked.
It'll be same for down.
We also have forward then we have back
we have clockwise also clockwise
other commands were left right
Flip front and flip back.
I'll copy and paste these lines and change the command names flip left flip right.
We also had patrol and stop patrol
now let's delete all these blank bro's
once the commands are successfully process.
We will be sending the text success to the front end side.
Now that we've finished connecting the commands let's run the code and try flying the drone using the
web UI first run this code go to the controller page.
I'm going to click on takeoff and you'll see the drone takeoff.
Try some of the buttons and see how your drone flies.
I just hit the down button so you can see my drone flying down.
Try using the clockwise button to see your drone rotate.
The default is set to 10 degrees so the rotation may be small.
Let's also press forward and back.
Right and Left.
Make sure you also check the flip buttons forward to flip from ways.
And back to flip backwards now left flip and right foot.
You can also change the speed to see if the drone speeds up.
Let's check on patrol.
We set the drone to fly up then rotate 90 degrees then fly down and the process will be repeated this
time we will just do the patrol once and hit the stop patrol button.
We went through all the buttons so let's hit the land button to finish this test.
If you try all the buttons and see your drone fly correctly you've succeeded.
In this lesson.
Congratulations.
Now I'll see you in the next lesson.