File: en_gettingstarted.html

package info (click to toggle)
aseba 1.6.99%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 18,328 kB
  • sloc: cpp: 44,160; ansic: 15,461; python: 1,597; javascript: 765; sh: 95; makefile: 57
file content (202 lines) | stat: -rw-r--r-- 12,662 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  <head>
    <meta name="generator" content="HTML Tidy for Linux (vers 25 March 2009), see www.w3.org" />
    <link rel="stylesheet" type="text/css" href="aseba.css" />
    <meta http-equiv="content-type" content="text/html; charset=utf-8" />
    <title>
      Getting started with Aseba
    </title>
  </head>
  <body>
    <h1 class="title">
      Getting started with Aseba
    </h1>
    <table id="toc-table" summary="TOC">
      <tr>
        <td>
          <div id="toc" class="floatright">
            <div class="title">
              Table of Contents
            </div>
            <div id="toc-list">
              <div style="margin-left: 1em;">
                <a href="#toc0">To start, launch challenge</a>
              </div>
              <div style="margin-left: 1em;">
                <a href="#toc1">Your first robot controller</a>
              </div>
              <div style="margin-left: 1em;">
                <a href="#toc2">A more elaborate robot controller</a>
              </div>
              <div style="margin-left: 1em;">
                <a href="#toc3">Taking decisions</a>
              </div>
              <div style="margin-left: 1em;">
                <a href="#toc4">Your turn</a>
              </div>
              <div style="margin-left: 1em;">
                <a href="#toc5">What to read next?</a>
              </div>
            </div>
          </div>
        </td>
      </tr>
    </table>
    <p>
      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 <a href="http://aseba.wikidot.com/en:thymioprogram">specific page</a>.
    </p>
    <h1 id="toc0">
      <span>To start, launch <em>challenge</em></span>
    </h1>
    <p>
      Aseba <em>challenge</em> (right image) is a simulated world where Aseba-controlled robots compete for food. You can use it as a playground to explore writing Aseba scripts or as an educational game to learn and teach programming.
    </p>
    <p>
      To get started, you have to launch Aseba <em>challenge</em>. If Aseba is not yet installed, please follow the <a href="http://aseba.wikidot.com/en:downloadinstall">installation instructions</a>. Once <em>challenge</em> is started, you have to click on “Add a new robot”, and to choose a name for it.
    </p>
    <div class="image-container floatright">
      <img src="asebachallenge.png" width="390" alt="asebachallenge.png" class="image" />
    </div>
    <p>
      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.<br />
      You can have the camera move automatically by checking “Auto camera”. If you are moving the camera manually, the controls are the following:
    </p>
    <ul>
      <li>ctrl + left mouse button: rotate view
      </li>
      <li>ctrl + shift + left mouse button: displace view on x/y
      </li>
      <li>ctrl + shift + right mouse button: displace view on z
      </li>
    </ul>
    <p>
      <em>Challenge</em> shows the score of each robot on translucid boards hanging over the arena. The goal is to stay alive by collecting energy.
    </p>
    <div class="image-container floatright">
      <img src="studio-connect-en.png" width="146" alt="studio-connect-en.png" class="image" />
    </div>
    <p>
      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.
    </p>
    <p>
      Once Aseba <em>challenge</em> is running, you have to start Aseba <em>studio</em> to program your robot. For each robot, you have to run one instance of studio, which can run on any computer. At startup, <em>studio</em> proposes you to connect to an Aseba target (right image). If you have launched <em>challenge</em> on your computer and added a robot, the default option will connect to this robot. If <em>challenge</em> is running on another computer, or if there are several robots in the arena, please specify the computer in <em>host</em> and the robot in <em>port</em>. The translucent screen over the arena in <em>challenge</em> shows the ports corresponding to the different robots
    </p>
    <h1 id="toc1">
      <span>Your first robot controller</span>
    </h1>
    <div class="image-container floatright">
      <img src="studio-challenge-en.png" width="390" alt="studio-challenge-en.png" class="image" />
    </div>
    <p>
      Once <em>studio</em> 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 <em>studio</em> in the menu <tt>Help-&gt;Studio</tt>. The menu <tt><a href="en_asebalanguage.html">Help-&gt;Language</a></tt> provides a detailed documentation of the Aseba programming language.
    </p>
    <p>
      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.
    </p>
    <p>
      In <em>challenge</em>, you program a simulated <a href="http://aseba.wikidot.com/en:e-puck">e-puck</a> 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:<br />
      <img src="epuck-sensors-wiki-en.png" alt="epuck-sensors-wiki-en.png" class="image" /><br />
    </p>
    <div style="text-align: right;">
      <p>
        <a href="epuck-sensors-wiki-en.svg">original svg file</a>, <a href="epuck-top-grayscale.png">background e-puck top</a>
      </p>
    </div>
    <p>
      Now, let us write your first robot controller. In the text editor in the middle of the <em>studio</em> window, write the following lines:
    </p>
    <div class="code">
      <pre>
