OZEKI Robot

Course 6 / Lecture 1:

# Plan the travel distance

In this lecture you will learn how to convert the wheel turn angle to distance. You will see how to measure your robot's wheel's circumference and how to calculate the required motor rotation degree to move your robot by one meter. This lecture gives you very useful knowledge, that can be used in real life autonomous vehicle systems.

Figure 1 - Move your robot by 1 meter

## Draw a wheel and mark the circumference!

Circumference - the distance around something rounded. For example the wheel

Figure 2 - Circumference

## Draw a line of distance traveled when one rotation took place!

Figure 3 - The distance traveled on one full wheel turn is called circumference

## Write a program to rotate the motor by 360 degrees!

After opening SNAP from Ozeki 10, you should create an entry point for your motor's rotatory program. In this lecture you will use the 'when green flag clicked' control block as an entry point. To rotate your motors, you can use the 'Rotate [motors] by [degree_value] degree' block from the Lego motors category. Using this block you should move the Sniffer forward, therefore you only need to rotate both motors at the same time, so set [motors] to 'A+D' motors. You should turn around the wheels only once, so only 360 degree rotation is required on the motors, because one turn around is equivalent to 360 degree rotation. Therefore please set [degree_value] to 360 to finish the correct rotation program like you can see it on Figure 4 and measure traveling length in Task #4.

Figure 4 - Rotate a full round with your motors

## Measure the circumference with a piece of paper!

To measure the circumference first place your paper on a horizontal surface, such as on a table or floor. After that, place your Sniffer on it, so that the Sniffer will move along the paper longer side. Take your pen or pencil and mark the paper from where the wheels start moving. Start your program which you created in the previous step by clicking on the green flag. After the motors have stopped, please mark the wheels again and take the Sniffer of your paper. After that measure (in centimeters) the distance between the two marked place on your paper with a ruler (Figure 5). This value is your wheel's circumference. This is the basic unit in cars, to measure travel distance.

Figure 5 - Measure the circumference

## Calculate how many rounds the wheel should roll for 1 meter!

After that you got your wheel's circumference (measured in the previous step on the paper) you need to calculate how many times should the wheels turn around to travel exactly 1 m (Figure 6). First convert one meter to centimeters (100 centimeters), because you calculated the circumference in centimeters and because every time when you calculate with values with unit, it is very important that before calculating, convert them to the same unit. Finally divide it by the wheel's circumference to get how many times should the motors turn around to take one meter distance.

Figure 6 - How many rolls should a wheel make on 1 m

## Calculate how many degrees should the wheel turn for 1 meter!

After you calculated how many turns you need to move your Sniffer wheels around to travel 1 m (100 centimeters divided by the wheel's circumference in the previous step). Finally you should calculate how many degree is it, because Ozeki Snap requires the rotation angle and not the required turns. This calculation is very simple, because one turn around is exactly 360°. So if you multiply the number of full turns by 360 (Figure 7), you will get a rotation angle in degrees to move your Sniffer exactly 1 m.

Figure 7 - How much degrees should a wheel roll to travel the required distance

## Write code to help you measure the circumference of the wheel!

STEP 1: Make calculations in SNAP - create 3 variables

After you have calculated the exact angle with your calculator, you will calculate it in SNAP to move your robot by 1 m. As you did in the first step, use the 'when green flag clicked' block as an entry point of your program. Then create three variables called 'circumference' , 'degree' and 'turns_around'. To do this, select 'Variables', click on the 'Make a variable' button, type the variables name and finally choose 'Ok' (Figure 8).

Figure 8 - Create the following variables: circumference, turns_around, degree

STEP 2: Make calculations in SNAP - set variables

After you have created some variables in the previous step, you should set their values. You can set your variable's value by using the 'set X to Y' block, where X is the variable's name from the a dropdown list and Y is the variable's value. First set the 'circumference' to the value you measured as your Sniffer's wheel's circumference. As you calculated in the STEP 3, divide 100 by the circumference to get the number of turns, then you can set the 'turns_around' variable to this value, Finally set the 'degree' variable's value by selecting it's name and use the 'X x Y' multiplier, where X is the 'turns_around' variable and Y is 360 (Figure 9).

Figure 9 - Setting variables by adding values to them

STEP 3: Use calculations in SNAP - moving

After calculating the exact angle in your program, you should move your robot forward 1 m. For this, please use the 'Rotate X by Y°' block, as you did it in STEP 1, so please select the 'A+D' option and add the angle to Y (Figure 10). At the moment you finish this lecture, you are able to move your robot to a required distance by changing '100' to the cm value that is required by your Sniffer to move.

Figure 10 - Rotate motors in the calculated angle

## Program code

Figure 11 - Program code that calculates the angle and rotates the wheel