fbpx
Wikipedia

urbiscript

urbiscript is a programming language for robotics.[3] It features syntactic support for concurrency and event-based programming. It is a prototype-based object-oriented scripting language. It is dynamic: name resolution is performed during the program execution (late binding); slots (member variables) can be added/removed at runtime, and even prototypes (superclasses) of an object can be changed at runtime.

urbiscript
Paradigmmulti-paradigm: object-oriented, event-driven, imperative, functional, procedural, reflective
Designed byJean-Christophe Baillie
DeveloperGostai et al.
First appeared2003; 20 years ago (2003)
Stable release
2.7.4 / November 17, 2011; 11 years ago (2011-11-17)
Typing disciplineduck, dynamic
OSCross-platform
LicenseBSD licenses[1]
Filename extensions.u
Websitegithub.com/urbiforge/urbi
Influenced by
C++, Self,[2] Io[2]

Memory management is performed by reference counting.

Tightly bound to the Urbi platform it supports seamless integration of C++/Java components.

Syntax and semantics

Inspiration

From the syntactical point of view, urbiscript belongs to the C-family of programming languages.

Its prototype-based object-oriented design was influenced by the Self and the Io programming languages.[2]

It is designed to program, but also interact with robots;[2] as such, it is influenced by Unix shells and other languages that provide a read-eval-print loop style interactive toplevel. However, contrary to others, there is no prompt for user input but answers from the system are prefixed by a timestamp (in milliseconds) between square brackets:

 1 + 1; sleep(1s); 1 + 2 * 3; 
[00005420] 2
[00006420] 7

Sequential statements and control flow

urbiscript statements include (among others):[4]

  • The if statement, which conditionally executes a block of code, along with else.
  • The traditional for statement, as in C which iterates over an iterable object, capturing each element to a local variable for use by the attached block.
  • Another for statement, which iterates over an iterable object, capturing each element to a local variable for use by the attached block.
  • The while statement, which executes a block of code as long as its condition is true.
  • The try statement, which allows exceptions thrown in its attached code block to be caught and handled by catch clauses. An optional else clause is run if no exception was thrown. Clean-up code can be guaranteed to be run in every case when given in a finally-clause.
  • The assert statement, used during debugging to check for conditions that ought to apply. urbiscript also feature assert blocks, which can be used to factor several assert statements.

Actually, contrary to most C-like languages and despite what the syntax suggests, statements "have a value", and therefore are expressions, provided they are embedded in braces:

 var status = { if (closed) "closed" else "open" }; var pass = { try { foo } catch { false } else { true } }; 

Concurrent statements and control flow

In urbiscript, some control-flow constructs come in several "flavors": two types of sequential composition, and two types of concurrent composition. Under the hood, concurrency is implemented using coroutines.[5]

Statement composition

Like in C, the semicolon denotes sequential composition: a;b stands for "run statement a then run statement b. Other tasks may be run between a and b. Another statement separator, pipe, denotes "tight sequential composition": no other task can be run between a and b in a|b.

Similarly urbiscript features two means to compose statements concurrently. With a,b, first a is run, and at some point b will be --- possibly while a is still running. This is very similar to the & operator in Unix shells. Alternatively, with a&b, both a and b are started together; in interactive sessions, this means that a won't be run until b is fully entered and properly followed by either a ; or a ,.

Scopes are boundaries for backgrounded jobs, as demonstrated in the following example:[5]

 { { sleep(2s); echo(2) }, { sleep(1s); echo(1) }, }; echo(3); 
[00012451] *** 1
[00013447] *** 2
[00013447] *** 3

Concurrent flavors of sequential constructs

Most looping constructs in urbiscript come in several "flavors", which are based on the four statement separators: ;, |, ,, and &.

For instance

 // This is actually "for;". for (var i : [0, 1, 2]) { echo(i); echo(i ** 2); }; 

displays

[00002919] *** 0
[00002921] *** 0
[00002921] *** 1
[00002922] *** 1
[00002922] *** 2
[00002922] *** 4

i.e., the loop bodies are not executed sequentially, while the for& keyword runs the loop bodies concurrently:

 for& (var i : [0, 1, 2]) { echo(i); echo(i ** 2); }; 
[00021680] *** 0
[00021680] *** 1
[00021680] *** 2
[00021682] *** 0
[00021682] *** 1
[00021682] *** 4

Event-based programming

