## Moving in a Circle

Now we are going to make our CoDrone fly in a circle. To do this we will have the CoDrone face the same way. Then by adjusting the roll and pitch we can have it move in a circle. At the top of the circle we will need to have a lot of roll to get it moving to the left, then as it moves along we will have less roll and have more pitch down. Then when it gets to the left we will have all pitch and no roll. And as it goes towards the bottom the roll will increase and the pitch will decrease. And it will just keep moving around.

So the main parts of the circle will be:

1. Roll (-80) and Pitch (0)
2. Roll (0) and Pitch (-80)
3. Roll (80) and Pitch (0)
4. Roll (0) and Pitch (80)

But if we did only these we would not get much of a circle, we would get a square.

We can add in more steps to create a shape that is closer to a circle than a square. For example, if we double the number of steps we would get an octagon.

We could add in more steps to make it even closer to a circle. However, since the CoDrone does not immediately change directions, but it takes time for it to accelerate into a new direction our octagon’s corners will become curved. A curved octagon looks really close to a circle. Also another issue we can have when we try to divide it into move and more movements is that a pitch or roll value of less than about 30 does not have any effect. So that would mean a step that was pitch 20 and roll 20, would just hover.

We will get started with the first steps. Firstly we need to take-off then once we are in the air we can do the first side of the octagon/circle. We will move at pitch 0 and roll -80 fro a short time. To make adjusting the time simpler I will make a variable that will be for how long each movement is.

Then we will go through and add in each of the seven other steps of our octagon/circle. Once we have completed the circle we can have the CoDrone land.

So our final code should look like this: