Title: Universal Realtime Behavior Interface
1Universal Real-time Behavior Interface
URBI Tutorial
Jean-Christophe Baillie ENSTA / Gostai
Aldebaran Robotics
2 WHAT IS URBI?
3URBI Key Features
URBI is a complete solution to control robots.
The base of the system is a new Interface
Language.
Simplicity Easy to understand, but with
extremely advanced capabilities for demanding
applications. URBI is used as well by Research
Labs and by 12 years old kids as a hobby.
Flexibility Independent of the robot, OS,
platform, interfaced with many languages (C,
Java, Matlab), Client/Server architecture.
Modularity Software devices can be transparently
plugged in the language to extend it, as internal
new functions or external modules running on
different computers (DOM Distributed Object
Management).
Parallelism Parallel processing of commands,
concurrent variable access policies, event based
programming, task scheduling, many new powerful
concepts oriented towards parallel programming
and Artificial Intelligence
4URBI Engine
Mac OSX, Intel or standard
URBI modules (remote)
URBI Engine
Windows, Linux,
commands
messages
super calculator
or, simply onboard
5 TECHNICAL PART Inside URBI
6Objects to control hardware
Every sensor, motor, camera or physical hardware
in the robot is an object.
micro
gripL
legR3
An URBI object is similar to a C object it has
methods and properties.
The val property is related to the device value
(telnet session, port 54000, with Aibo
ERS7) headPan 15 // or headPan.val
15 headPan 136901543notag 15.1030265089
accelX 136901543notag 0.002938829104
camera 145879854notag BIN 5347 jpeg 208
160 5347 bytes speaker
bin 54112 wav 2 16000 16 54112 bytes
7Messages and tags
All messages from the server are composed with
the same standard structure
headTilt 136901543notag 15.1030265089
the command to the server
the message from the server
Time stamp (ms)
Command tag
Message content
mytag headTilt 136901543mytag 15.1030265089
custom tag useful to know who is sending what
and to control running commands. Any command or
group of commands can be prefixed by a tag. This
is one of the most powerful features in URBI,
crucial to handle parallelism properly
8Advanced Tagging
stop / block / freeze
mytag command1 if (distance lt 50)
sometag command2 while (index lt 10)
ping index ...
From another client or from other commands
running in parallel
9Parallelism
Commands can be executed in serial or parallel
mode
headPan 15 neck 30
Set headPan to 15 and neck to 30 at the same time
headPan 15 neck 30
Set headPan to 15 and after, set neck to 30.
10Complex Assignments
Simple assignment
headPan -2
Numerical assignments can be specified via
modifiers
This command never terminates
put the command in background
11Blending modes
Conflicting assignments can occur from several
clients or inside the same program. How to handle
it?
NB this is also true for sound devices gt simple
multiplexer
Each assignment occurs at the same time and is
added to the others gt Used to superimpose
sinuses in Fourier decomposition
neck.val-gtblend add
neck.val-gtblend mix
Like add, but they are averaged instead of added
neck.val-gtblend queue
Each assignement occurs only when the others are
finished
neck.val-gtblend discard
Each conflicting assignment is ignored
neck.val-gtblend cancel
Each new assignment terminate any other pending
assignment
neck.val-gtblend normal
The latest assignment has the focus, be the
others run in background
12Objects OOP and broadcasting
Usual OOP features are available
Usual OOP features are available (1.0 only)
motor
class motor var val function switchon()
event overheat legRF1 new
motor("xx24") legRF2 new motor("xx27") legRF3
new motor("xx789") // broadcast
grouping group legRF legRF1, legRF2,
legRF3
legRF
subclassing and multiple inheritance possible
head
legs
tail
legRF1
legRF2
legRF3
URBI multiple parallel launch going
downward broadcasting.
function motor.switchon() echo on
val legRF.switchon()? broadcast
switchon() ? gets motor.switchon() ? legRF1.s
witchon() legRF2.switchon() legRF3.switchon(
)
Usual virtual method search going upward
function motor.switchon() echo on
val legRF2.switchon()? gets motor.switchon
13C-like Features
Function definition Functions can be defined on
devices or virtual devices
Control structures Standard control structures
are available and some more specific to URBI
function robot.walk (x,y) / walk
code/ function add (x,y) return
xy function fibo(n) if (nlt2) return 1
else a fibo(n-1) b
fibo(n-2) return ab
// the classical for loop for (i0ilt10i)
echo i // soft tests must be true for
3ms while (headsensor gt 0) instructions //
loop 10 times loopn (10) legLF1 legRF1 //
Funny average calculation with for avg
0 avg-gtblend mixfor (i0ilt10i) avg
tabi
no semicolon
usage
robot.walk (14,255) myresult
fibo(10) robot.process_mystring("bonjour")
14Event catching
Several event catching mechanisms are available
waituntil (test)
Terminates only when test becomes true. gt If
given a number, the wait command pauses for this
nb of ms.
usage
waituntil (test) instructions
15Event catching (2)
You can control the lifespan of a command
16Event catching(3)
You can emit your own events with the emit
function
17Multicore Integration
OS
Hardware
Automatic load balancing of parallel commands on
a variable number of cores and threads, with
real-time scheduling capabilities (currently in
development, v.2 only)
Core 1
Physical Thread
Physical Thread
URBI Scheduler
URBI Kernel
URBI Code Client1
Physical Thread
Core 2
URBI Code Client2
Physical Thread
Network Layer
Physical Thread
URBI Code Client3
URBI Commands Micro-threads (logical thread)
Core 3
Physical Thread
Synchronisation
18Advanced Features
Many other advanced features Interconnection
commands, variables by name, aliases, load/save
files, safe checking, debugging options,
None of these are required to move a
joint! joint 30 URBI can be used by non
experts as well
19Examples
camera
ball detection module
headPan
legR3
// Ball tracking program whenever
(ball.visible) headPan headPan
camera.xfov ball.x headTilt
headTilt camera.yfov ball.y
// Get up on the Aibo getup leg2 90
time2s leg3 0 time2s leg1 90
time1s leg2 10 time1s leg1 -10
time2s leg3 90 time2s
// Event detection at (headSensor 2s)
speaker.play("hello.wav") at (distance lt 40)
emit collision ...
20Walk Sequence
Simple walk Using an original walk from the
robocup, we extracted the two main Fourier
coefficients for each joints. With blend add
mode, these two components are added on each
joint to reproduce the original periodic
oscillation
function robot.walk(duration) echo "go for "
string(duration) " secs" direction 1
if (duration lt0) duration - duration,
direction -1 walk timeout(duration)
for (x1xlt2x) for
(y1ylt2y) for (j1jlt3j)
for (d1dlt2d)
robot.legxyj walk.meanxj
sinwalk.speedwalk.coefd
ampliwalk.ampxjd4 phasedirecti
onwalk.phasexyjdpi(direction-1)/2
21Behavior example
This example shows how to write behavior
graphs with URBI
// Tracking state function tracking()
whenever (ball.visible) headPan headPan
camera.xfov ball.x headTilt headTilt
camera.yfov ball.y // Searching
state function searching() period 10s
headPann 0.5 smooth1s headTiltn 1
smooth1s headPann 0.5 sinperiod
ampli0.5 headTiltn 0.5 cosperiod
ampli0.5
// Transitions track_transition at
(ball.visible 400ms) stop search
speaker found track tracking()
search_transition at (!ball.visible
400ms) stop track speaker lost
search searching()
22Finite State Machines (another way to do behavior
graphs)
function state2.init() state2.tag1
at (cond1) action1emit go_state4 stop
state2 state2.tag2 at (cond2)
action2emit go_state3 stop state2
state2.main loop ... at (go_state2)
state2 state2.init() at (go_state4) state4
state4.init()
Integrated
state 2
cond3
Action3
cond1
state 1
Action1
cond2
Action2
state 3
state 4
cond4
Action4
state 2
Local event gate
cond1
Action1
cond2
Action2
23How to use URBI?
URBI Server
- simple commands
- functions definition
- complex scripts
Remote/Plugged C Module
other integrated clients (matlab, python, . . .)
// C object inherit fro UObject UStart(ball) c
lass ball UObject ball(string) UVar
x,y . . .
24UObject Architecture
ball.cpp
ball.h
include "ball.h" UStart(ball) ballball(strin
g s) UObject(s) UAttachVar (ball,x)
UAttachVar (ball,y) UAttachFunction
(ball,init) UAttachFunction (ball,getSize)
UNotifyChange("camera.val", ballnewImage)
UNotifyChange(x) UNotifyChange(y, newY) x
0 y 0 int tmp (int)x // example
of callback int ballnewImage(UVar img)
char data ((UBinary)img).image.data) ...
include "uobject.h" using namespace urbi class
ball public UObject public
ball(string) // exported field UVar x
UVar y // exported methods void
init(string color) float getSize()
// callbacks int newImage(UVar) //
external callbacks int newY(UVar)
ball detection module
On the URBI side
ball_red new ball("red")
25Contact Jean-Christophe Baillie,
contact_at_urbiforge.com
at (talk.finished true) echo  Thank you
for your attention Â