Skip to content
Snippets Groups Projects
Commit 771a3a8f authored by Johannes Mey's avatar Johannes Mey
Browse files

remove pick and drop tokens

parent 4d2109d3
No related branches found
No related tags found
No related merge requests found
......@@ -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)) {
......
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;
......@@ -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;
}
}
}
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();
......
......@@ -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;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment