Register to receive free access to all teacher materials.
Turn your Finch using geometry and encoders!
Free Teacher Materials
INTERMEDIATE: Add Sensors
Required lessons: Encoders
You can use the encoders in the Finch to have the Finch draw circles. Imagine that the left Finch wheel is stationary while the right wheel is moving. The Finch will then move in a circle of radius w, where w is the width of the robot, which is 10 cm. The circumference of this circle is 2 * π * 10, or 20π cm.
Finch wheels have a diameter of 5 centimeters, so one full rotation of the Finch’s wheel will move that wheel by 5π cm. Write a program to move the Finch’s right wheel the correct number of rotations so that the Finch moves once in a complete circle.
Hint: Your robot will be more accurate at low speeds.
While we worked out the geometry when one wheel is not moving, you can also use this math for a more general situation. If the speeds of the right and left wheels are both positive but not equal, you can calculate the difference between the number of rotations of the right wheel and the number of rotations of the left wheel. When this difference is greater than the number of rotations you calculated above, the Finch will have turned 360°.
Modify your program so that the Finch turns 360° when the right wheel is moving at 40% and the left wheel is moving at 20%.
ADVANCED: Going Further
Required lessons: Control Structures & Line Tracking, Variables, Modularity
In this lesson you will create two modules that turn the Finch in an arcing motion. You can use the encoders in the Finch to find out how far the Finch has turned. This requires some geometry!
Activity 1: Turning with one wheel stationary
You will create a module that allows the user to turn the Finch along an arc, with the left wheel stationary while the right wheel is moving. This causes the Finch to move in a circle of radius w, where w is the distance between the Finch’s two wheels.
The distance that the right wheel moves, which we call d, is an arc length along that circle. That arc length is the width times the angle θ that the robot has turned. That angle is in radians. We can convert it to degrees by multiplying it by the conversion factor π/180°. We can then solve for d, as shown below. This equation enables us to find out how far the Finch has turned based on the distance the right wheel has moved and the distance between the Finch’s wheels, which is 10 centimeters (cm).
The equation above tells you the distance that the Finch wheel needs to travel to make the Finch turn an angle θ. You can convert this to a number of wheel rotations by dividing d by the circumference of the Finch wheel. To do this, you need to know the diameter of the Finch wheel, which is 5 cm, making the circumference of the Finch wheel 5π cm.
Use the information above to create a module that is given an angle as input and makes the Finch turn that angle. The robot should turn with the left wheel stationary and the right wheel moving. Hint: Your robot will be more accurate at low speeds.
Activity 2: Making an arc with both wheels in motion
While we worked out the geometry with one wheel stationary, you can actually use the math from activity 1 for a more general situation. If the speeds of the right and left wheels are both positive but not equal, you can calculate the difference between the number of rotations of the right wheel and the number of rotations of the left wheel. When this difference is greater than the number of rotations you calculated above, the Finch will have turned the desired angle.
Create a module that takes three inputs: the angle to turn, the speed of the left wheel, and the speed of the right wheel. The Finch should turn the given angle with the given wheel speeds. Make sure to test your module for different speed combinations!