This tutorial series will explain how we can make polygonal and circular orbits using a differential wheeled robot. You'll go through some examples of regular polygons and circles, first done by using mathematics, and then by running some SimpleIDE code examples. These tutorials are meant to be done on Parallax's ActivityBot, but the concepts can be extended to various other robots (like the S2), with some modification.
First, we'll need to study and analyze the problem of how to program rotation. We should be able to program the robot to rotate to the correct direction (clockwise or counterclockwise) corresponding to the various angles 0 ° < ω < 360 ° that we want to turn.
Rotation of ActivityBot ω degrees
In Go Certain Distances, you can see that the drive_goto(26, -25) command makes the ActivityBot execute a 90-degree right turn. Let’s see this example in closer detail and try to create a mathematical formula to calculate the appropriate number of “ticks” that correspond to some angle ω.
As the ActivityBot makes a rotation, it moves its wheels on the red circle (radius: 52.9 mm). If the robot makes a turn equal to 1 radian (rad), each wheel will move a distance equal to the radius r of the red circle. Thus 1 rad rotation of the ActivityBot is equivalent to movement of the wheels of distance:
r =52.9 mm = 52.91/3.25 ticks = 16.2769 ticks
Changing rad to degrees, we take the formula:
Ticks for Angle = ω * 0.284
So if we want to program the ActivityBot to rotate ω degrees we can multiply by 0.284 in order to find the appropriate number of wheel ticks.
To verify the above formula, we can see that a rotation of 90 degrees = 90 * 0.284 ticks = 25.56 ticks = 26 ticks (rounded up).
In the image above, there is a table that has useful information for the coming activities. Below we have provided an enlarged view of it:
In the chart, the text under "ActivityBot command" reads: for counterclockwise rotation, change the signs. This means that to reverse the direction of motion, change positive values to negative, and negative values to positive. For example, drive_goto(34, -34) would become drive_goto(-34, 34), etc.