diff --git a/src/main/jastadd/cleanup/Cleanup.jrag b/src/main/jastadd/cleanup/Cleanup.jrag index 41c9a4ec039a261a3b08f0a7f60da16502f86e09..62540f0f837a6e3f3f780dec537888b2b7149076 100644 --- a/src/main/jastadd/cleanup/Cleanup.jrag +++ b/src/main/jastadd/cleanup/Cleanup.jrag @@ -2,9 +2,7 @@ aspect CleanupAttributes { inh String ASTNode.object(); // TODO can this be avoided? inh String PickUpObject.object(); - inh String Pick.object(); inh String RightPlace.object(); - inh String Drop.object(); inh String DropObjectAtRightPlace.object(); eq MoveObjectToCorrectPlace.getPickUpObject().object() = getObjectAtWrongPlace().getObject(); eq MoveObjectToCorrectPlace.getDropObjectAtRightPlace().object() = getObjectAtWrongPlace().getObject(); @@ -32,9 +30,6 @@ aspect CleanupAttributes { throw new UnsupportedOperationException("Invalid use of attribute place():String"); } - inh String Drop.place(); - eq DropObjectAtRightPlace.getDrop().place() = place(); - syn boolean Tidy.inPlan(String object) { for (MoveObjectToCorrectPlace m : getMoveObjectToCorrectPlaceList()) { if (m.object().equals(object)) { diff --git a/src/main/jastadd/cleanup/Cleanup.relast b/src/main/jastadd/cleanup/Cleanup.relast index a2a86f5cdd1b151af53e9b64cdfec11e8fab9c88..537b1740b7e03cc15d033da10925192099eb16f9 100644 --- a/src/main/jastadd/cleanup/Cleanup.relast +++ b/src/main/jastadd/cleanup/Cleanup.relast @@ -1,20 +1,19 @@ Tidy : MotionGrammarElement ::= MoveObjectToCorrectPlace* WaitForEmptyTable* EmptyTable; MoveObjectToCorrectPlace : MotionGrammarElement ::= ObjectAtWrongPlace/*provides object*/ PickUpObject/*uses object*/ DropObjectAtRightPlace/*uses object*/; -PickUpObject/*requires object*/ : MotionGrammarElement ::= RobotIsReadyToPick Pick/*uses object*/; +PickUpObject/*requires object*/ : MotionGrammarElement ::= RobotIsReadyToPick; abstract RobotIsReadyToPick : MotionGrammarElement; RobotIsReallyReadyToPick : RobotIsReadyToPick ::= RobotIsReadyToPickToken; RobotIsNotReadyToPick : RobotIsReadyToPick ::= RobotIsNotReadyToPickToken Wait/*uses const "1sec"*/ RobotIsReadyToPick; abstract RobotIsReadyToDrop : MotionGrammarElement; RobotIsReallyReadyToDrop : RobotIsReadyToDrop ::= RobotIsReadyToDropToken; RobotIsNotReadyToDrop : RobotIsReadyToDrop ::= RobotIsNotReadyToDropToken Wait/*uses const "1sec"*/ RobotIsReadyToDrop; -DropObjectAtRightPlace/*requires object*/ : MotionGrammarElement ::= RobotIsReadyToDrop RightPlace/*uses object, provides place*/ Drop/*uses place*/; +DropObjectAtRightPlace/*requires object*/ : MotionGrammarElement ::= RobotIsReadyToDrop RightPlace/*uses object, provides place*/; WaitForEmptyTable : MotionGrammarElement ::= NotEmptyTable Wait/*uses const "1sec"*/; // Tokens EmptyTable : Token; NotEmptyTable : Token; // TODO should be improved to express EmptyTable can not be parsed ObjectAtWrongPlace : Token ::= <Object:String>; // the Object is a variable of the token -Pick/*requires object*/ : Token; RobotIsReadyToPickToken : Token ::= RobotIsIdle RobotHasNoItemAttached; // combined token. both individual tokens are parsed in parallel RobotIsNotReadyToPickToken : Token ::= [RobotIsNotIdle] /*or*/ [RobotHasItemAttached]; // TODO negated RobotIsReadyToPickToken RobotIsReadyToDropToken : Token ::= RobotIsIdle RobotHasItemAttached; // combined token. both individual tokens are parsed in parallel @@ -25,4 +24,3 @@ RobotHasItemAttached : Token; RobotHasNoItemAttached : Token; // TODO negated RobotHasItemAttached Wait/*requires time*/ : Token; // artificial token, which parsing takes a specified amount of time RightPlace/*requires object*/ : Token ::= <Place:String>; -Drop/*requires object and place*/ : Token; diff --git a/src/main/jastadd/cleanup/RobotWorld.jadd b/src/main/jastadd/cleanup/RobotWorld.jadd index e8d8619bce2f69e479027e9fd90f627b6446c1b5..335eba4c8893109636f15a461bd40e52fe6592a2 100644 --- a/src/main/jastadd/cleanup/RobotWorld.jadd +++ b/src/main/jastadd/cleanup/RobotWorld.jadd @@ -14,7 +14,6 @@ aspect RobotWorld { public static TokenType EmptyTable.type() { return TokenType.of("EMPTY_TABLE"); } public static TokenType NotEmptyTable.type() { return TokenType.of("NOT_EMPTY_TABLE"); } public static TokenType ObjectAtWrongPlace.type() { return TokenType.of("OBJECT_AT_WRONG_PLACE"); } - public static TokenType Pick.type() { return TokenType.of("PICK"); } public static TokenType RobotIsReadyToPickToken.type() { return TokenType.of("ROBOT_IS_READY_TO_PICK_TOKEN"); } public static TokenType RobotIsNotReadyToPickToken.type() { return TokenType.of("ROBOT_IS_NOT_READY_TO_PICK_TOKEN"); } public static TokenType RobotIsReadyToDropToken.type() { return TokenType.of("ROBOT_IS_READY_TO_DROP_TOKEN"); } @@ -25,7 +24,6 @@ aspect RobotWorld { public static TokenType RobotHasNoItemAttached.type() { return TokenType.of("ROBOT_HAS_NO_ITEM_ATTACHED"); } public static TokenType Wait.type() { return TokenType.of("WAIT"); } public static TokenType RightPlace.type() { return TokenType.of("RIGHT_PLACE"); } - public static TokenType Drop.type() { return TokenType.of("DROP"); } public static Pose Pose.of(double x, double y, double z) { return new Pose(x, y, z, 0, 0, 0, 1); @@ -84,22 +82,6 @@ aspect RobotWorld { return null; } - public Pick World.parsePick(String objectName) { - return null; - } - public Pick RobotScene.parsePick(String objectName) { - System.out.print("Trying to parse token <Pick> for Object \"" + objectName + "\"... "); - MovableObject o = getTable().getMovableObjectByName(objectName); - - if (o != null) { - System.out.println("success"); - return new Pick(); - } else { - System.out.println("failure"); - return null; - } - } - public RobotIsReadyToPickToken World.parseRobotIsReadyToPickToken() { return null; } @@ -250,21 +232,4 @@ aspect RobotWorld { return null; } } - - public Drop World.parseDrop(String objectName, String placeName) { - return null; - } - public Drop RobotScene.parseDrop(String objectName, String placeName) { - System.out.print("Trying to parse token <Drop> for Object \"" + objectName + "\" and Bin \"" + placeName + "\"... "); - MovableObject o = getTable().getMovableObjectByName(objectName); - Bin b = getTable().getBinByName(placeName); - - if (o != null && b != null) { - System.out.println("success"); - return new Drop(); - } else { - System.out.println("failure"); - return null; - } - } } diff --git a/src/main/jastadd/cleanup/SemanticActions.jadd b/src/main/jastadd/cleanup/SemanticActions.jadd index 056e96cdb18db2f28e4230838ab0b86f4b7a094e..54aee93a2a04412adcf511fe12744299855bdf65 100644 --- a/src/main/jastadd/cleanup/SemanticActions.jadd +++ b/src/main/jastadd/cleanup/SemanticActions.jadd @@ -1,6 +1,6 @@ aspect SemanticActions { - public void Pick.action(World world) { + public void PickUpObject.action(World world) { RobotScene scene = world.asRobotScene(); System.out.println("performing semantic action for element Pick"); String objectName = object(); @@ -15,7 +15,7 @@ aspect SemanticActions { }); } - public void Drop.action(World world) { + public void DropObjectAtRightPlace.action(World world) { RobotScene scene = world.asRobotScene(); System.out.println("performing semantic action for element Pick"); String objectName = object(); @@ -42,4 +42,4 @@ aspect SemanticActions { } } -} \ No newline at end of file +} diff --git a/src/main/java/de/tudresden/inf/st/mg/RobotParser.java b/src/main/java/de/tudresden/inf/st/mg/RobotParser.java index d87078cc1a0e7b9a81b3648d8327125490b5eca6..0af51f88a7ba60e32aad9b5e6263b49b88c932b6 100644 --- a/src/main/java/de/tudresden/inf/st/mg/RobotParser.java +++ b/src/main/java/de/tudresden/inf/st/mg/RobotParser.java @@ -19,7 +19,6 @@ public final class RobotParser extends MotionGrammarParser<Tidy> { private EmptyTable peekedEmptyTable_ = null; private NotEmptyTable peekedNotEmptyTable_ = null; private ObjectAtWrongPlace peekedObjectAtWrongPlace_ = null; - private Pick peekedPick_ = null; private RobotIsReadyToPickToken peekedRobotIsReadyToPickToken_ = null; private RobotIsNotReadyToPickToken peekedRobotIsNotReadyToPickToken_ = null; private RobotIsReadyToDropToken peekedRobotIsReadyToDropToken_ = null; @@ -30,7 +29,6 @@ public final class RobotParser extends MotionGrammarParser<Tidy> { private RobotHasNoItemAttached peekedRobotHasNoItemAttached_ = null; private Wait peekedWait_ = null; private RightPlace peekedRightPlace_ = null; - private Drop peekedDrop_ = null; @Override protected void parse(ASTNode<?> parent, int index) throws ParseException { @@ -97,33 +95,12 @@ public final class RobotParser extends MotionGrammarParser<Tidy> { parseRobotIsReadyToDrop(result, 0); parseRightPlace(result, 1); - parseDrop(result, 2); // semantic action for DropObjectAtRightPlace result.action(getWorld()); printAST("parseDropObjectAtRightPlace", result); } - private void parseDrop(ASTNode<?> parent, int index) throws ParseException { - Drop result; - - if (peekedDrop_ != null) { - result = peekedDrop_; - peekedDrop_ = null; // TODO check if all peeked values are actually parsed afterwards - } else { - result = getWorld().parseDrop(parent.object(), parent.place()); - if (result == null) { - throw new ParseException(Drop.type()); - } - } - - parent.setChild(result, index); - - // semantic action for Drop - result.action(getWorld()); - printAST("parseDrop", result); - } - private void parseRightPlace(ASTNode<?> parent, int index) throws ParseException { RightPlace result; @@ -149,33 +126,12 @@ public final class RobotParser extends MotionGrammarParser<Tidy> { parent.setChild(result, index); parseRobotIsReadyToPick(result, 0); - parsePick(result, 1); // semantic action for T1 result.action(getWorld()); printAST("parsePickUpObject", result); } - private void parsePick(ASTNode<?> parent, int index) throws ParseException { - Pick result; - - if (peekedPick_ != null) { - result = peekedPick_; - peekedPick_ = null; // TODO check if all peeked values are actually parsed afterwards - } else { - result = getWorld().parsePick(parent.object()); - if (result == null) { - throw new ParseException(Pick.type()); - } - } - - parent.setChild(result, index); - - // semantic action for Pick - result.action(getWorld()); - printAST("parsePick", result); - } - private void parseRobotIsReadyToPick(ASTNode<?> parent, int index) throws ParseException { RobotIsReadyToPick result;