Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
research:software:lrp [2016/10/26 15:19] – jfabry | research:software:lrp [2018/04/02 21:51] (current) – mcampusa | ||
---|---|---|---|
Line 7: | Line 7: | ||
We all like videos of robots, right? Here are some of LRP on a few different robots for your viewing pleasure. | We all like videos of robots, right? Here are some of LRP on a few different robots for your viewing pleasure. | ||
- | * [[https:// | + | * [[https:// |
- | * [[https:// | + | * [[https:// |
- | * [[https:// | + | * [[https:// |
- | * [[https:// | + | * [[https:// |
+ | * [[https:// | ||
**NEWS**: | **NEWS**: | ||
+ | * Miguel presented LRP at the [[https:// | ||
* [[http:// | * [[http:// | ||
- | * [[http://www.smalltalkhub.com/# | + | * [[http://pharo.org/news/Nao-robot|A first version of NAO support is out!]] |
* Journal paper defining LRP, the functioning of the interpreter and bridges to robot API accepted for Science of Computer Programming, | * Journal paper defining LRP, the functioning of the interpreter and bridges to robot API accepted for Science of Computer Programming, | ||
* NIER Paper on visualizing robotic sensors accepted at [[http:// | * NIER Paper on visualizing robotic sensors accepted at [[http:// | ||
Line 27: | Line 29: | ||
</ | </ | ||
- | As LRP is not bound to a specific robot infrastructure, | + | As LRP is not bound to a specific robot infrastructure, |
LRP is implemented in [[http:// | LRP is implemented in [[http:// | ||
Line 53: | Line 55: | ||
(spawn esc tick) | (spawn esc tick) | ||
- | States may also contain actions: an on entry action ('' | + | States may also contain actions: an on entry action ('' |
A machine can also define variables. Global variables may also be defined, outside of the root machine. Variables must be given a value when they are defined, the value is the result of evaluating a Smalltalk block. This block has in scope all variables that are lexically in scope. All actions (i.e. '' | A machine can also define variables. Global variables may also be defined, outside of the root machine. Variables must be given a value when they are defined, the value is the result of evaluating a Smalltalk block. This block has in scope all variables that are lexically in scope. All actions (i.e. '' | ||
Line 128: | Line 130: | ||
</ | </ | ||
+ | ==== Advanced Features ==== | ||
+ | |||
+ | === Nested Machines === | ||
+ | |||
+ | As LRP is a nested state machine language, a state of a machine may contain (several) complete state machine(s), whose states may again contain a machine, and so on. Machines can be spawned when the state is entered by having the '' | ||
+ | |||
+ | <note important> | ||
+ | |||
+ | When a state with a nested machine stops being active, the nested machine is stopped and discarded. As part of this process, the on exit action in the active state of this nested machine is performed after any machines nested in that state are stopped and discarded (and so on recursively). | ||
+ | |||
+ | A brief (contrived) example is as follows: | ||
+ | < | ||
+ | (machine root | ||
+ | (state r1 | ||
+ | (machine nest1 | ||
+ | (state n1 | ||
+ | (machine nest2 (state n1n2)) | ||
+ | (onentry (spawn nest2 n1n2)) | ||
+ | ) | ||
+ | (ontime 500 n1->n2) | ||
+ | (state n2 | ||
+ | (machine nest3 (state n2n3)) | ||
+ | (onentry (spawn nest3 n2n3)) | ||
+ | ) | ||
+ | (state n3) | ||
+ | (ontime 500 n2->n3)) | ||
+ | (onentry (spawn nest1 n1)) | ||
+ | ) | ||
+ | (state r2) | ||
+ | (ontime 2000 r1->r2) | ||
+ | (ontime 500 r2->r1) | ||
+ | ) | ||
+ | (spawn root r1) | ||
+ | </ | ||
+ | |||
+ | === Concurrency === | ||
+ | |||
+ | It is possible to have multiple machines running at the same time, i.e. to have multiple machines each with an active state, without these machines being nested. To achieve this, multiple '' | ||
+ | * If a spawn statement specifies a machine that is already running, i.e. that already has an active state, the spawn fails with an error. | ||
+ | * exiting a state that has multiple nested machines concurrently running means exiting all of these machines | ||
+ | * removing a top-level spawn does NOT stop the machine that was spawned | ||
+ | * adding or removing a spawn of a state means changing the state. So if the state is active (possibly having multiple nested machines running) the program is restarted. | ||
+ | |||
+ | The scheduling of machine execution is fair and predictable: | ||
+ | * all top level spawned machines perform one interpretation step for each interpreter step. This happens sequentially and the order is the lexical order of the spawn statements. | ||
+ | * all nested machines perform one interpretation step for each interpretation step of the state. This happens sequentially and the order is the lexical order of the spawn statements. Note that this implies recursion when an active state of a nested machine has concurrent nested state machines. | ||
+ | |||
+ | Put succinctly, interpretation of multiple running machines is equal to a depth-first traversal of the running machines tree. | ||
+ | |||
+ | There are two brief (contrived) examples: | ||
+ | < | ||
+ | (machine m | ||
+ | (state s) (state t) | ||
+ | (ontime 1500 s->t) (ontime 1500 t->s) | ||
+ | ) | ||
+ | (machine n | ||
+ | (state a) (state b) (state c) | ||
+ | (ontime 2000 a->b) (ontime 2000 b->c) (ontime 2000 c->a) | ||
+ | ) | ||
+ | (spawn m s) | ||
+ | (spawn n a) | ||
+ | </ | ||
+ | < | ||
+ | (machine m | ||
+ | (state s) (state t) | ||
+ | (ontime 1500 s->t) (ontime 1500 t->s) | ||
+ | ) | ||
+ | (machine n | ||
+ | (state a) (state b) (state c) | ||
+ | (ontime 2000 a->b) (ontime 2000 b->c) (ontime 2000 c->a) | ||
+ | ) | ||
+ | (machine o | ||
+ | (state p | ||
+ | (onentry (spawn m s)) | ||
+ | (onentry (spawn n a))) | ||
+ | ) | ||
+ | (spawn o p) | ||
+ | </ | ||
+ | |||
+ | |||
+ | === Exit transitions === | ||
+ | |||
+ | In a nested machine it is possible to define transitions that go to a state of the parent machine, effectively exiting the nested machine. Such transitions are like normal transactions, | ||
+ | |||
+ | A simple example is as follows. As soon as the '' | ||
+ | < | ||
+ | (machine root | ||
+ | (var out := [false]) | ||
+ | (state one | ||
+ | (machine nested | ||
+ | (state onen) | ||
+ | (exit goout onen-> | ||
+ | (event goout [out])) | ||
+ | (onentry (spawn nested onen)) | ||
+ | ) | ||
+ | (state two) | ||
+ | ) | ||
+ | (spawn root one) | ||
+ | </ | ||
+ | |||
+ | === Eventless transitions === | ||
+ | |||
+ | It can become tedious for transitions to need an event as a trigger, since it requires the definition of an event as a separate statement. This is especially tedious when the transition is the only that references that event. To ease this tedium, transitions also accept a block instead of an event name. This block should return true for the transition to trigger. | ||
+ | |||
+ | Eventless transitions are in fact syntactic sugar: an event is generated and added to the machine, with as action block the block that was specified in the transition, and the transition instead then refers to that event. | ||
+ | |||
+ | === User interface: Transition to and Jump to === | ||
+ | |||
+ | The LRP user interface allows for the user to force a machine in a given state. By right-clicking on a state in the visualisation a menu appears, with the option to '' | ||
+ | |||
+ | Transition to and jump to also combine with concurrency (see above for concurrency): | ||
==== Downloads ==== | ==== Downloads ==== | ||
Line 169: | Line 282: | ||
Next time the LRP interpreter is opened the ROS bridge UI will open, asking for the name of the class that represents the current package. | Next time the LRP interpreter is opened the ROS bridge UI will open, asking for the name of the class that represents the current package. | ||
+ | |||
+ | If you have problems installing PhaROS, you can bypass the main installation by downloading only the PhaROS API for Pharo. | ||
+ | Gofer it | ||
+ | smalltalkhubUser: | ||
+ | configuration; | ||
+ | load | ||
+ | |||
+ | After installing PhaROS, you can install the LRP ROS bridge (see above). | ||
+ | |||
+ | === Parrot AR.Drone Support === | ||
+ | |||
+ | The Parrot AR.Drone 2 is also supported in LRP. To use it, get the Pharo API from [[http:// | ||
+ | |||
+ | Example LRP code for the drone [[https:// | ||
=== Lego Mindstorms EV3 Support === | === Lego Mindstorms EV3 Support === |