Thymio Explorer

This page describes the realization of an exploration vehicle based on a mechanical structure made ​​of well known plastic bricks, the engines and sensors of the Thymio, all controlled by a Raspberry PI with Linux and Wi-Fi, powered by a solar battery.

The final vehicle has the following shape:

full-explo-square.jpg

The following sections describe briefly how to implement this vehicle from a mechanical point of view, electronic (connections) and software. Software options may vary, as long as the vehicle has an embedded computer with Linux, but we only show a few possibilities.

Mechanical structure

In order to realize the mechanical base caterpillars, we looked at the first step of the instructions for the vehicle of the following box:

base-box.jpg

Thus we kept only the caterpillar's supports and the base structure that links the two caterpillars

The base chassis was then modified according to the following points :

  • enlargement to have more distance between the tracks
  • creation of a platform to support Thymio II and the Raspberry PI
  • mechanical support for the Thymio II
  • link between the wheels of the Thymio II and the caterpillars in order transmit the motion
  • support for the box of the Raspberry PI (to allow connections)
  • support for the camera of the Raspberry PI
  • support for the solar battery

Combined together, these modifications give the following version:

chassis-explo.jpg

The bottom view offers a better view of the caterpillars and the spacing between them, as well as the base structure:

botton-chassis.jpg

The front view allows you to see the structure that supports the chains between platform and caterpillars. In order to realize this link, the frontal axis of the caterpillars was replaced in order to lengthen inwards:

front-chassis.jpg

The side view allows you to see the upper structure with the supports for Thymio II on the right, the support for the Raspberry PI in the middle and the support for the battery on the back:

lateral-chassis.jpg

Thymio II was mounted on the front of this base through the lateral cross supports

thymio-installed.jpg

The mechanical connection to activate the caterpillars from Thymio II wheels is made via chains and gears. Different possible diameters can offer a slight reduction between the wheels of Thymio II and caterpillars:

links-chains.jpg

Here is a view of the inside of the chain that goes to the caterpillars, hidden in the previous image:

link-to-track.jpg

In order to obtain a more lively system (:-), we have placed two cabins with the drivers on the Thymio II by fixing them on the top face :

cabines-installed.jpg

The Raspberry PI can be placed on the back of the Thymio II

pre-raspberry.jpg

The vehicle is equipped with a camera linked to the Raspberry PI. No holes for this connection were planned on the box of the Raspberry PI, therefore we have created an opening in the upper part of the box.

The camera has to be fixed somewhere with a rigid link. A support for the camera was made and can be fixed to the chassis and its orientation can be changed

camera-supp-details.jpg

The Raspberry PI is fixed to the chassis

pre-wiring-thy-RP.jpg

Once the Raspberry PI installed, we can connect to Thymio II through a short USB cable and fix the camera

connection-thymio.jpg

The camera is facing the front of the robot, between the two cabins. The opening angle is narrow enough so the cabins are not in its field of view.

front-cockpit.jpg

The Raspberry PI is powered by a solar battery (which is also USB rechargeable):

solar-battery.jpg

The battery is placed in the rear of the vehicle on a slope for this purpose:

pre-battery.jpg

So at the end we obtain the following vehicle

full-explo-square.jpglateral-view.jpgfront-view.jpg

Raspberry PI wiring

The connection to the battery is done through a short USB cable:

battery-connection.jpg

The connection between Thymio II and the Raspberry PI is done through USB. The second USB port is used for the WiFi

USB-raspberry-pi.jpg

The system can be recharged using sunlight

recharging-sun.jpg

Installation of the Raspberry PI

To start with the Raspberry PI, we have followed the suggestion of
http://techcrunch.com/2012/10/21/getting-started-with-the-raspberry-pi-is-not-as-easy-as-pie/

Primarily we chose to install “Raspbian wheezy”, which was a pretty good option
(page de downloads).

In order to format and flash the SD card so as to install “Raspbian wheezy”, the information can be found here
http://www.andrewmunsell.com/blog/getting-started-raspberry-pi-install-raspbian (for more information: http://elinux.org/RPi_Easy_SD_Card_Setup ).

Once the SD card is ready, we can start the Raspberry PI. For the configuration, we plugged screen, mouse and keyboard to the Raspberry PI. We used a USB Hub as there are only two USB ports on the Raspberry PI. One suggestion is to connect the hub with keyboard, mouse etc. on one of the USB ports and the Wi-Fi in the other one. For the Wi-Fi we chose Edimax ew-7811un which is compact, cheap and compatible with the Raspberry PI. Some advice for its setup can be found here: http://www.frodebang.com/post/how-to-install-the-edimax-ew-7811un-wifi-adapter-on-the-raspberry-pi

