Snap Lesson 4: Flight Movements part 2
In this lesson, we learn some good techniques to better control the CoDrone using the movement commands. Summary
Our next step in programming our CoDrone is understanding how the program works. This lesson will explain how the program makes the CoDrone fly and how to use this knowledge to improve our flight code.
When we use a sending command it does not just send the movement commands above it, it sends all of the most recent values for each direction. For example:
The first sending command will set the roll to 50, the pitch to 25, the yaw to 100, and the throttle to 75 on the CoDrone. Then it waits one second. The second sending command not only sends pitch 50 and throttle 0, but it also sends roll 50 and yaw 100. Which means if we wanted it to stop turning and going towards the side we need to set these values to 0 also.
This also means we may run into some problems if your code starts just like this:
The reason is that since in the first movement we only set the throttle value, then we do not know what the other movements will be set too. Normally when you do a flight event stop or landing it resets them all to 0, however if you do an emergency stop or something they will not always be reset. This means if roll was last set at 50, then in this first set throttle will be 75 and the roll will be 50. To prevent this problem from appearing we will set all movement values in the first step to make sure that we are setting all movements to the values we want.
This code above shows how to properly start the CoDrone.
Stay in the loop
Get the latest updates and promotions. In fact, we'll give you a 8% discount today!
Your Information will be protected by our super robot guards