Thymio II inertial platform

Two motors can be used to drive two wheels, or to tilt in two directions. This example shows a structure which allows Thymio II to tilt in two mutually perpendicular axes in the horizontal plane. Thymio II rotates along an axis relative to a frame and the frame moves relative to a base structure along a second axis perpendicular to the first. This gives the following construction: One wheel is used directly (via a reduction) to tilt the robot along an axis relative to a frame. A compact construction follows. Note that the last axis in the frame is fixed, so that the last big gear (on the left) of the reduction gears is fixed to the frame. Since the second axis has to be perpendicular to the first, the robot's second wheel has to transmit its movement around the edge of the frame so as to tilt a second perpendicular axis which is between the frame and the base structure of the whole construction. Here too the last gear (visible in the transparent support which is fixed to the frame) is fixed to the support. A small detail of the construction: the transmission of this movement over such a distance cannot be very rigid. To reduce the effect of this lack of rigidity on the precision of rotation about the axis, it is important to multiply (and not to reduce) the movement between the robot's wheel and the transmission (here on the right), then to have a substantial reduction at the end, here by using a worm gear. In this configuration Thymio II can turn along two axes. It can do this, for example, to maintain the black baton above it in a vertical position by reading the accelerometers like this:

``````var accTampon0 = 0,0,0,0
var accTamponPos0 = 0
var accTampon1 = 0,0,0,0
var accTamponPos1 = 0
var sumacc0
var sumacc1

onevent acc
accTampon0[accTamponPos0] = acc-2
accTamponPos0 = (accTamponPos0 + 1) % 4
sumacc0 = accTampon0 + accTampon0 + accTampon0 + accTampon0
accTampon1[accTamponPos1] = acc
accTamponPos1 = (accTamponPos1 + 1) % 4
sumacc1 = accTampon1 + accTampon1 + accTampon1 + accTampon1

motor.left.target=-sumacc0*10
motor.right.target=sumacc1*20```
```

All together this gives the following behaviour: