Commit 9287757d authored by René Schöne's avatar René Schöne
Browse files

Update preprocessor and mustache.

parent 7496e1b5
Subproject commit 130a96efa74f90c9d2f8634e2ddc6d6c705f146d
Subproject commit c10bed0d03e3fa18b8133ce1de48de7646899615
package org.jastadd.ragconnect.compiler;
import org.jastadd.ragconnect.ast.*;
import org.jastadd.ragconnect.parser.RagConnectParser;
import org.jastadd.ragconnect.scanner.RagConnectScanner;
import java.io.Reader;
import java.nio.file.Files;
import java.nio.file.Paths;
import org.jastadd.ragconnect.ast.Document;
import org.jastadd.ragconnect.ast.ListElement;
import org.jastadd.ragconnect.ast.MappingElement;
/**
* Testing Ros2Rag without parser.
......@@ -19,70 +15,64 @@ public class SimpleMain {
Document doc = new Document();
MappingElement root = new MappingElement();
MappingElement firstLevel = new MappingElement();
firstLevel.addKeyValuePair(new KeyValuePair("server", new StringElement("tcp://localhost:1883")));
firstLevel.addKeyValuePair(new KeyValuePair("robot_speed_factor", new ValueElement(".7")));
firstLevel.put("server", "tcp://localhost:1883");
firstLevel.put("robot_speed_factor", ".7");
KeyValuePair topics = new KeyValuePair();
topics.setKey("topics");
MappingElement theTopics = new MappingElement();
theTopics.addKeyValuePair(new KeyValuePair("robotConfig", new StringElement("robotconfig")));
theTopics.addKeyValuePair(new KeyValuePair("trajectory", new StringElement("trajectory")));
theTopics.addKeyValuePair(new KeyValuePair("nextStep", new StringElement("ros2rag/nextStep")));
topics.setValue(theTopics);
firstLevel.addKeyValuePair(topics);
theTopics.put("robotConfig", "robotconfig");
theTopics.put("trajectory", "trajectory");
theTopics.put("nextStep", "ros2rag/nextStep");
firstLevel.put("topics", theTopics);
firstLevel.addKeyValuePair(new KeyValuePair("zone_size", new ValueElement("0.5")));
firstLevel.put("zone_size", "0.5");
ListElement theZones = new ListElement();
theZones.addElement(new StringElement("1 1"));
theZones.addElement(new StringElement("0 1"));
theZones.addElement(new StringElement("-1 1"));
firstLevel.addKeyValuePair("zones", theZones);
theZones.add("1 1");
theZones.add("0 1");
theZones.add("-1 1");
firstLevel.put("zones", theZones);
MappingElement pandaParts = new MappingElement();
MappingElement thePanda = new MappingElement();
thePanda.addKeyValuePair(new KeyValuePair("Link0", new StringElement("panda_link0")));
thePanda.addKeyValuePair(new KeyValuePair("Link1", new StringElement("panda_link1")));
thePanda.addKeyValuePair(new KeyValuePair("Link2", new StringElement("panda_link2")));
thePanda.addKeyValuePair(new KeyValuePair("Link3", new StringElement("panda_link3")));
thePanda.addKeyValuePair(new KeyValuePair("Link4", new StringElement("panda_link4")));
thePanda.addKeyValuePair(new KeyValuePair("Link5", new StringElement("panda_link5")));
thePanda.addKeyValuePair(new KeyValuePair("Link6", new StringElement("panda_link6")));
thePanda.addKeyValuePair(new KeyValuePair("RightFinger", new StringElement("panda_rightfinger")));
thePanda.addKeyValuePair(new KeyValuePair("LeftFinger", new StringElement("panda_leftfinger")));
pandaParts.addKeyValuePair("panda", thePanda);
firstLevel.addKeyValuePair("parts", pandaParts);
thePanda.put("Link0", "panda_link0");
thePanda.put("Link1", "panda_link1");
thePanda.put("Link2", "panda_link2");
thePanda.put("Link3", "panda_link3");
thePanda.put("Link4", "panda_link4");
thePanda.put("Link5", "panda_link5");
thePanda.put("Link6", "panda_link6");
thePanda.put("RightFinger", "panda_rightfinger");
thePanda.put("LeftFinger", "panda_leftfinger");
pandaParts.put("panda", thePanda);
firstLevel.put("parts", pandaParts);
MappingElement endEffectorParts = new MappingElement();
MappingElement endEffector = new MappingElement();
endEffector.addKeyValuePair("EndEffector", new StringElement("panda_hand"));
endEffectorParts.addKeyValuePair("panda", endEffector);
firstLevel.addKeyValuePair("end_effectors", endEffectorParts);
endEffector.put("EndEffector", "panda_hand");
endEffectorParts.put("panda", endEffector);
firstLevel.put("end_effectors", endEffectorParts);
KeyValuePair goalPoses = new KeyValuePair();
goalPoses.setKey("goal_poses");
ListElement theGoalPoses = new ListElement();
addPose(theGoalPoses, "0.4 0.4 0.3");
addPose(theGoalPoses, "-0.4 0.4 0.3");
addPose(theGoalPoses, "-0.4 -0.4 0.3");
addPose(theGoalPoses, "0.4 0.4 0.3");
addPose(theGoalPoses, "-0.4 0.4 0.3");
addPose(theGoalPoses, "0.4 0.4 0.3");
goalPoses.setValue(theGoalPoses);
firstLevel.addKeyValuePair(goalPoses);
theGoalPoses.add(makePose("0.4 0.4 0.3"));
theGoalPoses.add(makePose("-0.4 0.4 0.3"));
theGoalPoses.add(makePose("-0.4 -0.4 0.3"));
theGoalPoses.add(makePose("0.4 0.4 0.3"));
theGoalPoses.add(makePose("-0.4 0.4 0.3"));
theGoalPoses.add(makePose("0.4 0.4 0.3"));
firstLevel.put("goal_poses", theGoalPoses);
root.addKeyValuePair("panda_mqtt_connector", firstLevel);
root.put("panda_mqtt_connector", firstLevel);
doc.setRootElement(root);
System.out.println(doc.prettyPrint());
}
private static void addPose(ListElement theGoalPoses, String position) {
MappingElement goalPose1 = new MappingElement();
goalPose1.addKeyValuePair(new KeyValuePair("position", new StringElement(position)));
goalPose1.addKeyValuePair(new KeyValuePair("orientation", new StringElement("1 1 0 0")));
goalPose1.addKeyValuePair(new KeyValuePair("work", new StringElement("20000")));
theGoalPoses.addElement(goalPose1);
private static MappingElement makePose(String position) {
MappingElement goalPose = new MappingElement();
goalPose.put("position", position);
goalPose.put("orientation", "1 1 0 0");
goalPose.put("work", "20000");
return goalPose;
}
public static void main(String[] args) {
......
Subproject commit 79d237fda220364ffebf77dc7de0a7b29635e360
Subproject commit c00441c03dc6723a08de0fcb041254a99497774f
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment