**Course 6 / Lecture 8:**

# Predict the result of a robot race

This lecture will teach you how to predict the result of a speed race. You will have two robots started from different distances. They will go at different speeds. Your job will be to find out which robot will reach the finish line first. This lecture teaches maths and provides directions to create robot control program code to verify results.

**Figure 1** - Predict the result of a robot race

## Requirements

- Ruler
- 2 Sniffers: http://www.ozeki.hu/index.php?owpn=6204
- Ozeki 10 installed: http://www.ozeki.hu/index.php?owpn=6066
- Snap basics: http://www.ozeki.hu/index.php?owpn=6180

## Measure the speed in meter/second!

In this lecture you need to know the robot's speed in meter/second. For the
easier calculations you should measure the maximum speed of the Sniffer. During
*Lecture 4*, you learned how to measure speed, so you should load the stopwatch
program code and replace the power percentage of the motor to 100 as **Figure 2.1**
demonstrates then run it. After you measured the traveled distance, you should
calculate the speed by using the measured distance and the value in the
'passed' variable.

**Figure 2.1** - Measure the full speed of both robot

There is a chart about speed values at different power. If you took the previous
step, the result of your calculations should be similar to the shown value at
100% power on **Figure 2.2**. On the chart you can see that the speed
increases proportionally with the increase in performance until
it reaches approximately 85% of power. Then performance increasing is very
small. Keep it in your mind when you calculate with different power percentages.

**Figure 2.2** - Measured speed at different power

## Place your robots toward the finish and measure target distance!

After you got to know your Sniffer's full speed, you should place
both robots on a flat surface in one direction, but
they are not next to each other and there is also some distance between them.
Then you should to mark the target line for your race.
Finally please measure the distance between your target line and both
robots. Write this two distance data down because you will need to
calculate which Sniffer reaches the target line first (**Figure 3**).
You can race with different robots if you wish.

**Figure 3** - The robots look toward the target

## Calculate the required times and predict which robot will win!

After you calculated your Sniffer's full speed, placed your robots
on a flat surface and measured the distances towards the target line, you
need to calculate how much time your Sniffers need to reach the target line.
To calculate the required time, you should express the time from the
velocity equation. So please multiply the velocity equation by the time and
divide it by the speed, as you did in *Lecture 4*.
Finally please write the equation for both robots (using indices),
because your Sniffers will move different distances with different speed.
Look at **Figure 4** for help.

**Figure 4** - Calculate the required time for each robot racer

There are some obvious cases when you can predict the winner without any
calculation. The closer Sniffer wins if it is faster or has the same speed
as the further Sniffer. But if the further Sniffer is faster than the closer
one, you need to calculate the racing time for each robot by using the
equation from the previous step. If the further Sniffer needs less time to
reach the target line, it will win the race. If the results of the
calculations are equal, the race will result in a draw, otherwise
the closer Sniffer will win the race. The **Figure 5** demonstrates these
cases. It all depends on the time towards the finish line.

**Figure 5** - The time towards the finish line decides the winner

## Test your calculations by running and modifying the program from the previous Lecture!

After you learned how to predict the outcome of the race, you should perform
concrete calculations and test it with your program. So you should open
your SNAP and load the program you coded during *Lecture 7* and modify the
speed values as you wish. For the real race please set bigger speed for
the further Sniffer. There is an example on **Figure 6**.
After that please calculate the required time for both Sniffers using the
equation from *Task #3*. Finally make a prediction from the time
values and test it by starting the race.

**Figure 6** - Program code to control Sniffers

## Program codes

**Figure 7** - The program codes

Download the SNAP programsThe first one helps you to calculate the speed of the robot by measing the passed time. The second one gives you an ability to start both robots at the same time. It is easier to follow the guide if you have the codes in front of you: Download the SNAP program files |

## More information