ArticleslgStudy

computer science

Urbiscript

Urbiscript is a computer science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Urbiscript rather than just read about it. In short: urbiscript is a programming language for robotics. It features syntactic support for concurrency and event-based programming.

Key takeaways

  • Urbiscript belongs to computer science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Urbiscript to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Urbiscript from memory before moving on to harder problems.

Reference excerpt

urbiscript is a programming language for robotics. 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. Memory management is performed by reference counting. Due to its close relationship to the Urbi platform, it directly supports 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. It is designed to program, but also interact with robots; 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):

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:

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.

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:

[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

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:

[00021680] *** 0 [00021680] *** 1 [00021680] *** 2 [00021682] *** 0 [00021682] *** 1 [00021682] *** 4

Event-based programming Aiming at the development of portable robotic applications, 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

Second, specify event handlers

Third, "emit" this event

[00014333] *** received event e Events can have payloads, and event handlers enjoy pattern matching on the payload:

[00014336] *** received event e

[00014336] *** received event e [00014336] *** received event e(1, 2)

Implicit events The urbiscript language also allows to monitor expressions:

The following example demonstrates the feature:

[00002165] 0

[00002166] 0

[00002167] 0

[00002168] *** 0 + 0 == 0

[00002169] 1

[00002170] 1 [00002170] *** 1 + 0 == 1

See also List of robotics software Urbi

References

External links urbi on GitHub Docker repository urbiscript Tutorial

Worked examples

Example 1 — a first encounter with Urbiscript

Start with the simplest possible case. Write down what Urbiscript claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In computer science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Urbiscript before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Urbiscript ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Urbiscript

In research
Urbiscript appears in computer science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Urbiscript in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Urbiscript is common in secondary-school and first-year university syllabi. It links to neighbouring topics C programming language family, Cross-platform free software, Dynamically typed programming languages, so understanding it makes those chapters shorter.
In everyday life
Look for Urbiscript outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.

Affiliate

Preply — study more efficiently by working with a personal tutor. 50% off.

How to study Urbiscript in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Urbiscript means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Urbiscript out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Urbiscript in simple terms?

urbiscript is a programming language for robotics. It features syntactic support for concurrency and event-based programming.

Why does Urbiscript matter?

Because it connects several computer science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Urbiscript?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Urbiscript.

Tags

  • C programming language family
  • Cross-platform free software
  • Dynamically typed programming languages
  • Free and open source interpreters
  • High-level programming languages
  • Object-oriented programming languages
  • Programming languages created in 2003
  • Prototype-based programming languages
  • Robot programming languages
  • Scripting languages
  • Text-oriented programming languages

Keep exploring