Thymio-II interface: Differential kinematics

The latest upgrade to my Thymio interface has been differential kinematics. Basically this is turning the wheels at different speeds in order to move in an arc. The Thymio has 2 wheels with separate motors for each so the wheels can move at different speeds very easily and so this form of motion can be implemented.

I decided to implement this using 2 variables, the radius of the arc and the distance traveled. With this information i can calculate the time the Thymio should move for and the speed of the wheels.

Previously i gave the user the ability to set the wheel speed so we can make use of that in the calculations. To calculate the individual speed we can do the following: set the outer most wheel to move at the wheel speed set by the player, calculate the difference between the length of the arcs of each wheel and then multiply the wheel speed by that difference.

In this example lets say the radius is 10cm and the length to travel is also 10cm. Looking up the specs of the Thymio we find that the width of it is 11cm, and as we want to use the middle of the wheels we can say that the difference is 10cm. The Thymio should move about 3cm/s at a speed of 100.

Calculating the time to move can be done in the following way. First we need to calculate theta (the angle we will me moving) by doing the length traveled divided by the radius, this will give us the angle in radians and works because finding the circumference of a circle  equals 2*pi*radius. That basically means that the 360 degrees (the full circle) is equal to 2*pi. to simplify this means that the angle equals the length divided by the radius. Now we know the angle we'll be traveling  we need to know the speed the center of the robot will travel. Theta * the radius (radius to the center) divided by theta * (radius + 5) will give us the difference between the 2 arcs. We can then times this number by the wheel speed to get the speed at the center and then we can divide this by 33.33 (speed of 100 = 3cm/s so speed/33.33 = speed in cm/s) to get the speed in cm per seconds. finally we can divide by the speed and the do 1 over this result to get the time to wait for the action to finish.
In our example this means theta is 1 and the difference will be 0.66 recurring and if the speed is 100 then the time we will need to wait will be 4.999 seconds

1/(((10/15 * 100 )/33.33333)/10)

Calculating the speed is very similar but instead of the radius +5 and the radius, we will use the radius-5. with the outer wheel moving at "wheelspeed" and the inner wheel moving at wheel speed * the difference.

That was quite a block of text but the result is that the center of the Thymio (the pen holder) will move the required distance in an arc.

The video below shows an example of this in action.

In the video i made use of a pi to run the python code. In the code there is a line which defines the IP address of the scratch serve the code should communicate with, by setting  this to the IP address of my laptop running the scratch code I can control it remotely.

To get the code running i used tight vnc to look at the Raspberry Pi's desktop remotely. I started the remote viewing using putty to communicate with the pi over ssh, I had to delete the .Xauthority in order to run the python as there was a conflict with running dbus. the file can be deleted by typing the following:

cd ~

sudo rm .Xauthority

Unfortunately this needs to be done every time you start up vnc on the pi