We have mainly edited /etc/network/interfaces in order to have a fixed IP address on the Raspberry PI. Then the file looks like this:

auto lo

iface lo inet loopback
iface eth0 inet dhcp

allow-hotplug wlan0
iface wlan0 inet static
address <FIXED IP ADDRESS> 
netmask 255.255.255.0
gateway <ROUTER IP ADDRESS>

wpa-ssid <YOUR SSID>
wpa-psk <YOUR PASSPHRASE/KEY>

With this configuration, we can have a totally independent robot that connects to an Access Point and we can connect to it using a ssh pi@<FIXED IP ADDRESS> and the password of the Raspberry PI user (by default the password is raspberry)

It is important also to configure your PC with a fixed IP address to access your Raspberry PI. You can test the connection using for example Putty on Windows. More information can be found here:
http://zaidpirwani.com/1290/raspberry-pi-setting-up-for-electronics-and-development-work/

Control of Thymio II

On the page https://aseba.wikidot.com/en:linuxinstall#toc4 you can find a package for the installation of Aseba Studio and the tools to connect to Thymio II from your Raspberry PI.

You can download this package directly from the Raspberry PI or copy this package from your computer with the following command:

scp aseba_1.3.1_armhf.deb pi@<FIXED IP ADRESS>:~/.

For installing:

sudo dpkg -i aseba_1.3.1_armhf.deb

Some packages may be missing, they have to be installed with the following command :

sudo apt-get -f install

Once the various tools for Aseba are installed, Thymio has to be physically connected to the Raspberry PI. The connection is done using USB. If you want to check if Thymio II is connected, you can show the list of USB devices using the following command:

lsusb

There should be a device from the École Polytechnique Fédérale de Lausanne

You can check this connection using the command:

dmesg | tail

and list the new devices that appeared by using:

ls /dev/ttyACM*

At this point you can start Aseba Studio on your Raspberry PI, but this is not the goal for this project. What we want to do is connect to Thymio II and exchange messages with it from any place using wireless connection. As the serial port can be accessed only locally, it is interesting to create a local switch that allows you to connect to Thymio II using this switch from any place. In order to start this switch on the Raspberry PI, you can use the command:

asebaswitch "ser:device=/dev/ttyACM0"

by supposing that your Thymio II is the device /dev/ttyACM0.

When the switch is running on your Raspberry PI, you can start Aseba Studio on your computer and connect through the network (TCP) to the fixed IP address of your Raspberry PI. You should be able to access your Thymio II.

Monitoring proximity sensors

The following code (Here the file that can be downloaded) allows you to control Thymio II using buttons, IR remote control and events. By using the same events we can realize interesting graphics of inner variables, for example the values of the proximity sensors.

var turnleft = 0
var turnright = 0
var yellowl = 0
var yellowr = 0

call sound.system(-1)
call leds.top(0,0,0)
call leds.bottom.left(0,0,0)
call leds.bottom.right(0,0,0)
call leds.circle(0,0,0,0,0,0,0,0)
call leds.top(32,32,0)
call leds.bottom.left(32,32,0)
call leds.bottom.right(32,32,0)
timer.period[0] = 500

onevent buttons         # commande avec boutons
    if button.forward == 1 then
        motor.left.target = -500
        motor.right.target = -500
        turnleft=0
        turnright=0
    end
    if button.backward == 1 then
        motor.left.target = 500
        motor.right.target = 500
        turnleft=1
        turnright=1
    end
    if button.left == 1 then
        motor.left.target = 500
        motor.right.target = -500
        turnleft=1
        turnright=0
    end
    if button.right == 1 then
        motor.left.target = -500
        motor.right.target = 500
        turnleft=0
        turnright=1
    end
    if button.center == 1 then
        motor.left.target = 0
        motor.right.target = 0
        turnleft=0
        turnright=0
    end

