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

increase times, wait for full table a start of parse

parent ecefc480
Branches
No related tags found
No related merge requests found
......@@ -12,9 +12,9 @@ aspect CleanupAttributes {
}
syn double ASTNode.time(); // TODO can this be avoided?
eq RobotIsNotReadyToPick.time() = 2;
eq RobotIsNotReadyToDrop.time() = 2;
eq WaitForEmptyTable.time() = 1;
eq RobotIsNotReadyToPick.time() = 4;
eq RobotIsNotReadyToDrop.time() = 4;
eq WaitForEmptyTable.time() = 4;
eq ASTNode.time() {
throw new UnsupportedOperationException("Invalid use of attribute time():double");
}
......
Tidy : MotionGrammarElement ::= MoveObjectToCorrectPlace* WaitForEmptyTable* EmptyTable;
Tidy : MotionGrammarElement ::= WaitForFullTable* MoveObjectToCorrectPlace* WaitForEmptyTable* EmptyTable;
MoveObjectToCorrectPlace : MotionGrammarElement ::= ObjectAtWrongPlace/*provides object*/ PickUpObject/*uses object*/ DropObjectAtRightPlace/*uses object*/;
PickUpObject/*requires object*/ : MotionGrammarElement ::= RobotIsReadyToPick;
abstract RobotIsReadyToPick : MotionGrammarElement;
......@@ -9,6 +9,7 @@ RobotIsReallyReadyToDrop : RobotIsReadyToDrop ::= RobotIsReadyToDropToken;
RobotIsNotReadyToDrop : RobotIsReadyToDrop ::= RobotIsNotReadyToDropToken Wait/*uses const "1sec"*/ RobotIsReadyToDrop;
DropObjectAtRightPlace/*requires object*/ : MotionGrammarElement ::= RobotIsReadyToDrop RightPlace/*uses object, provides place*/;
WaitForEmptyTable : MotionGrammarElement ::= NotEmptyTable Wait/*uses const "1sec"*/;
WaitForFullTable : MotionGrammarElement ::= EmptyTable Wait/*uses const "1sec"*/;
// Tokens
EmptyTable : Token;
......
......@@ -9,13 +9,13 @@ aspect SemanticActions {
java.util.concurrent.Executors.newSingleThreadExecutor().submit(() -> {
scene.getTable().getRobot().setIsIdle(false);
try {
Thread.sleep(1200);
Thread.sleep(3000);
} catch (InterruptedException e) { /* ignore */ }
MovableObject object = scene.getTable().getMovableObjectByName(objectName);
scene.getTable().getRobot().setAttachedItem(object);
object.setPose(Pose.of(-1, -1, -1));
try {
Thread.sleep(1200);
Thread.sleep(3000);
} catch (InterruptedException e) { /* ignore */ }
scene.getTable().getRobot().setIsIdle(true);
});
......@@ -38,14 +38,14 @@ aspect SemanticActions {
java.util.concurrent.Executors.newSingleThreadExecutor().submit(() -> {
scene.getTable().getRobot().setIsIdle(false);
try {
Thread.sleep(1200);
Thread.sleep(3000);
} catch (InterruptedException e) { /* ignore */ }
MovableObject object = scene.getTable().getMovableObjectByName(objectName);
Bin bin = scene.getTable().getBinByName(placeName);
object.setPose(Pose.of(bin.getPose()));
scene.getTable().getRobot().setAttachedItem(null);
try {
Thread.sleep(1200);
Thread.sleep(3000);
} catch (InterruptedException e) { /* ignore */ }
scene.getTable().getRobot().setIsIdle(true);
});
......
......@@ -36,6 +36,17 @@ public final class RobotParser extends MotionGrammarParser<Tidy> {
result.parser = this;
parent.setChild(result, index);
while (true) {
peekEmptyTable();
if (peekedEmptyTable_ != null) {
int i = result.getNumWaitForFullTable();
result.addWaitForFullTable(null);
parseWaitForFullTable(result.getWaitForFullTableList(), i);
} else {
break;
}
}
while (true) {
peekObjectAtWrongPlace(result);
if (peekedObjectAtWrongPlace_ != null) {
......@@ -58,9 +69,9 @@ public final class RobotParser extends MotionGrammarParser<Tidy> {
}
}
parseEmptyTable(result, 2);
parseEmptyTable(result, 3);
// semantic action for T
// semantic action for Tidy
result.action(getWorld());
printAST("parseTidy", result);
}
......@@ -79,6 +90,19 @@ public final class RobotParser extends MotionGrammarParser<Tidy> {
printAST("parseMoveObjectToCorrectPlace", result);
}
private void parseWaitForFullTable(ASTNode<?> parent, int index) throws ParseException {
WaitForFullTable result = new WaitForFullTable();
result.parser = this;
parent.setChild(result, index);
parseEmptyTable(result, 0);
parseWait(result, 1);
// semantic action for WaitForFullTable
result.action(getWorld());
printAST("parseWaitForFullTable", result);
}
private void parseWaitForEmptyTable(ASTNode<?> parent, int index) throws ParseException {
WaitForEmptyTable result = new WaitForEmptyTable();
result.parser = this;
......@@ -401,6 +425,11 @@ public final class RobotParser extends MotionGrammarParser<Tidy> {
printAST("parseObjectAtWrongPlace", result);
}
private boolean peekEmptyTable() {
peekedEmptyTable_ = getWorld().parseEmptyTable();
return peekedEmptyTable_ != null;
}
private void parseEmptyTable(ASTNode<?> parent, int index) throws ParseException {
EmptyTable result;
......
......@@ -36,7 +36,7 @@ public class DiagramProvider {
private DiagramProvider() {
asts = new ArrayList<>();
Javalin app = Javalin.create().start(7070);
Javalin app = Javalin.create(config -> config.enableCorsForOrigin("http://localhost:3000")).start(7070);
app.get("/", ctx -> ctx.result("Hello World"));
app.get("/asts/", ctx -> {
......@@ -64,7 +64,7 @@ public class DiagramProvider {
asts.add(new AST(timestamp, step, parseRule, Files.readString(diagramPath)));
clients.keySet().forEach(session -> {
System.err.println("sending");
session.send(asts);
session.send(asts.get(asts.size()-1));
});
} catch (IOException e) {
System.err.println("Unable to read AST diagram file " + diagramPath);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment