Skip to content
Snippets Groups Projects
Commit 38b3bea2 authored by marvin's avatar marvin
Browse files

Case-based input selection

parent 2105943c
Branches
No related merge requests found
......@@ -94,20 +94,50 @@ public class Adapter {
*/
public static void main(String[] args) {
try {
Document FeatureModel = readXml("resources/input/featuremodel.xml");
Document GazeboModel = readXml("resources/input/turtlebot3-master/turtlebot3_description/urdf/turtlebot3_burger.gazebo.xacro");
Document featureModel = readXml("resources/input/featuremodel.xml");
Document sensorConfig = readXml("resources/input/sensorconfig.xml");
Document gazeboModel = null;
//TODO
//######### Operate on featuremodel.xml #########
Element fmRoot = FeatureModel.getRootElement();
List<Element> modules = fmRoot.getChildren("module");
//CustomBot not supported for now
List<Attribute> botList = xQueryAttributes(featureModel, "//module[@types='TurtleBot']/@name");
String botName = "";
switch(botList.size()) {
case 0:
System.out.println("Invalid input: No bot selected\n");
System.exit(-1);
break;
case 1:
botName = botList.get(0).getValue();
break;
default:
System.out.println("Invalid input: multiple bots selected\n");
System.exit(-1);
}
switch(botName) {
case "Burger":
gazeboModel = readXml("resources/input/turtlebot3-master/turtlebot3_description/urdf/turtlebot3_burger.gazebo.xacro");
break;
case "Waffle":
gazeboModel = readXml("resources/input/turtlebot3-master/turtlebot3_description/urdf/turtlebot3_waffle.gazebo.xacro");
break;
case "WafflePi":
gazeboModel = readXml("resources/input/turtlebot3-master/turtlebot3_description/urdf/turtlebot3_waffle_pi.gazebo.xacro");
break;
default:
System.out.println("Cannot handle \'"+botName+"\': No input file known.\n");
System.exit(-1);
}
//###############################################
//TODO
//######### Operate on .gazebo.xacro ############
Element gmRoot = GazeboModel.getRootElement();
Element gmRoot = gazeboModel.getRootElement();
//###############################################
......@@ -117,7 +147,7 @@ public class Adapter {
//TODO
//######### Output result #######################
xmlOutput.output(GazeboModel, dest);
xmlOutput.output(gazeboModel, dest);
//###############################################
......@@ -125,11 +155,11 @@ public class Adapter {
//XPathExamples
XPathFactory xFactory = XPathFactory.instance();
XPathExpression<Element> xExpr = xFactory.compile("robot/gazebo/sensor/ray/range/min", Filters.element());
Element test = xExpr.evaluateFirst(GazeboModel);
List<Element> test2 = searchAllElements(GazeboModel, "min");
List<Element> test3 = searchAllElements(GazeboModel, "max");
Element test4 = searchFirstElement(GazeboModel, "plugin");
List<Attribute> test5 = xQueryAttributes(GazeboModel, "(//plugin)[1]/@*");
Element test = xExpr.evaluateFirst(gazeboModel);
List<Element> test2 = searchAllElements(gazeboModel, "min");
List<Element> test3 = searchAllElements(gazeboModel, "max");
Element test4 = searchFirstElement(gazeboModel, "plugin");
List<Attribute> test5 = xQueryAttributes(gazeboModel, "(//plugin)[1]/@*");
if(test != null) xmlOutput.output(test, System.out);
System.out.println("\n");
......
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