onevent rc5        # commande avec télécommande IR
    if rc5.command == 32 then
        motor.left.target = -500
        motor.right.target = -500
        turnleft=0
        turnright=0
    end
    if rc5.command == 33 then
        motor.left.target = 500
        motor.right.target = 500
        turnleft=1
        turnright=1
    end
    if rc5.command == 17 then
        motor.left.target = 500
        motor.right.target = -500
        turnleft=1
        turnright=0
    end
    if rc5.command == 16 then
        motor.left.target = -500
        motor.right.target = 500
        turnleft=0
        turnright=1
    end
    if rc5.command == 13 then
        motor.left.target = 0
        motor.right.target = 0
        turnleft=0
        turnright=0
    end

# commande avec évènements

onevent forward
        motor.left.target = -500
        motor.right.target = -500
        turnleft=0
        turnright=0

onevent backward
        motor.left.target = 500
        motor.right.target = 500
        turnleft=1
        turnright=1

onevent left
        motor.left.target = 500
        motor.right.target = -500
        turnleft=1
        turnright=0

onevent right
        motor.left.target = -500
        motor.right.target = 500
        turnleft=0
        turnright=1

onevent stop
        motor.left.target = 0
        motor.right.target = 0
        turnleft=0
        turnright=0

# clignotement à droite, gauche et arrière:

onevent timer0
    if turnleft==1 then
        if yellowl==0 then
            yellowl=1
            call leds.bottom.left(32,32,0)
        else
            yellowl=0
            call leds.bottom.left(32,0,0)            
        end
    else
        call leds.bottom.left(32,32,0)
    end

    if turnright==1 then
        if yellowr==0 then
            yellowr=1
            call leds.bottom.right(32,32,0)
        else
            yellowr=0
            call leds.bottom.right(32,0,0)            
        end
    else
        call leds.bottom.right(32,32,0)
    end

# évènements qui permettent d'exporter des valeurs:

onevent acc
    emit accelerometer(acc)

onevent prox
    emit light prox.ground.ambiant[0]
    emit proxfront prox.horizontal

Here are some examples of situations when we have visualized the graphs of three different events: accelerometer, light and proxfront. If you want to make graphs using the values sent by an event, select the event and click on the icon graph on top of it. A new tab will appear with the graphic next to the tab of the code

Path on a hill, measure of the accelerometer

The fact that the robot is moving on a hill can be detected by the accelerometers, which measure the orientation of the gravity vector direction.

Here is a picture of the test which was made:

hill.jpg

If we plot the three accelerometers' axes, we obtain the following graph:

hill-graph.png

We can observe a lot of noise due to the motion of the robot. The red axis, horizontal and perpendicular to the direction of the robot keeps the same value, while the values of the two other axes change in function of the slope

Detect light

The ambient light can be measured using the two sensors of the Thymio II that are facing the floor. Here the sensors can measure the diffused light that is reflected by the floor. Using a white floor and lateral sunlight, the measure varies depending on the robot orientation.

Here is a picture of the test which was made:

sun.jpg

If we plot one of the light sensors, we obtain the following graph:

sun-graph.png

A variation of the measure depending on the robot's orientation can be observed.

Front proximity sensors

The front sensors of Thymio II allow to measure the distance from obstacles.

Here is a picture of the test which was made:

obstacle-dect.jpg

If the values of the proximity sensors are plotted while the robot is moving towards the obstacle and stopped when the obstacle is very close, we obtain the following graph:

obstacle-dect-graph.png

Three sensors are detecting obstacles in this example.

Wireless camera

The official description showing how to use the camera of the Raspberry PI is: http://www.raspberrypi.org/camera

The instructions can be used to take a picture or save a video file. But the instruction to create a video stream on MAC are not updated, because the compiled version of the MPlayer mentioned in this page is not working for a MAC Intel ….

It is therefore more reliable to use VLC (according to http://www.mybigideas.co.uk/RPi/RPiCamera/ ). On Raspberry PI, you can install VLC with the command:

sudo apt-get install vlc

Then you can create a video stream with the command

raspivid -o - -t 0 -w 920 -h 540 |cvlc -vvv stream:///dev/stdin --sout '#rtp{sdp=rtsp://:8554/}' :demux=h264

On your MAC, you have to open a network stream to the address:

rtsp://<IPofRaspberryPi>:8554/

This type of video stream creates a delay of ~ 3 seconds, it was not possible to do better…but if you have an idea, you are welcome!

Behaviour programming

The behaviour of the robot can be programmed

  1. on Thymio II using ASEBA language
  2. on the Raspberry PI, using python, C, C++
  3. on a PC that is controlling the robot remotely, using python, ROS, …

If you have some examples, you can add them here!

Video illustrating the different aspects

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License