Aiming at the development of portable robotic applications,[6] urbiscript relies on specific syntactic constructs to specify reactive behaviors such as "go to the charging dock when the battery is low", "play a friendly sound when a known face is recognized", or "stop when an obstacle is detected".

Explicit event handling

Event handling goes into three steps. First, define an event

 var e = Event.new; 

Second, specify event handlers

 at (e?) echo("received event e"); 

Third, "emit" this event

 e!; 
[00014333] *** received event e

Events can have payloads, and event handlers enjoy pattern matching on the payload:

 at (e?(1, var x) if x % 2 == 0) echo("received event e(1, %s)" % x); e!(1, 1); 
[00014336] *** received event e
 e!(1, 2); 
[00014336] *** received event e
[00014336] *** received event e(1, 2)

Implicit events

The urbiscript language also allows to monitor expressions:

 at (batteryLevel <= 0.2) robot.goToChargingDock; 

The following example demonstrates the feature:

 var x = 0; 
[00002165] 0
 var y = 0; 
[00002166] 0
 var z = 0; 
[00002167] 0
 at (x + y == z) echo("%s + %s == %s" % [x, y, z]); 
[00002168] *** 0 + 0 == 0
 x = 1; 
[00002169] 1
 z = 1; 
[00002170] 1
[00002170] *** 1 + 0 == 1

See also

References

  1. ^ "Urbi, the open source operating system for robots". Retrieved 2012-10-27.
  2. ^ a b c d Baillie, Jean-Christophe; Demaille, Akim; Nottale, Matthieu; Hocquet, Quentin; Tardieu, Samuel (2008). "The Urbi Universal Platform for Robotics" (PDF). Retrieved 6 October 2011.
  3. ^ Baillie, Jean-Christophe. "Urbi: a new parallel & event-driven script language for robotics, games and more". YouTube. Retrieved 6 Oct 2011.
  4. ^ "urbiscript Language Reference Manual". Retrieved 2011-09-20.
  5. ^ a b Baillie, Jean-Christophe; Demaille, Akim; Nottale, Matthieu; Hocquet, Quentin (2010). "Tag: Job Control in urbiscript" (PDF). Retrieved 6 October 2011.
  6. ^ Baillie, Jean-Christophe; Demaille, Akim; Nottale, Matthieu; Hocquet, Quentin (2010). "Events! (Reactivity in urbiscript)". arXiv:1010.5694 [cs.PL].

External links

  • urbi on GitHub
  • Docker repository
  • urbiscript Tutorial