<code>wheel_left_speed = 5
wheel_right_speed = -5</code>
</pre>
    </div><br />
    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.
    <p>
      To interact with the world continuously, the robot must execute a script periodically. This is achieved with the <tt>onevent timer</tt> 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:
    </p>
    <div class="code">
      <pre>
<code>onevent timer
wheel_left_speed = dist[0] - 6
wheel_right_speed = dist[0] - 6</code>
</pre>
    </div><br />
    Click “Load” and then “Run”. As the proximity sensors return a distance between 0 to 12&nbsp;cm (if the object is farther than 12&nbsp;cm, they nevertheless return 12), the speed of the robot will be -6&nbsp;cm/s when the object is close, 0&nbsp;cm/s when the object is 6&nbsp;cm away, and 6&nbsp;cm/s when the object is far away. The robot will thus tend to stay 6&nbsp;cm away from any object in front of it.
    <h1 id="toc2">
      <span>A more elaborate robot controller</span>
    </h1>
    <p>
      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.
    </p>
    <p>
      The simulated <em>e-puck</em> robot in <em>challenge</em> 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.
    </p>
    <p>
      Let us write a small code that makes the robot avoid obstacles and go straight ahead otherwise:
    </p>
    <div class="code">
      <pre>
<code>onevent timer
wheel_left_speed = dist[1] - 6
wheel_right_speed = dist[6] - 6</code>
</pre>
    </div><br />
    This controller looks at the front left and front right proximity sensors. As long there is no obstacle, both <tt>dist[1]</tt> and <tt>dist[6]</tt> 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, <tt>dist[6]</tt> (which looks to the left) could be 10 but <tt>dist[1]</tt> (which looks to the right) will stay at 12; and thus <tt>wheel_left_speed</tt> would still be 6 but <tt>wheel_right_speed</tt> would be 4, causing the robot to turn to the right and thus avoid the obstacle on its left.
    <h1 id="toc3">
      <span>Taking decisions</span>
    </h1>
    <p>
      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:
    </p>
    <div class="code">
      <pre>
<code>onevent timer
var dists = dist[6] + dist[7] + dist[0] + dist[1]
if dists &lt; 48 then
    wheel_left_speed = 5
    wheel_right_speed = -5
else
    wheel_left_speed = 5
    wheel_right_speed = 5
end</code>
</pre>
    </div><br />
    This controller sums the distances of the 4 front proximity sensors, and if this sum is below 48&nbsp;cm, which means that at least one of the sensor sees an obstacle, the robot turns on the spot. Otherwise, it goes straight ahead.<br />
    The scripting language provides other interesting constructs, such as the <tt>while</tt> loop, which executes a block of code repeatedly as long as a condition is true, or the <tt>for</tt> loop, which executes a block of code a certain number of times and changes the value of a variable each time. The menu <tt><a href="en_asebalanguage.html">Help -&gt; Language</a></tt> gives access to a page which lists all available constructs together with examples; feel free to have a look.
    <h1 id="toc4">
      <span>Your turn</span>
    </h1>
    <p>
      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.
    </p>
    <p>
      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 <tt>color_red</tt>, <tt>color_green</tt> and <tt>color_blue</tt>), 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.
    </p>
    <p>
      The goal of <em>challenge</em> is to learn robotics, programming, and Aseba while having fun.
    </p>
    <h1 id="toc5">
      <span>What to read next?</span>
    </h1>
    <p>
      You might be interested to read:
    </p>
    <ul>
      <li>
        <a href="en_asebaconcepts.html">A description of basic concepts used in Aseba</a>
      </li>
      <li>
        <a href="en_asebastudio.html">Documentation of the integrated development environment</a>
      </li>
      <li>
        <a href="en_asebalanguage.html">Description of the Aseba language</a>
      </li>
      <li>
        <a href="en_asebastdnative.html">Description of the native functions standard library</a>
      </li>
    </ul>
  </body>
</html>