Getting started with Aseba

This page teaches you how to get started with Aseba if you do not have any physical robot. If you have a Thymio II, there exists a specific page.

To start, launch challenge

Aseba challenge (right image) is a simulated world where Aseba-controlled robots compete for food. You can use it as a playground to explore writing Aseba programs or as an educational game to learn and teach programming.

To get started, you have to launch Aseba challenge. If Aseba is not yet installed, please follow the installation instructions. Once challenge is started, you have to click on “Add a new robot”, and to choose a name for it.

asebachallenge.png

If you are a group, you have to add one robot for each player. You can remove all the robots by clicking “Remove all robots”. You can hide the buttons by checking “Auto hide”: the buttons will only show up when the mouse pointer is around them.
You can have the camera move automatically by checking “Auto camera”. If you are moving the camera manually, the controls are the following:

  • ctrl + left mouse button: rotate view
  • ctrl + shift + left mouse button: displace view on x/y
  • ctrl + shift + right mouse button: displace view on z

Challenge shows the score of each robot on translucid boards hanging over the arena. The goal is to stay alive by collecting energy.

studio-connect-en.png

As long as a robot is alive, its points increase; when it dies, they are halved. Four blue sources provide energy to nearby robots. When a source is depleted, it becomes red and does not provide energy any more. From time to time, a source will sink into the ground and robots will no longer see it until it reappears.

Once Aseba challenge is running, you have to start Aseba studio to program your robot. For each robot, you have to run one instance of studio, which can run on any computer. At startup, studio proposes you to connect to an Aseba target (right image). If you have launched challenge on your computer and added a robot, the default option will connect to this robot. If challenge is running on another computer, or if there are several robots in the arena, please specify the computer in host and the robot in port. The translucent screen over the arena in challenge shows the ports corresponding to the different robots

Your first robot controller

studio-challenge-en.png

Once studio is running (right image), you can edit the robot's program in the centre area. The latter is a program editor which checks and compiles your program in real time, telling you whether the program's syntax is correct or not. You can learn more about studio in the menu Help->Studio. The menu Help->Language provides a detailed documentation of the Aseba programming language.

To program a robot, you first have to understand how it works. A robot interacts with the world in a loop: it perceives the state of the world through its sensors, takes some decisions with its onboard computer, and performs actions with its actuators; these actions change the state of the world, and the robot perceives this new state when it reads its sensors again.

In challenge, you program a simulated e-puck robot. This robot has 8 proximity sensors around its body and a simple camera of 3 pixels pointing forward, with an aperture angle of 20° per pixel. You can read these values and also choose the speed of the wheels:
epuck-sensors-wiki-en.png

Now, let us write your first robot controller. In the text editor in the middle of the studio window, write the following lines:

wheel_left_speed = 5
wheel_right_speed = -5

Click “Load” and then “Run”. You should see your robot turning on the spot. This code just sets the speed of the wheels when the robot starts and then does nothing. To have a better behaviour, we should allow the robot to perceive its environment, for instance any obstacles; and make decisions, for instance to avoid the obstacles.

To interact with the world continuously, the robot must execute a program periodically. This is achieved with the onevent timer keywords. For instance, using a front proximity sensor, we can set the speed of the wheels with respect to the distance to the object in front of the robot:

onevent timer
wheel_left_speed = dist[0] - 6
wheel_right_speed = dist[0] - 6

Click “Load” and then “Run”. As the proximity sensors return a distance between 0 to 12 cm (if the object is farther than 12 cm, they nevertheless return 12), the speed of the robot will be -6 cm/s when the object is close, 0 cm/s when the object is 6 cm away, and 6 cm/s when the object is far away. The robot will thus tend to stay 6 cm away from any object in front of it.

A more elaborate robot controller

Keeping a safe distance to an object in front is good, but right now the robot cannot move elsewhere. To have the robot wander around, we need to understand how it moves.

The simulated e-puck robot in challenge is an example of a differential wheeled robot; this type of robot changes its direction by setting different speeds for its right and left wheels. If each wheel has the same speed, the robot goes forward; otherwise it turns; if the speeds are in opposite directions, the robot turns on the spot. Industrial caterpillar vehicles use the same movement modality.

Let us write a small code that makes the robot avoid obstacles and go straight ahead otherwise:

onevent timer
wheel_left_speed = dist[1] - 6
wheel_right_speed = dist[6] - 6

This controller looks at the front left and front right proximity sensors. As long there is no obstacle, both dist[1] and dist[6] report 12 and thus the robot goes forward at speed 6. But when there is an obstacle at one side, the value of the corresponding sensor goes down. For instance, if there is an obstacle on the left, dist[6] (which looks to the left) could be 10 but dist[1] (which looks to the right) will stay at 12; and thus wheel_left_speed would still be 6 but wheel_right_speed would be 4, causing the robot to turn to the right and thus avoid the obstacle on its left.

Taking decisions

The controllers we have seen so far link the values of the sensors to the speed of the wheels through mathematical expressions, but do not make “if, then” choices. Yet this is sometimes desirable; for instance if we want the robot either to go straight or to turn on the spot, but not perform curved trajectories, we can write:

onevent timer
var dists = dist[6] + dist[7] + dist[0] + dist[1]
if dists < 48 then
    wheel_left_speed = 5
    wheel_right_speed = -5
else
    wheel_left_speed = 5
    wheel_right_speed = 5
end

This controller sums the distances of the 4 front proximity sensors, and if this sum is below 48 cm, which means that at least one of the sensor sees an obstacle, the robot turns on the spot. Otherwise, it goes straight ahead.

The Aseba programming language provides other interesting constructs, such as the while loop, which executes a block of code repeatedly as long as a condition is true, or the for loop, which executes a block of code a certain number of times and changes the value of a variable each time. The menu Help -> Language gives access to a page which lists all available constructs together with examples; feel free to have a look.

Your turn

Play for a while with obstacle avoidance in order to get a good understanding of the sensors, actuators and dynamics of the robot. Feel free to explore, the robot is in a simulator and does not risk being harmed.

Once you feel confident, try to make the robot direct itself to the food sources when they are blue (0, 0, 100) (in R, G, B), and avoid them when they are red (100, 0, 0). The colour of the background is gray (50, 50, 50). Try to play with your friends and to get the best robot controller. You can change the colour of your robot (by changing variables color_red, color_green and color_blue), and thus pretend to be a food source. If the others trick your robot like this, check the energy variable; if it is not increasing while seeing blue, you are being tricked.

The goal of challenge is to learn robotics, programming, and Aseba while having fun.

What to read next?

You might be interested to read:

en.giffr.gifde.gifes.gifit.gifzh.gif
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License