urbiscript, programming, language, robotics, features, syntactic, support, concurrency, event, based, programming, prototype, based, object, oriented, scripting, language, dynamic, name, resolution, performed, during, program, execution, late, binding, slots, . urbiscript is a programming language for robotics 3 It features syntactic support for concurrency and event based programming It is a prototype based object oriented scripting language It is dynamic name resolution is performed during the program execution late binding slots member variables can be added removed at runtime and even prototypes superclasses of an object can be changed at runtime urbiscriptParadigmmulti paradigm object oriented event driven imperative functional procedural reflectiveDesigned byJean Christophe BaillieDeveloperGostai et al First appeared2003 20 years ago 2003 Stable release2 7 4 November 17 2011 11 years ago 2011 11 17 Typing disciplineduck dynamicOSCross platformLicenseBSD licenses 1 Filename extensions uWebsitegithub wbr com wbr urbiforge wbr urbiInfluenced byC Self 2 Io 2 Memory management is performed by reference counting Tightly bound to the Urbi platform it supports seamless integration of C Java components Contents 1 Syntax and semantics 1 1 Inspiration 1 2 Sequential statements and control flow 1 3 Concurrent statements and control flow 1 3 1 Statement composition 1 3 2 Concurrent flavors of sequential constructs 1 4 Event based programming 1 4 1 Explicit event handling 1 4 2 Implicit events 2 See also 3 References 4 External linksSyntax and semantics EditInspiration Edit From the syntactical point of view urbiscript belongs to the C family of programming languages Its prototype based object oriented design was influenced by the Self and the Io programming languages 2 It is designed to program but also interact with robots 2 as such it is influenced by Unix shells and other languages that provide a read eval print loop style interactive toplevel However contrary to others there is no prompt for user input but answers from the system are prefixed by a timestamp in milliseconds between square brackets 1 1 sleep 1s 1 2 3 00005420 2 00006420 7Sequential statements and control flow Edit urbiscript statements include among others 4 The if statement which conditionally executes a block of code along with else The traditional for statement as in C which iterates over an iterable object capturing each element to a local variable for use by the attached block Another for statement which iterates over an iterable object capturing each element to a local variable for use by the attached block The while statement which executes a block of code as long as its condition is true The try statement which allows exceptions thrown in its attached code block to be caught and handled by catch clauses An optional else clause is run if no exception was thrown Clean up code can be guaranteed to be run in every case when given in a finally clause The assert statement used during debugging to check for conditions that ought to apply urbiscript also feature assert blocks which can be used to factor several assert statements Actually contrary to most C like languages and despite what the syntax suggests statements have a value and therefore are expressions provided they are embedded in braces var status if closed closed else open var pass try foo catch false else true Concurrent statements and control flow Edit In urbiscript some control flow constructs come in several flavors two types of sequential composition and two types of concurrent composition Under the hood concurrency is implemented using coroutines 5 Statement composition Edit Like in C the semicolon denotes sequential composition a b stands for run statement a then run statement b Other tasks may be run between a and b Another statement separator pipe denotes tight sequential composition no other task can be run between a and b in a b Similarly urbiscript features two means to compose statements concurrently With a b first a is run and at some point b will be possibly while a is still running This is very similar to the a href Job control Unix html title Job control Unix amp a operator in Unix shells Alternatively with a amp b both a and b are started together in interactive sessions this means that a won t be run until b is fully entered and properly followed by either a or a Scopes are boundaries for backgrounded jobs as demonstrated in the following example 5 sleep 2s echo 2 sleep 1s echo 1 echo 3 00012451 1 00013447 2 00013447 3Concurrent flavors of sequential constructs Edit Most looping constructs in urbiscript come in several flavors which are based on the four statement separators and amp For instance This is actually for for var i 0 1 2 echo i echo i 2 displays 00002919 0 00002921 0 00002921 1 00002922 1 00002922 2 00002922 4i e the loop bodies are not executed sequentially while the for amp keyword runs the loop bodies concurrently for amp var i 0 1 2 echo i echo i 2 00021680 0 00021680 1 00021680 2 00021682 0 00021682 1 00021682 4Event based programming Edit Aiming at the development of portable robotic applications 6 urbiscript relies on specific syntactic constructs to specify reactive behaviors such as go to the charging dock when the battery is low play a friendly sound when a known face is recognized or stop when an obstacle is detected Explicit event handling Edit Event handling goes into three steps First define an event var e Event new Second specify event handlers at e echo received event e Third emit this event e 00014333 received event eEvents can have payloads and event handlers enjoy pattern matching on the payload at e 1 var x if x 2 0 echo received event e 1 s x e 1 1 00014336 received event ee 1 2 00014336 received event e 00014336 received event e 1 2 Implicit events Edit The urbiscript language also allows to monitor expressions at batteryLevel lt 0 2 robot goToChargingDock The following example demonstrates the feature var x 0 00002165 0var y 0 00002166 0var z 0 00002167 0at x y z echo s s s x y z 00002168 0 0 0x 1 00002169 1z 1 00002170 1 00002170 1 0 1See also EditUrbiReferences Edit Urbi the open source operating system for robots Retrieved 2012 10 27 a b c d Baillie Jean Christophe Demaille Akim Nottale Matthieu Hocquet Quentin Tardieu Samuel 2008 The Urbi Universal Platform for Robotics PDF Retrieved 6 October 2011 Baillie Jean Christophe Urbi a new parallel amp event driven script language for robotics games and more YouTube Retrieved 6 Oct 2011 urbiscript Language Reference Manual Retrieved 2011 09 20 a b Baillie Jean Christophe Demaille Akim Nottale Matthieu Hocquet Quentin 2010 Tag Job Control in urbiscript PDF Retrieved 6 October 2011 Baillie Jean Christophe Demaille Akim Nottale Matthieu Hocquet Quentin 2010 Events Reactivity in urbiscript arXiv 1010 5694 cs PL External links Editurbi on GitHub Docker repository urbiscript Tutorial Retrieved from https en wikipedia org w index php title Urbiscript amp oldid 1005323004, wikipedia, wiki, book, books, library,

article

, read, download, free, free download, mp3, video, mp4, 3gp, jpg, jpeg, gif, png, picture, music, song, movie, book, game, games.