Skip to content
Snippets Groups Projects
Commit ed456229 authored by René Schöne's avatar René Schöne
Browse files

towards final case study scenario

parent 30773aee
Branches
Tags
No related merge requests found
Pipeline #13672 failed
Showing
with 216 additions and 68 deletions
......@@ -13,7 +13,7 @@ dependencies {
grammar2uml group: 'de.tudresden.inf.st', name: 'grammar2uml', version: '0.2.3'
relast group: 'org.jastadd', name: 'relast', version: "0.4.0-143"
ragconnect group: 'de.tudresden.inf.st', name: 'ragconnect', version: '1.0.0-alpha-198'
ragconnect group: 'de.tudresden.inf.st', name: 'ragconnect', version: '1.0.0-alpha-203'
implementation group: 'de.tudresden.inf.st', name: 'dumpAst', version: '1.0.2-68'
}
......
......@@ -36,7 +36,8 @@ task ragConnect(type: JavaExec) {
'--List=JastAddList',
'--experimental-jastadd-329',
'--incremental=param',
"--tracing=cache,flush"
'--tracing=cache,flush',
'--evaluationCounter'
])
}
......
{ "objects": [
{ "id": "target_Blue","type": "DROP_OFF_LOCATION","pos": { "x": 8,"y": 3,"z": 0.8325 },"size": { "length": 0.21,"width": 0.3,"height": 0.165 },"orientation": { "w": 1 },"color": { "r": 1 } },
{ "id": "target_Green","type": "DROP_OFF_LOCATION","pos": { "x": 1,"y": 1,"z": 0.8325 },"size": { "length": 0.21,"width": 0.3,"height": 0.165 },"orientation": { "w": 1 },"color": { "r": 1 } },
{ "id": "bigBlue","type": "BOX","pos": { "x": 8,"y": 3,"z": 0.8105 },"size": { "length": 0.031,"width": 0.062,"height": 0.121 },"orientation": { "z": 0.382683,"w": 0.92388 },"color": { "r": 1 } },
{ "id": "bigGreen","type": "BOX","pos": { "x": 1,"y": 1,"z": 0.8105 },"size": { "length": 0.031,"width": 0.062,"height": 0.121 },"orientation": { "z": 0.382683,"w": 0.92388 },"color": { "r": 1 } }
{ "id": "target_blue1","type": "DROP_OFF_LOCATION","pos": { "x": 11,"y": 11,"z": 11 },"size": { "length": 0.21,"width": 0.3,"height": 0.165 },"orientation": { "w": 1 },"color": { "r": 1 } },
{ "id": "target_blue2","type": "DROP_OFF_LOCATION","pos": { "x": 12,"y": 12,"z": 12 },"size": { "length": 0.21,"width": 0.3,"height": 0.165 },"orientation": { "w": 1 },"color": { "r": 1 } },
{ "id": "target_blue3","type": "DROP_OFF_LOCATION","pos": { "x": 13,"y": 13,"z": 13 },"size": { "length": 0.21,"width": 0.3,"height": 0.165 },"orientation": { "w": 1 },"color": { "r": 1 } },
{ "id": "target_green1","type": "DROP_OFF_LOCATION","pos": { "x": 21,"y": 21,"z": 21 },"size": { "length": 0.21,"width": 0.3,"height": 0.165 },"orientation": { "w": 1 },"color": { "r": 1 } },
{ "id": "target_green2","type": "DROP_OFF_LOCATION","pos": { "x": 22,"y": 22,"z": 22 },"size": { "length": 0.21,"width": 0.3,"height": 0.165 },"orientation": { "w": 1 },"color": { "r": 1 } },
{ "id": "target_red1","type": "DROP_OFF_LOCATION","pos": { "x": 31,"y": 31,"z": 31 },"size": { "length": 0.21,"width": 0.3,"height": 0.165 },"orientation": { "w": 1 },"color": { "r": 1 } },
{ "id": "target_red2","type": "DROP_OFF_LOCATION","pos": { "x": 32,"y": 32,"z": 32 },"size": { "length": 0.21,"width": 0.3,"height": 0.165 },"orientation": { "w": 1 },"color": { "r": 1 } },
{ "id": "blue1","type": "BOX","pos": { "x": 11,"y": 11,"z": 11 },"size": { "length": 0.031,"width": 0.062,"height": 0.121 },"orientation": { "z": 0.382683,"w": 0.92388 },"color": { "r": 1 } },
{ "id": "blue2","type": "BOX","pos": { "x": 12,"y": 12,"z": 12 },"size": { "length": 0.031,"width": 0.062,"height": 0.121 },"orientation": { "z": 0.382683,"w": 0.92388 },"color": { "r": 1 } },
{ "id": "blue3","type": "BOX","pos": { "x": 13,"y": 13,"z": 13 },"size": { "length": 0.031,"width": 0.062,"height": 0.121 },"orientation": { "z": 0.382683,"w": 0.92388 },"color": { "r": 1 } },
{ "id": "green1","type": "BOX","pos": { "x": 21,"y": 21,"z": 21 },"size": { "length": 0.031,"width": 0.062,"height": 0.121 },"orientation": { "z": 0.382683,"w": 0.92388 },"color": { "r": 1 } },
{ "id": "green2","type": "BOX","pos": { "x": 22,"y": 22,"z": 22 },"size": { "length": 0.031,"width": 0.062,"height": 0.121 },"orientation": { "z": 0.382683,"w": 0.92388 },"color": { "r": 1 } },
{ "id": "red1","type": "BOX","pos": { "x": 31,"y": 31,"z": 31 },"size": { "length": 0.031,"width": 0.062,"height": 0.121 },"orientation": { "z": 0.382683,"w": 0.92388 },"color": { "r": 1 } },
{ "id": "red2","type": "BOX","pos": { "x": 32,"y": 32,"z": 32 },"size": { "length": 0.031,"width": 0.062,"height": 0.121 },"orientation": { "z": 0.382683,"w": 0.92388 },"color": { "r": 1 } }
] }
{
"regions": [
{ "name": "G", "positions": ["target_Blue"] },
{ "name": "G", "positions": ["target_Green"] }
{ "name": "B", "positions": ["target_blue1", "target_blue2", "target_blue3"] },
{ "name": "G", "positions": ["target_green1", "target_green2"] },
{ "name": "J", "positions": ["target_red1", "target_red2"] }
]
}
......@@ -54,9 +54,10 @@ aspect BFS {
//--- prettyPrint ---
public String Graph.prettyPrint() {
StringJoiner sj = new StringJoiner("\n", "Graph {\n", "\n}");
StringJoiner sj = new StringJoiner(", ", "Graph {\n", "\n}");
if (!hasVertex()) { sj.add("<no vertices>"); }
for (Vertex v : getVertexList()) { sj.add(v.toString()); }
sj.add("\n");
if (!hasEdge()) { sj.add("<no edges>"); }
for (Edge e : getEdgeList()) { sj.add(e.prettyPrint()); }
return sj.toString();
......
......@@ -63,7 +63,7 @@ aspect RobotReachabilityToBFS {
}
}
aspect Printint {
aspect Printing {
public String VertexWithObjectOfInterest.toString() {
return "V(" + getNameOfObjectOfInterest() + ")";
}
......
......@@ -5,6 +5,7 @@ receive Robot.CanReachObjectOfInterestWrapper using ParseReachability, ConvertRe
receive Robot.OwnedCollaborationZoneNames using ConfigChangeCommandCheckForOwnedCollaborationZone ;
receive Robot.OccupiedCollaborationZoneNames using CommandCheckForOccupiedCollaborationZone ;
receive Robot.CurrentPosition ;
receive indexed with add WorldModelB.ExecutedOperation using ParseCommand, ConvertCommand ;
ParseReachability maps byte[] bytes to de.tudresden.inf.st.ceti.Reachability {:
return de.tudresden.inf.st.ceti.Reachability.parseFrom(bytes);
......@@ -20,6 +21,28 @@ ConvertReachability maps de.tudresden.inf.st.ceti.Reachability r to CanReachObje
return result;
:}
ParseCommand maps byte[] bytes to de.tudresden.inf.st.ceti.Command {:
return de.tudresden.inf.st.ceti.Command.parseFrom(bytes);
:}
ConvertCommand maps de.tudresden.inf.st.ceti.Command command to Operation {:
if (command.hasPickAndPlace()) {
return new PickAndPlace()
.setObjectToPick(worldModelB().getMyScene().getLogicalScene().resolveLogicalObjectOfInterest(command.getPickAndPlace().getIdPick()).asLogicalMovableObject())
.setTargetLocation(worldModelB().getMyScene().resolveObjectOfInterest(command.getPickAndPlace().getIdPlace()).asDropOffLocation())
.setRobotToExecute(worldModelB().findRobot(command.getPickAndPlace().getIdRobot()).get());
} else if (command.hasConfigChange()) {
return new ConfigChange()
.setCollaborationZone(worldModelB().getMyScene().resolveObjectOfInterest(command.getConfigChange().getIdCollaborationZone()).asDropOffLocation().asCollaborationZone())
.setRobotToExecute(worldModelB().findRobot(command.getConfigChange().getIdRobotNewOwner()).get());
} else if (command.hasEvacuate()) {
return new Evacuate()
.setCollaborationZone(worldModelB().getMyScene().resolveObjectOfInterest(command.getEvacuate().getIdCollaborationZone()).asDropOffLocation().asCollaborationZone())
.setRobotToExecute(worldModelB().findRobot(command.getEvacuate().getIdRobot()).get());
}
return new ErrorOperation().setErrorMessage("Could not parse operation " + command);
:}
// --- sending ---
send WorldModelB.NextOperation using PrintOperation ;
send Robot.myPosition(String) ;
......
aspect Computation {
static boolean ASTNode.VERBOSE = false;
//--- unspecifiedRegion ---
syn nta LogicalRegion WorldModelB.unspecifiedRegion() = new LogicalRegion().setName("<unspecified>");
......@@ -73,14 +75,18 @@ aspect Computation {
continue;
}
if (!myGenericObject.isLogicalMovableObject()) {
if (VERBOSE) {
System.err.println("MovableObject " + otherObject.getName() + " is not a MovableObject in myScene. Skipping!");
}
continue;
}
LogicalMovableObject myObject = myGenericObject.asLogicalMovableObject();
if (myObject.hasLocatedAt() && !otherObject.hasLocatedAt()) {
if (myObject.getLocatedAtList().size() > 1) {
if (VERBOSE) {
System.err.println("More than one region found for my " + myObject.getName() + ", using only first.");
}
}
var diff = new DifferenceObjectMisplaced();
diff.setObject(myObject);
// use first region
......@@ -89,11 +95,15 @@ aspect Computation {
continue;
}
if (myObject.getLocatedAtList().size() > 1) {
if (VERBOSE) {
System.err.println("More than one region found for my " + myObject.getName() + ", using only first.");
}
}
if (otherObject.getLocatedAtList().size() > 1) {
if (VERBOSE) {
System.err.println("More than one region found for other " + otherObject.getName() + ", using only first.");
}
}
Set<String> myRegions = myObject.regionNameSet();
Set<String> otherRegions = otherObject.regionNameSet();
if (!myObject.hasLocatedAt() && !otherObject.hasLocatedAt() ||
......@@ -176,7 +186,9 @@ aspect Computation {
*/
if (sourceLocation.isCollaborationZone()) {
CollaborationZone cz = sourceLocation.asCollaborationZone();
if (VERBOSE) {
System.out.println("source is cz, occ:" + (cz.hasOccupient() ? cz.occupient().nameAndHash() : "none") + ", owner: " + (cz.hasOwner() ? cz.owner().nameAndHash() : "none"));
}
// order is important here, first add Evacuate, then ConfigChange
if (cz.hasOccupient() && !cz.occupient().equals(executingRobot)) {
if (cz.occupient().isBusy()) {
......@@ -195,7 +207,9 @@ aspect Computation {
}
if (targetLocation.isCollaborationZone()) {
CollaborationZone cz = targetLocation.asCollaborationZone();
if (VERBOSE) {
System.out.println("target is cz, occ:" + (cz.hasOccupient() ? cz.occupient().nameAndHash() : "none") + ", owner: " + (cz.hasOwner() ? cz.owner().nameAndHash() : "none"));
}
// order is important here, first add Evacuate, then ConfigChange
if (cz.hasOccupient() && !cz.occupient().equals(executingRobot)) {
if (cz.occupient().isBusy()) {
......@@ -213,7 +227,7 @@ aspect Computation {
}
}
result.add(PickAndPlace.of(executingRobot, getObject(), targetLocation));
}, () -> result.add(new ErrorOperation("Could not find robot with name " + edge.asEdgeWithRobot().getNameOfRobot())));
}, () -> result.add(new ErrorOperation().setErrorMessage("Could not find robot with name " + edge.asEdgeWithRobot().getNameOfRobot())));
transit = target;
}
return result;
......@@ -232,7 +246,7 @@ aspect Computation {
//--- error ---
protected static List<Operation> Difference.error(String message) {
return Collections.singletonList(new ErrorOperation(message));
return Collections.singletonList(new ErrorOperation().setErrorMessage(message));
}
//--- Operation.of ---
......@@ -265,14 +279,14 @@ aspect Computation {
//--- getNextOperation ---
syn Operation WorldModelB.getNextOperation() {
if (diffToOperations().getNumChild() == 0) {
return new ErrorOperation("No operation computed!");
return new ErrorOperation().setErrorMessage("No operation computed!");
}
for (Operation op : diffToOperations()) {
if (!op.isErrorOperation()) {
return op;
}
}
return new ErrorOperation("No executable operation found!");
return new ErrorOperation().setErrorMessage("No executable operation found!");
}
//--- canReach ---
......@@ -349,7 +363,9 @@ aspect Computation {
}
private String Robot.logAndReturn(String pre, String returnValue) {
if (VERBOSE) {
System.out.println(pre + returnValue);
}
return returnValue;
}
......@@ -362,7 +378,9 @@ aspect AttributeMappings {
//--- toProtobufByteArray ---
syn byte[] Operation.toProtobufByteArray() = null;
eq ErrorOperation.toProtobufByteArray() {
if (VERBOSE) {
System.err.println(getErrorMessage());
}
return null;
}
eq Pick.toProtobufByteArray() {
......
WorldModelB ::= Region* Robot* [MyScene:Scene] OtherScene:LogicalScene* /NextOperation:Operation/ TestingOtherScene:LogicalScene* ;
WorldModelB ::= Region* Robot* [MyScene:Scene] OtherScene:LogicalScene* ExecutedOperation:Operation* /NextOperation:Operation/ ;
// FIXME inline CanReachObjectOfInterestWrapper
Robot ::= <Name:String> CanReachObjectOfInterestWrapper <OwnedCollaborationZoneNames> <OccupiedCollaborationZoneNames> <CurrentPosition> ;
......
......@@ -138,39 +138,27 @@ public class MainB extends SharedMainParts<MqttHandler, WorldModelB> {
@Override
protected void connectEndpoints() throws IOException {
for (String topic : config.forB.topicsSceneUpdate) {
checkSuccess(
model.connectMyScene(mqttUri(topic, config)),
"connectMyScene"
);
}
checkSuccess(
model.connectOtherScene(mqttUri("place-a/logical/update", config), 0),
"OtherScene"
);
checkSuccess(
model.connectNextOperation(mqttUri(config.forB.topicCommand, config), false),
"NextOperation"
);
checkSuccess(model.connectMyScene(mqttUri(topic, config)),
"connectMyScene");
}
checkSuccess(model.connectOtherScene(mqttUri("place-a/logical/update", config), 0),
"OtherScene");
checkSuccess(model.connectNextOperation(mqttUri(config.forB.topicCommand, config), false),
"NextOperation");
// checkSuccess(model.connectExecutedOperation(mqttUri(config.forB.topicCommand, config)),
// "OperationHistory");
for (Robot robot : model.getRobotList()) {
// self-loop
checkSuccess(
robot.connectOwnedCollaborationZoneNames(mqttUri(config.forB.topicCommand, config)),
"OwnedCollaborationZoneNames (" + robot.getName() + ")"
);
checkSuccess(
robot.connectOccupiedCollaborationZoneNames(mqttUri(config.forB.topicCommand, config)),
"OccupiedCollaborationZoneNames (" + robot.getName() + ")"
);
checkSuccess(robot.connectOwnedCollaborationZoneNames(mqttUri(config.forB.topicCommand, config)),
"OwnedCollaborationZoneNames (" + robot.getName() + ")");
checkSuccess(robot.connectOccupiedCollaborationZoneNames(mqttUri(config.forB.topicCommand, config)),
"OccupiedCollaborationZoneNames (" + robot.getName() + ")");
String topicPosition = joinTopics("place-b", robot.getName(), "position");
checkSuccess(
robot.connectCurrentPosition(mqttUri(topicPosition, config)),
"CurrentPosition (" + robot.getName() + ")"
);
checkSuccess(
robot.connectMyPosition(mqttUri(topicPosition, config), true),
"MyPosition (" + robot.getName() + ")"
);
checkSuccess(robot.connectCurrentPosition(mqttUri(topicPosition, config)),
"CurrentPosition (" + robot.getName() + ")");
checkSuccess(robot.connectMyPosition(mqttUri(topicPosition, config), true),
"MyPosition (" + robot.getName() + ")");
}
}
......
......@@ -130,9 +130,13 @@ public class UtilB {
sb.append(" (unset)\n");
}
sb.append("Diff: ").append(model.diffScenes().prettyPrint(Difference::prettyPrint)).append("\n");
if (detailed) {
sb.append("Graph: ").append(model.toReachabilityGraph().prettyPrint()).append("\n");
}
sb.append("Operations: ").append(model.diffToOperations().prettyPrint(Operation::prettyPrint)).append("\n");
sb.append("Next operation: ").append(model.getNextOperation().prettyPrint()).append("\n");
sb.append("Operation History: ").append(model.getExecutedOperations().prettyPrint(Operation::prettyPrint)).append("\n");
sb.append("EvaluationCounter:\n").append(model.ragconnectEvaluationCounterSummary());
return sb.toString();
}
......
......@@ -1444,11 +1444,11 @@
}
},
{
"id": "bigBlue",
"id": "blue1",
"type": "BOX",
"pos": {
"x": 0.1,
"y": -0.25,
"y": -0.7,
"z": 0.9355
},
"size": {
......@@ -1464,11 +1464,71 @@
}
},
{
"id": "bigGreen",
"id": "blue2",
"type": "BOX",
"pos": {
"x": -0.3,
"y": 2.01,
"x": 0.2,
"y": 0.3,
"z": 0.9355
},
"size": {
"length": 0.0318,
"width": 0.0636,
"height": 0.091
},
"orientation": {
"w": 1
},
"color": {
"b": 1
}
},
{
"id": "blue3",
"type": "BOX",
"pos": {
"x": 0.2,
"y": -0.1,
"z": 0.9355
},
"size": {
"length": 0.0318,
"width": 0.0636,
"height": 0.091
},
"orientation": {
"w": 1
},
"color": {
"b": 1
}
},
{
"id": "green1",
"type": "BOX",
"pos": {
"x": 0.2,
"y": -0.3,
"z": 0.9355
},
"size": {
"length": 0.0318,
"width": 0.0636,
"height": 0.091
},
"orientation": {
"w": 1
},
"color": {
"g": 1
}
},
{
"id": "green2",
"type": "BOX",
"pos": {
"x": 0.1,
"y": 1.91,
"z": 0.9355
},
"size": {
......@@ -1483,6 +1543,46 @@
"g": 1
}
},
{
"id": "red1",
"type": "BOX",
"pos": {
"x": -0.3,
"y": -0.6,
"z": 0.9355
},
"size": {
"length": 0.0318,
"width": 0.0636,
"height": 0.091
},
"orientation": {
"w": 1
},
"color": {
"r": 1
}
},
{
"id": "red2",
"type": "BOX",
"pos": {
"x": 0.3,
"y": 1.41,
"z": 0.9355
},
"size": {
"length": 0.0318,
"width": 0.0636,
"height": 0.091
},
"orientation": {
"w": 1
},
"color": {
"r": 1
}
},
{
"id": "arm1",
"type": "ARM",
......
......@@ -3,9 +3,10 @@
{
"name": "arm1",
"reachableLocations": [
"A1",
"A1", "A2", "A3", "A4",
"B1", "B2",
"C1",
"C1", "C2", "C3", "C4", "C5", "C6", "C7", "C8", "C9",
"D1", "D2", "D3", "D4", "D5", "D6", "D7", "D8", "D9",
"cz1"
]
},
......@@ -13,8 +14,10 @@
"name": "arm2",
"reachableLocations": [
"cz1",
"G1", "G2", "G3", "G4",
"I1", "I2", "I3" ,"I4"
"G1", "G2", "G3", "G4", "G5", "G6", "G7", "G8", "G9",
"H1", "H2", "H3", "H4", "H5", "H6", "H7", "H8", "H9",
"I1", "I2", "I3" ,"I4",
"J1", "J2"
]
}
]
......
{
"regions": [
{ "name": "A", "positions": ["A1"] },
{ "name": "A", "positions": ["A1", "A2", "A3", "A4"] },
{ "name": "B", "positions": ["B1", "B2"] },
{ "name": "C", "positions": ["C1"] },
{ "name": "D", "positions": ["D1"] },
{ "name": "E", "positions": ["E1"] },
{ "name": "F", "positions": ["F1"] },
{ "name": "G", "positions": ["G1", "G2", "G3", "G4"] },
{ "name": "H", "positions": ["H1"] },
{ "name": "C", "positions": ["C1", "C2", "C3", "C4", "C5", "C6", "C7", "C8", "C9"] },
{ "name": "D", "positions": ["D1", "D2", "D3", "D4", "D5", "D6", "D7", "D8", "D9"] },
{ "name": "G", "positions": ["G1", "G2", "G3", "G4", "G5", "G6", "G7", "G8", "G9"] },
{ "name": "H", "positions": ["H1", "H2", "H3", "H4", "H5", "H6", "H7", "H8", "H9"] },
{ "name": "I", "positions": ["I1", "I2", "I3", "I4"] },
{ "name": "J", "positions": ["J1", "J2"] },
{ "name": "CZ", "positions": ["cz1"] }
]
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment