Introduction

Presenting the Thymio II
The Thymio II is an educational robot jointly developed at [url=http://www.epfl.ch]EPFL[/url] and [url=http://www.ecal.ch]ECAL[/url] in Lausanne, Switzerland.[br][br]The Thymio robot presents three main features:[br]- a large number of sensors and actuators[br]- interactivity based on light and touch[br]- a programming environment featuring graphical and text programming

Moving the robot

In the previous exercice we were drawing the outline of the robot based on the pair [math](A, \theta)[/math]. Now we are going to build a a simple script to animate the robot. The robot uses differential steering, which means the left motor runs at speed [math]v_0[/math] and the right motor at speed [math]v_1[/math]. From this we can calculate the forward speed [math]v_f=\frac{v_1+v_0}2[/math] and also the differential speed [math]v_d=\frac{v_1-v_0}2[/math] In order to animate the robot we add 3 buttons: - [b]Reset[/b], which sets [math]A=(0,0)[/math] and [math]\theta=0[/math] - [b]Start[/b], which starts the animation (StartAnimation[true]) - [b]Stop[/b], which stops the animation (StartAnimation[false]) We also add an animation script to the (invisible) time slider: A=A+v*v_f*dt θ=θ+ω dt Set two motor speeds [math](v_0, v_1)[/math] and press the [b]Start[/b] button. Observe the trajectory of the two wheels.

Try to create your own robot animation. Add buttons to turn left/right and other buttons to accelerate/decelerate.

Staying inside a rectangle

How can simulate sensor input to change the behavior of our robot ? Use the position of the ground sensors and check if it falls within the boundaries of a rectangular area. For this we define two boolean values [math](out_0, out_1)[/math]to see if the sensor position [math](C_0, C_1)[/math] is inside the rectangle defined by the points [math](F_0, F_1)[/math] [math]out_0=(x(C_0) < x(F_0)) ∨ (x(C_0) > x(F_1)) ∨ (y(C_0) < y(F_0)) ∨ (y(C_0) > y(F_1))[/math] [math]out_1=(x(C_1) < x(F_0)) ∨ (x(C_1) > x(F_1)) ∨ (y(C_1) < y(F_0)) ∨ (y(C_1) > y(F_1))[/math] We use this information inside the animation script of the slider time [b]t[/b] to determine if the robot needs to turn. A=A+v*v_f*dt If[out_0, SetValue[θ, θ-dθ],If[out_1, SetValue[θ, θ+dθ]]] To give a visual feedback when the sensor is outside the rectangle, we momentarily increase the size from 3 to 15. SetPointSize[C_0, If[out_0, 15, 3]] SetPointSize[C_1, If[out_1, 15, 3]]

Intersecting a line

Programming hints
Place the robot at the starting position and monitor the sensors [math](C_0,C_1)[/math]. Calculate the distance to the black line. From the time difference in the two signals, use trigonometry to calculate the angle under which the robot hits the black line. Program the robot to turn and continue perpendicular after the line.
Preview of the printed A4 sheet

Information