Program with aseba

Get total control with text programming

Get started

Plug Thymio to the computer with the USB cable or with the USB dongle and turn Thymio on by pressing 3 seconds on the central button

Launch “Thymio Suite”

Click on the Aseba Studio icon

First steps with text programming

Take a look at the reference card and check the documentation. Here is a basic example.

View the full documentation

Examples

# reset outputs
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)

# Thymio moves forward when you press the forward button onevent buttons
when button.forward == 1 do
motor.left.target = 200
motor.right.target = 200
end

# if the ground sensors detects nothing Thymio becomes red otherwise he becomes green
onevent prox
if prox.ground.delta[0] <= 400 or prox.ground.delta[1] <= 400 then
motor.left.target = 0
motor.right.target = 0
call leds.top(32,0,0)
else
call leds.top(0,32,0)
end

# reset outputs
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)

onevent prox
when prox.horizontal[2] >= 2000 do
motor.left.target = 350
motor.right.target = 350
end

when prox.horizontal[0] >= 2000 do
motor.left.target = 0
motor.right.target = 500
end

when prox.horizontal[4] >= 2000 do
motor.left.target = 500
motor.right.target = 0
end

when prox.horizontal[0] <= 1000 and prox.horizontal[1] <= 1000 and
prox.horizontal[2] <= 1000 and prox.horizontal[3] <= 1000 and
prox.horizontal[4] <= 1000 do
motor.left.target = 0
motor.right.target = 0
end

Thymio stops at the border of the table

# reset outputs                                        moblie                                     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)

   # Thymio moves forward when       you press the forward button             onevent buttons

   when button.forward == 1 do                                                                                motor.left.target = 200                                                                                             motor.right.target = 200                      end                                 

   # if the ground sensors detects       nothing Thymio becomes red           otherwise he becomes green           onevent prox                                          if prox.ground.delta[0] <= 400 or     prox.ground.delta[1] <= 400               then                                                          motor.left.target = 0                              motor.right.target = 0 

   call leds.top(32,                                     call leds.top(0,32,0)                              end   

Thymio follows your hand

  # reset outputs                                       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

  when prox.horizontal[2] >= 2000      domotor.left.target = 350                  motor.right.target = 350                end 

  when prox.horizontal[0] >= 2000      do                                                      motor.left.target = 0                                                                              motor.right.target = 500                   end 

  when prox.horizontal[4] >= 2000      do                                                     motor.left.target = 500                                                                            motor.right.target = 0                 end 

 when prox.horizontal[0] <= 1000   and prox.horizontal[1] <= 1000 and   prox.horizontal[2] <= 1000 and   prox.horizontal[3] <= 1000 and   prox.horizontal[4] <= 1000 do                                                       motor.left.target = 0                                                                             motor.right.target = 0                        end                                                                                                                                                                    

Controlling one robot with another – Example

Use a Wireless Thymio robot buttons to move another Wireless Thymio robot

Prerequisites

  1. You need to have two Wireless Thymio in the same network. Click here to learn how to do that 
  2. Launch Aseba Studio for Thymio. You should see two tabs. One of the Thymio robots will be the controller and the other will be the vehicle.

Global event

Before starting to code you need to create a global event. A global event is a message sent from one Thymio to the others in the same network. A global event has a name (we will call it “ button_emit”) and a number of arguments (Here we need 1 argument). We will define the values for the argument in the following code.

Code for the controller Thymio (tab 1)


# reset outputs
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)


# When a button is pressed we will change and emit the value of the global event “button_emit”
# We do that so we can get the value of “button_emit” with the other Thymio robot and react to it

onevent buttons

when button.backward == 1 do
emit button_emit -1
end

when button.center == 1 do
emit button_emit 0
end

when button.forward == 1 do
emit button_emit 1
end

when button.left == 1 do
emit button_emit 2
end

when button.right == 1 do
emit button_emit 3
end

Code for the vehicle Thymio (tab 2)

   # When the second Thymio robot get     the event “button_emit”

   onevent button_emit

   # We get the value of the first                   argument “[0]” (the count start at 0         and it’s the only one in our case) of         the global event
   # We associated every button to a        value. And now we program the              second Thymio to react when he get      thoses values.
  # For example, If the recieved value is     -1, it means the backward button             was   pressed. So, we make Thymio         go backward.

  if event.args[0] == -1 then
  motor.left.target = -200
  motor.right.target = -200

  # If the value is 0 then Thymio stops
  elseif event.args[0] == 0 then
  motor.left.target = 0
  motor.right.target = 0

  # If the value is 1, Thymio goes forward
  elseif event.args[0] == 1 then
  motor.left.target = 200
  motor.right.target = 200

  # If the value is 2, Thymio goes left
  elseif event.args[0] == 1 then
  motor.left.target = 0
  motor.right.target = 200

  # If the value is 3, Thymio goes right
  elseif event.args[0] == 3 then
  motor.left.target = 200
  motor.right.target = 0
  end

Click “Load all” and “Run all” to send the code to both robots and try it out.

Aseba is an open-source software created by Dr. Stéphane Magnenat with contributions from the community.

Something still not clear?

Visit our support center and get help from the Mobsya team!

Contact us

Describe your issue