ASEBAOpen-Source Low-Level Robot Programming
Stephane Magnenat 1
stephane at magnenat.net
Philippe Retornaz 2
1Autonomous Systems LabETH Zurich
2Mobots group - Laboratory of robotics SystemsEPFL
February 5, 2012
1 / 46
Outline
Motivation
Current Use
Technical Description
Performances
Wrap-up
2 / 46
Outline
Motivation
Current Use
Technical Description
Performances
Wrap-up
3 / 46
Motivation: Multi-Microcontrollers Robots
17cm
Modern integrated mobile robotshave
I lots of degrees of freedom
I many and various sensors
Their computing infrastructureconsists of
I a main processor running Linux(ex. Gumstix)
I multiple microcontrollers
I a common communication bus(ex. I2C or CAN)
4 / 46
Motivation: Usual Approach is Centralized Polling...
microcontroller 1
microcontroller 2
microcontroller 3
processormain
1
cycle cycle
1
activitybus
main processor
continuously
I read sensors
I process data
I set actuators
microcontrollers
I interface tophysical devices
bus
I I2C
5 / 46
Motivation: ...but Distributed Events are Better!
microcontroller 1
microcontroller 2
microcontroller 3
processormain
2 3
activitybus
main processor
I react to events
I send events
microcontrollers
I interface tophysical devices
I preprocess data
I send events
I react to events
bus
I CAN
6 / 46
Motivation: An Example of Distributed Events
left motor
right motor
proximity
sensors
tim
e
7 / 46
Motivation: An Example of Distributed Events
no obstacle
left motor
right motor
proximity
sensors
tim
e
8 / 46
Motivation: An Example of Distributed Events
no obstacle
left motor
right motor
proximity
sensors
tim
eobstacle detected
9 / 46
Motivation: An Example of Distributed Events
no obstacle
left motor
right motor
proximity
sensors
tim
eobstacle detected
no obstacle
10 / 46
Motivation: How to Implement Distributed Events?
I Contrary to centralized polling, with events the emissionpolicy must be distributed as well.
I Microcontrollers must take decisions about what event tosend when, and how to link incoming events to actuators.
I Therefore they must be programmable, but flashing is slow.
I A virtual machine is the solution...
I And so Aseba was born!
I Aseba stands for Actuator and Sensor Event-BasedArchitecture.
I Aseba puts virtual machines inside microcontrollers; enablingtheir programming through a user-friendly language and IDE.
11 / 46
Motivation: How to Implement Distributed Events?
I Contrary to centralized polling, with events the emissionpolicy must be distributed as well.
I Microcontrollers must take decisions about what event tosend when, and how to link incoming events to actuators.
I Therefore they must be programmable, but flashing is slow.
I A virtual machine is the solution...
I And so Aseba was born!
I Aseba stands for Actuator and Sensor Event-BasedArchitecture.
I Aseba puts virtual machines inside microcontrollers; enablingtheir programming through a user-friendly language and IDE.
12 / 46
Outline
Motivation
Current Use
Technical Description
Performances
Wrap-up
13 / 46
Swarm Robotics: hand-bot
6 Aseba VM, real-time unwind control, grasping,and state machines implemented in Aseba
14 / 46
Swarm Robotics: hand-bot
hand-bot video athttp://www.youtube.com/watch?v=92bLgE6DO2g
In this video, the hand-bot climbs a shelf and retrieves a booksolely using Aseba.
15 / 46
Autonomous Construction: Lonelybuilder
5 Aseba VM, state machines coded in Asebalocalisation, mapping, planning running on Linux ARM
16 / 46
Autonomous Construction: Lonelybuilder
Lonelybuilder video athttp://www.youtube.com/watch?v=h865RHbT9Ms
In this video, Lonelybuilder constructs a tower by manipulatingcubes. The manipulation state machines are implemented with
Aseba.
17 / 46
Brick for Building Robot: Smartrob
I 2 motor and 8 servo drivers
I 8 infrared-sensor drivers
I additional I/O and A/D
I CAN bus, stackable
I single 3 to 25 V input
I shipped with Aseba
I ROS and D-Bus integration
I soon available for buying
18 / 46
Educational Robotics: Thymio II
Full-featured open-hardware programmable mobile robot for100 CHF (≈ 80¿), see http://aseba.wikidot.com/en:thymio
19 / 46
Educational Robotics: Thymio II
20 / 46
Educational Robotics: Thymio II
1
1
2
2
3
3
4
4
D D
C C
B B
A A
2 Laboratoire de Systèmes Robootiques
Michael BonaniSTI-IMT-LSRO1EPFLCH-1015 LAUSANNE
9A
16.06.201113:33:03
microcontroleur.SchDoc
Date:
Revision:Page de
Thymio2
Project
File :
thymio2-main.PrjPCBPart
PCB principal
VCC
C36100nF
VCC
GND
C37100nF
VCC
GND
C38100nF
VCC
GND
R10110K
VCC
C35100nF
VCC
GND
123456
X1
Con1x6
GND
PGDPGC
PGDPGC
X5R
C3410uF X5R
C39100nF
VCC
GND
VCC
GND
VCC
GND
ACC_INT
ACC_SCKACC_SDA
123456
X2
Con1x6
GND
Buton1Buton2Buton3Buton4Buton5
IR-sens-front2
IR-sens-front3
IR-sens-front4
IR-sens-front5
IR-sens-front1
IR-sens-groundRIR-sens-groundL
IR-pulse-front
IR-pulse-groundL
IR-pulse-groundR
IR-pulse-back
IR-sens-backL
IR-sens-backR
MOTOR1-PWMH1
MOTOR1-PWMH2
MOTOR1-PWML1
MOTOR1-PWML2
MOTOR2-PWMH1MOTOR2-PWMH2
MOTOR2-PWML1MOTOR2-PWML2
MOTOR1-SENSMOTOR2-SENS
D-D+
USB-500
VAenableR1034.7KR104
4.7K
VCC
LED_CLK
LED_CS
LED_SDI
12Y1
815-ABLS-8-B2C4118pF
C4218pF
GND GND
USB-Charge
OUT 1
VSS 3
GND 236 kHz
U20
IRM-3636T
R105100
AGND
36 kHz IR receiver
IR_Receiver
VA
IR_Receiver
Micro
C33100nF
SOUND_OUTSDcard-CS
SDcard-DISDcard-CK
SDcard-DO
C434.7uF
USB-Present
R10210K
C62100nF
t° RT1NCP15XH103F03RC
GND
INNTC2
INNTC2
Therm. NTC Sensor
R137
180
GND S
S2SW-PB
GND
PMD5/CN63/RE5 1
PMD6/SCL3/CN64/RE6 2
PMD7/SDA3/CN65/RE7 3
PMA5/RP21/C1IND/CN8/RG64
RP26/PMA4/C1INC/CN9/RG75
PMA3/RP19/C2IND/CN10/RG86
MCLR7
RP27/PMA2/C2INC/CN11/RG98
VSS9
VDD10
PGEC3/RP18/VBUSON/C1INA/AN5/CN7/RB5 11PGED3/RP28/USBOEN/C1INB/AN4/CN6/RB4 12VPIO/C2INA/AN3/CN5/RB3 13VMIO/RP13/C2INB/AN2/CN4/RB2 14PGEC1/RP1/VREF-/AN1/CN3/RB1 15PGED1/RP0/PMA6/VREF+/AN0/CN2/RB0 16
PGEC2/AN6/RP6/CN24/RB6 17
PGED2/RCV/RP7/AN7/CN25/RB7 18
AVDD19
AVSS20
RP8/AN8/CN26/RB8 21
PMA7/RP9/AN9/CN27/RB9 22
TMS/PMA13/AN10/CVREF/CN28/RB10 23
TDO/AN11/PMA12/CN29/RB11 24
VSS25
VDD26
TCK/PMA11/AN12/CTED2/CN30/RB12 27
TDI/PMA10/AN13/CTED1/CN31/RB13 28
CTPLS/RP14/PMA1/AN14/CN32/RB14 29
RP29/PMA0/AN15/REFO/CN12/RB15 30
PMA9/RP10/SDA2/CN17/RF431
PMA8/RP17/SCL2/CN18/RF532
RP16/USBID/CN71/RF333
VBUS34
VUSB35
D-/RG336 D+/RG237
VDD38
OSCI/CLKI/CN23/RC12 39
OSCO/CLKO/CN22/RC15 40
VSS41
RP2/DMLN/RTCC/CN53/RD8 42
RP4/DPLN/SDA1/CN54/RD9 43
RP3/SCL1/PMCS2/CN55/RD10 44
RP12/PMCS1/CN56/RD11 45
RP11/DMH/CN49/INT0/RD0 46
SOSCI/C3IND/CN1/RC13 47
RPI37/SOSCO/C3INC/TICK/CN0/RC14 48
RP24/VCPCON/CN50/RD1 49
DPH/RP23/CN51/RD2 50
RP22/PMBE/CN52/RD3 51
PMWR/RP25/CN13/RD4 52
PMRD/RP20/CN14/RD5 53
C3INB/CN15/RD6 54
C3INA/CN16/RD7 55
VCAP/VDDCORE56
ENVREG57
VBUSST/VCMPST1/CN68/RF058
VCMPST2/CN69/RF159
PMD0/CN58/RE0 60
PMD1/CN59/RE1 61
PMD2/CN60/RE2 62
PMD3/CN61/RE3 63
PMD4/CN62/RE4 64
U19
PIC24FJ128GB106-I/PT
R143
100K
PIC3301
PIC3302COC33
PIC3401
PIC3402COC34
PIC3501
PIC3502COC35 PIC3601
PIC3602COC36 PIC3701
PIC3702COC37 PIC3801
PIC3802COC38 PIC3901
PIC3902
COC39
PIC4101
PIC4102COC41 PIC4201
PIC4202COC42
PIC4301
PIC4302COC43
PIC6201
PIC6202COC62
PIR10101
PIR10102COR101
PIR10201
PIR10202COR102
PIR10301
PIR10302COR103
PIR10401
PIR10402COR104
PIR10501
PIR10502COR105
PIR13701 PIR13702
COR137
PIR14301PIR14302
COR143
PIRT101
PIRT102
CORT1
PIS201
PIS202
PIS20S
COS2
PIU1901PIU1902
PIU1903
PIU1904
PIU1905PIU1906
PIU1907
PIU1908
PIU1909
PIU19010
PIU19011
PIU19012
PIU19013
PIU19014
PIU19015
PIU19016
PIU19017
PIU19018
PIU19019
PIU19020
PIU19021
PIU19022
PIU19023
PIU19024
PIU19025
PIU19026
PIU19027
PIU19028
PIU19029
PIU19030
PIU19031
PIU19032
PIU19033
PIU19034
PIU19035
PIU19036
PIU19037
PIU19038
PIU19039
PIU19040
PIU19041
PIU19042
PIU19043
PIU19044
PIU19045
PIU19046
PIU19047
PIU19048
PIU19049
PIU19050
PIU19051
PIU19052
PIU19053
PIU19054
PIU19055
PIU19056
PIU19057
PIU19058
PIU19059
PIU19060
PIU19061
PIU19062
PIU19063
PIU19064
COU19
PIU2001
PIU2002
PIU2003
COU20
PIX101
PIX102
PIX103
PIX104
PIX105
PIX106
COX1
PIX201
PIX202
PIX203
PIX204PIX205
PIX206
COX2
PIY101PIY102
COY1
POACC0INT
POACC0SCKPOACC0SDA
POD0
POIR0PULSE0BACK
POIR0PULSE0FRONT
POIR0PULSE0GROUNDL
POIR0PULSE0GROUNDR
POIR0SENS0BACKL
POIR0SENS0BACKR
POIR0SENS0FRONT1
POIR0SENS0FRONT2
POIR0SENS0FRONT3
POIR0SENS0FRONT4
POIR0SENS0FRONT5
POIR0SENS0GROUNDLPOIR0SENS0GROUNDR
POLED0CLK
POLED0CS
POLED0SDI
POMICRO
POMOTOR10PWMH1
POMOTOR10PWMH2
POMOTOR10PWML1
POMOTOR10PWML2
POMOTOR10SENS
POMOTOR20PWMH1POMOTOR20PWMH2
POMOTOR20PWML1POMOTOR20PWML2
POMOTOR20SENS
POSDCARD0CK
POSDCARD0CS
POSDCARD0DIPOSDCARD0DO
POSOUND0OUT
POUSB0500POUSB0CHARGE
POUSB0PRESENT
POVAENABLE
21 / 46
Educational Robotics: Thymio II
Li-Po battery level
speaker
microphone
infrared remote controlreceiver
3 axis accelerometer
5 proximity sensors(obstacle detection)’
2 ground sensors(line following)
39 LED to visualizesensors and interaction
reset button
5 capacitive touchbuttons with activity display, and ON-OFF function
pencil support
USB connection(programming and recharging)
memory card slot
hook for trailer
2 proximity sensors
mechanic fixation
2 wheels withspeed control
temperature sensor
22 / 46
Educational Robotics: Thymio II
Enables children to discover programming with a mobile robot.
23 / 46
Simulated Robotics: Challenge
beamer
arena
computer
child computer
development env.
+ local arena
child computer
development env.
+ local arena
child computer
development env.
+ local arena
child computer
development env.
+ local arena
24 / 46
Outline
Motivation
Current Use
Technical Description
Performances
Wrap-up
25 / 46
Technical Overview
Aseba:
I allows fast prototyping of the behaviour of microcontrollersconnected through a network,
I provides an IDE for edition, debugging and inspection of thevalues of variables (including sensor and actuators),
I compiles scripts into bytecode,
I executes bytecode on microcontrollers in a virtual machine,
I safe execution,
I dynamic enumeration of microcontrollers’ variables, nativefunctions and events,
I dynamic reprogramming of the microcontrollers,
I asynchronous code execution upon events,
I open source, LGPL.
26 / 46
Software Architecture
microcontroller
microcontroller
microcontroller
central embeddedcomputer running Linux
desktopcomputer
high-level controlprograms
software switchIDE
optional optional
CANTCP
ROS or D-Bus or TCP • • •
robot
27 / 46
Microcontrollers
programspecific
application
microcontroller
communicationvirtual machine
shared communication bus
actuatorssensors
low-level control
native functions
28 / 46
Virtual Machine
I targets 16-bit microcontrollers and better,
I stack based, 16-bit integers,
I executes bytecode(4-bit opcode, 12-bit payload + optional trailing 16-bit words)
I ≈ 1000 lines of C, including debugging logic,
I RAM: 22 bytes + user defined amount of bytecode, variable,stack, and breakpoints.
I flash: 7.5 kB flash (dsPIC30, e-puck),
I no external library requirement, excepted the implementationof bus communication.
29 / 46
Language
Simple imperative scripting language, octave-like syntax.
I blocks of code executed upon events,
I 16-bit integer variables and arrays,
I common mathematical expressions and arrays access,
I if and when conditionals,
I while and for loops,
I native functions for complex processing,
I subroutines.
30 / 46
Studio (IDE)
Live Demonstration using Thymio II
31 / 46
Outline
Motivation
Current Use
Technical Description
Performances
Wrap-up
32 / 46
Evaluation Platform
Evaluation conducted using the marXbot base.
33 / 46
Aseba vs Polling: Bus Bandwidth
emp
ty
box
es
wal
ls
empty boxes walls 10 Hz 25 Hz 67 Hz
data
tran
smitt
ed fo
r 1
min
ute
100 B
1 kB
10 kB
100 kB
1 MB
event−based polling
34 / 46
Aseba vs Polling: Bandwidth Use w.r.t. Location
35 / 46
Aseba vs Polling: Latency
150 mm/s
250 mm
initially
d
once stopped
polling 10 Hz
distance [mm]
Fre
quen
cy5 10 20 30
010
2030
polling 25 Hz
distance [mm]
Fre
quen
cy
5 10 20 30
010
2030
polling 67 Hz
distance [mm]
Fre
quen
cy
5 10 20 30
010
2030
event−based
distance [mm]
Fre
quen
cy5 10 20 30
010
2030
36 / 46
Aseba vs Native
On a 40 MHz dsPIC:
I Ratio of about 70 dsPIC instructions for 1 Aseba instruction
I Rate of 600’000 instructions per second
I Event round trip lasts 25µs on idle VM
I Native functions in DSP assembly
I Native functions use dsPIC’s DSP, event round trip for meanof 100 values is 60µs, faster than bare C code
37 / 46
Lessons Learnt on Performance
I Events save bandwidth compared to polling.
I Events allow for lower latencies than polling.
I Virtual machines are suitable for embedded, provided thecritical path is optimised.
38 / 46
Outline
Motivation
Current Use
Technical Description
Performances
Wrap-up
39 / 46
Future Directions
Improve IDE
I store program as abstractsyntax tree, textual surfaceform for editor
I contextualised help/errors
I intelligent completion
I statistics and machinelearning for commonmistakes, automatic tutoring
Lower entry curve
I improve tutorial
I robotics course
I more translations
More platform support
I new firmware for Thymio II
I affordable service robotbased on Smartrob
I add your favourite platform!
On the long run
I no more arithmetic/logicoperation in the VM, useonly native functions
I complete type system
I more proving in the compiler
I JIT on some platforms
I use standard language?40 / 46
Take-Home Message
The combination of VM and custom-tailored IDE enables efficientembedded development, in particular for robotic applications.
Aseba is a mature and robust implementation of this idea. Yetthere is much room for improvement and innovative ideas.
You are welcome to join us in this endeavour!
41 / 46
Thank you
Thank you for your attention, your questions are welcome.
The Aseba community awaits you: http://aseba.wikidot.com
Thanks to: Michael Bonani, Florian Vaussard, Fanny Riedo, ValentinLongchamp, Basilio Noris, Sandra Moser and Francesco Mondada
42 / 46
Program Memory Layout
addresses (in 16-bit words) content
bytecodeSize −1unused bytecode
. . .
. . .bytecode for last managed event
evLastAddr
. . .. . .
bytecode for first managed eventev0Addr
evVectSize −1 evLastAddr
evVectSize −2 evLastId
. . . . . .0x0002 ev0Addr
0x0001 ev0Id
0x0000 evVectSize
43 / 46
Data Memory Layout
addresses (in 16-bit words) content
variablesSize −1 temporary variables to pass. . . constants to native calls
. . . unused variables
. . .user-defined variables
exportedVarsLength
. . .exported variables
0x0000
44 / 46
Types of Bytecodes - 1/2
name w.c. function
stop 1 stop executionsmall immediate 1 push a constant onto the stacklarge immediate 2 push a constant onto the stackload 1 push data from memory onto the stackstore 1 pop data from the stack into the mem-
oryload indirect 2 push data from memory onto the stack
using an offset from the stackstore indirect 2 pop data from the stack into the mem-
ory using an offset from the stackunary arithmetic 1 unary arithmetic operation on the stackbinary arithmetic 1 binary arithmetic operation on the
stack
45 / 46
Types of Bytecodes - 2/2
name w.c. function
jump 1 jump to another execution addressconditional branch 2 check a condition on the stack and
jump depending on the resultemit 3 send an eventnative call 1 call a native functionsub call 1 jump into a subroutine, store return
address on the stacksub ret 1 return from a subroutine, using return
address from the stack
46 / 46
Top Related