From d2056824a1a200cccdfe1ad4dcb81d9fc0ab9fd5 Mon Sep 17 00:00:00 2001 From: Johannes Mey <johannes.mey@tu-dresden.de> Date: Wed, 13 Apr 2022 16:49:32 +0200 Subject: [PATCH] update pages --- pages/docs/index.md | 4 +- pages/docs/load-parsing.md | 21 ++++++++++ pages/docs/load.md | 42 +++++++++++++++++++ pages/docs/parsing.md | 21 ---------- pages/docs/sorting-parsing.md | 40 ++++++++++++++++++ pages/docs/sorting.md | 3 ++ pages/mkdocs.yml | 7 +++- src/main/jastadd/cleanup/RobotWorld.jadd | 2 - src/main/jastadd/cleanup/SemanticActions.jadd | 8 ++-- 9 files changed, 118 insertions(+), 30 deletions(-) create mode 100644 pages/docs/load-parsing.md create mode 100644 pages/docs/load.md delete mode 100644 pages/docs/parsing.md create mode 100644 pages/docs/sorting-parsing.md create mode 100644 pages/docs/sorting.md diff --git a/pages/docs/index.md b/pages/docs/index.md index 0834143..45b29f2 100644 --- a/pages/docs/index.md +++ b/pages/docs/index.md @@ -1,4 +1,4 @@ -# Motion Grammar Parser for JastAdd Example +# Motion Grammar Parser for JastAdd Examples A testbed for a potential *motion grammar*[^1] implementation using JastAdd. @@ -23,7 +23,7 @@ elements. There are no attributes used so far, but at each point where a semantic action takes place, the AST is printed to a file in `src/gen/resources/diagrams/parsing`, demonstrating the "available" part of the AST, which could be used by -attributes. This trace is shown [here](/parsing). +attributes. This trace is shown [here](/load-parsing). Detailed notes: diff --git a/pages/docs/load-parsing.md b/pages/docs/load-parsing.md new file mode 100644 index 0000000..260567d --- /dev/null +++ b/pages/docs/load-parsing.md @@ -0,0 +1,21 @@ +# Parsing the Load/Unload World + +| Action | World | Motion Grammar | +|--------|--------------------------------------------------------------|----------------------------------------------------| +| |  | | +| Load |  |  | +| Load |  |  | +| Load |  |  | +| Full |  |  | +| T2 |  |  | +| T |  |  | +| Unload |  |  | +| T1 |  |  | +| T |  |  | +| Unload |  |  | +| T1 |  |  | +| T |  |  | +| Unload |  |  | +| T1 |  |  | +| T |  |  | +| |  |  | diff --git a/pages/docs/load.md b/pages/docs/load.md new file mode 100644 index 0000000..5b843ff --- /dev/null +++ b/pages/docs/load.md @@ -0,0 +1,42 @@ +# The Load/Unload Grammar + +The motion grammar describes the Load/Unload scenario from Dantam[^1]. The point of this very simple grammar was *not* +to show how motion grammars work, but rather the expressiveness of a CFG (compared to a regular grammar), but it is very +simple, so it serves as a starting point. + + + +The grammar comprises three parts. `MotionGrammar` contains generic nonterminals present in every motion +grammar, `LoadUnload` has the actual nonterminals of the grammar, and `World` describes the context within which the +grammar is parsed. + +## Execution (Parsing) and Implementation Details + +Currently, the parser reads a sequence of `Load`, `Unload`, and `Full` tokens and loads a `Container` with up to ten +elements. + +There are no attributes used so far, but at each point where a semantic action takes place, the AST is printed to a file +in `src/gen/resources/diagrams/parsing`, demonstrating the "available" part of the AST, which could be used by +attributes. This trace is shown [here](/load-parsing). + +Detailed notes: + +- Tokens can have semantic actions. This might be a difference to the original motion grammar concept, but could easily + be simulated by adding another nonterminal enclosing each token. +- The `Load` token currently can always be parsed. This is problematic, since it requires a fixed order in the parser + rule for `T`. A workaround would be to introduce a new token `NotFull` before the load token. +- The parser `Worldparser.java` uses three kinds of parse methods: + - `parse` distinguishes an abstract rule (for `T`, but since it is the entrypoint, it has this generic name). This + only works like this if the abstract rule does *not* have any elements, which can be achieved by a simple + transformation, but maybe breaks the attribute part of the grammar. This method needs a lookahead, which is done + by a peek method. The peek method actually parses the next token and keeps it in a cache, which is read by the + token parse method later. + - `parseT1` and `parseT2` do not need lookahead. + - `parseLoad`, `parseUnload`, and `parseFull` parse tokens. +- There are no thoughts on parsing lists and optional children yet. + +## Bibliogaphy + +[^1]: Dantam, N., Stilman, M., 2013. The Motion Grammar: Analysis of a Linguistic Method for Robot Control. IEEE Trans. +Robot. 29, 704–718. https://doi.org/10.1109/TRO.2013.2239553 + diff --git a/pages/docs/parsing.md b/pages/docs/parsing.md deleted file mode 100644 index 4faa06d..0000000 --- a/pages/docs/parsing.md +++ /dev/null @@ -1,21 +0,0 @@ -# Parsing the Load/Unload World - -| Action | World | Motion Grammar | -|--------|---------------------------------------------------------------------------------|------------------------------------------------------------------------| -| |  | | -| Load |  |  | -| Load |  |  | -| Load |  |  | -| Full |  |  | -| T2 |  |  | -| T |  |  | -| Unload |  |  | -| T1 |  |  | -| T |  |  | -| Unload |  |  | -| T1 |  |  | -| T |  |  | -| Unload |  |  | -| T1 |  |  | -| T |  |  | -| |  |  | diff --git a/pages/docs/sorting-parsing.md b/pages/docs/sorting-parsing.md new file mode 100644 index 0000000..91ea99b --- /dev/null +++ b/pages/docs/sorting-parsing.md @@ -0,0 +1,40 @@ +# Parsing the Robot Sorting World + +| Action | World | Motion Grammar | +|---------------------------|--------------------------------------------------------------------------------|----------------------------------------------------------------------| +| |  | | +| ObjectAtWrongPlace |  |  | +| RobotIsFree |  |  | +| RobotIsReallyReadyToPick |  |  | +| PickUpObject |  |  | +| Pick |  |  | +| PickUpObject |  |  | +| RightPlace |  |  | +| Drop |  |  | +| DropObjectAtRightPlace |  |  | +| MoveObjectToCorrectPlace |  |  | +| ObjectAtWrongPlace |  |  | +| RobotIsBusy |  |  | +| Wait |  |  | +| RobotIsBusy |  |  | +| Wait |  |  | +| RobotIsFree |  |  | +| RobotIsReallyReadyToPick |  |  | +| PickUpObject |  |  | +| RobotIsNotReadyToPick |  |  | +| PickUpObject |  |  | +| RobotIsNotReadyToPick |  |  | +| PickUpObject |  |  | +| Pick |  |  | +| PickUpObject |  |  | +| RightPlace |  |  | +| Drop |  |  | +| DropObjectAtRightPlace |  |  | +| MoveObjectToCorrectPlace |  |  | +| NotEmptyTable |  |  | +| Wait |  |  | +| WaitForEmptyTable |  |  | +| EmptyTable |  |  | +| Tidy |  |  | +| |  |  | + diff --git a/pages/docs/sorting.md b/pages/docs/sorting.md new file mode 100644 index 0000000..3c57634 --- /dev/null +++ b/pages/docs/sorting.md @@ -0,0 +1,3 @@ +# The Robot Sorting Grammar + + diff --git a/pages/mkdocs.yml b/pages/mkdocs.yml index f489d98..d99c565 100644 --- a/pages/mkdocs.yml +++ b/pages/mkdocs.yml @@ -4,7 +4,12 @@ site_dir: ../public nav: - "Overview": index.md - - "Parsing Example": parsing.md + - "Load-Unload Grammar": + - "Overview": load.md + - "Parsing": load-parsing.md + - "Sorting Example": + - "Overview": sorting.md + - "Parsing": sorting-parsing.md - "API documentation": ragdoc/index.html theme: diff --git a/src/main/jastadd/cleanup/RobotWorld.jadd b/src/main/jastadd/cleanup/RobotWorld.jadd index 205ae76..a3a5659 100644 --- a/src/main/jastadd/cleanup/RobotWorld.jadd +++ b/src/main/jastadd/cleanup/RobotWorld.jadd @@ -4,10 +4,8 @@ aspect RobotWorld { Table t = new Table(); t.addPhysicalObject(new Bin("binRed", Pose.of(-10, -10, 0), "red")); t.addPhysicalObject(new Bin("binGreen", Pose.of(-10, 0, 0), "green")); - t.addPhysicalObject(new Bin("binBlue", Pose.of(-10, 10, 0), "blue")); t.addPhysicalObject(new MovableObject("boxRed", Pose.of(-5, -10, 0), "red")); t.addPhysicalObject(new MovableObject("boxGreen", Pose.of(-5, 0, 0), "green")); - t.addPhysicalObject(new MovableObject("boxBlue", Pose.of(-5, 10, 0), "blue")); Robot b = new Robot(); b.setIsIdle(true); return new RobotScene(t, b); diff --git a/src/main/jastadd/cleanup/SemanticActions.jadd b/src/main/jastadd/cleanup/SemanticActions.jadd index a1d6d88..b3e0a42 100644 --- a/src/main/jastadd/cleanup/SemanticActions.jadd +++ b/src/main/jastadd/cleanup/SemanticActions.jadd @@ -8,11 +8,11 @@ aspect SemanticActions { @Override public void run() { scene.getRobot().setIsIdle(false); - try { Thread.sleep(1500); } catch (InterruptedException e) { /* ignore */ } + try { Thread.sleep(1200); } catch (InterruptedException e) { /* ignore */ } MovableObject object = scene.getTable().getMovableObjectByName(objectName); scene.getRobot().setAttachedItem(object); object.setPose(Pose.of(-1,-1,-1)); - try { Thread.sleep(2500); } catch (InterruptedException e) { /* ignore */ } + try { Thread.sleep(1200); } catch (InterruptedException e) { /* ignore */ } scene.getRobot().setIsIdle(true); } }); @@ -27,12 +27,12 @@ aspect SemanticActions { @Override public void run() { scene.getRobot().setIsIdle(false); - try { Thread.sleep(3500); } catch (InterruptedException e) { /* ignore */ } + try { Thread.sleep(1200); } catch (InterruptedException e) { /* ignore */ } MovableObject object = scene.getTable().getMovableObjectByName(objectName); Bin bin = scene.getTable().getBinByName(placeName); object.setPose(Pose.of(bin.getPose())); scene.getRobot().setAttachedItem(null); - try { Thread.sleep(1500); } catch (InterruptedException e) { /* ignore */ } + try { Thread.sleep(1200); } catch (InterruptedException e) { /* ignore */ } scene.getRobot().setIsIdle(true); } }); -- GitLab