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

automated comparison of sensor values

parent ef06786c
No related merge requests found
......@@ -11,27 +11,24 @@
</properties>
<struct>
<and abstract="true" mandatory="true" name="CarConfigurator">
<alt mandatory="true" name="ConfiguratorMain">
<and mandatory="true" name="ConfiguratorMain">
<alt abstract="true" name="TurtleBot">
<feature name="Burger"/>
<feature name="Waffle"/>
<feature name="WafflePi"/>
</alt>
<and abstract="true" name="CustomBot">
<alt abstract="true" name="Camera">
<feature name="Cam1"/>
<feature name="Cam2"/>
</alt>
<and abstract="true" name="NonOpticalSensor">
<graphics key="collapsed" value="false"/>
<alt abstract="true" mandatory="true" name="Radar">
<and abstract="true" name="CustomBot">
<and abstract="true" name="RangeFinder">
<graphics key="collapsed" value="false"/>
<feature name="Radar1"/>
<feature name="Radar2"/>
</alt>
<alt abstract="true" mandatory="true" name="TwoDRF">
<graphics key="collapsed" value="false"/>
<feature name="Sensor1"/>
<feature name="Sensor2"/>
<feature name="CustomTwoDRF"/>
</alt>
</and>
</and>
</and>
</alt>
</alt>
</and>
</and>
</struct>
</featureModel>
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<featureModel>
<properties>
<graphics key="showhiddenfeatures" value="true"/>
<graphics key="legendautolayout" value="true"/>
<graphics key="showshortnames" value="false"/>
<graphics key="layout" value="horizontal"/>
<graphics key="showcollapsedconstraints" value="true"/>
<graphics key="legendhidden" value="false"/>
<graphics key="layoutalgorithm" value="1"/>
</properties>
<struct>
<and abstract="true" mandatory="true" name="CarConfigurator">
<alt mandatory="true" name="ConfiguratorMain">
<alt abstract="true" name="TurtleBot">
<feature name="Burger"/>
<feature name="Waffle"/>
<feature name="WafflePi"/>
</alt>
<and abstract="true" name="CustomBot">
<alt abstract="true" name="Camera">
<feature name="Cam1"/>
<feature name="Cam2"/>
</alt>
<and abstract="true" name="NonOpticalSensor">
<graphics key="collapsed" value="false"/>
<alt abstract="true" mandatory="true" name="Radar">
<graphics key="collapsed" value="false"/>
<feature name="Radar1"/>
<feature name="Radar2"/>
</alt>
</and>
</and>
</alt>
</and>
</struct>
</featureModel>
......@@ -5,5 +5,8 @@
<min>0.3</min>
<max>5.2</max>
</range>
<noise>
<stddev>0.09</stddev>
</noise>
</sensor>
</configuration>
......@@ -115,8 +115,8 @@
</horizontal>
</scan>
<range>
<min>0.3</min>
<max>5.2</max>
<min>0.120</min>
<max>3.5</max>
<resolution>0.015</resolution>
</range>
<noise>
......
......@@ -89,6 +89,23 @@ public class Adapter {
return xQueryElements(doc, "//"+elementName);
}
/**
* Checks whether two elements have an equal xml tag.
* (Name of the xml tag and all attributes including their order must be equal)
*
* @param element1 Element1
* @param element2 Element2
* @return true if of equal tag or false if not
*/
public static boolean equalTag(Element element1, Element element2) {
List<Attribute> attributeList1 = element1.getAttributes();
List<Attribute> attributeList2 = element2.getAttributes();
if(!element1.getName().equals(element2.getName())) return false;
if(!attributeList1.equals(attributeList2)) return false;
return true;
}
/**
* @param args
*/
......@@ -135,19 +152,38 @@ public class Adapter {
//TODO##### Operate on .gazebo.xacro ############
List<Element> cSensorList = xQueryElements(sensorConfig, "//sensor");
List<Element> gSensorList = xQueryElements(gazeboModel, "//sensor");
//hard-coded and only for demo purposes
List<Element> cSensorList = xQueryElements(sensorConfig, "//sensor[@type='ray' and @name='lds_lfcd_sensor']");
Element cSensor = cSensorList.get(0);
if(cSensorList.isEmpty()) {
System.out.println("No new sensor values in sensorconfig.xml");
System.exit(-1);
}
if(gSensorList.isEmpty()) {
System.out.println("No sensors found in "+fileName);
System.exit(-1);
}
List<Element> gSensorList = xQueryElements(gazeboModel, "//sensor[@type='ray' and @name='lds_lfcd_sensor']");
Element gSensor = gSensorList.get(0);
String new_min = cSensor.getChild("range").getChild("min").getText();
String new_max = cSensor.getChild("range").getChild("max").getText();
for(Element cSensor : cSensorList) {
for(Element gSensor : gSensorList) {
if(equalTag(cSensor, gSensor)) {
//TODO automatischer Abgleich aller cSensor-Informationen mit gSensor und Wertersetzung
}
}
}
gSensor.getChild("ray").getChild("range").getChild("min").setText(new_min);
gSensor.getChild("ray").getChild("range").getChild("max").setText(new_max);
//hard-coded and only for demo purposes
// List<Element> cSensorList = xQueryElements(sensorConfig, "//sensor[@type='ray' and @name='lds_lfcd_sensor']");
// Element cSensor = cSensorList.get(0);
//
// List<Element> gSensorList = xQueryElements(gazeboModel, "//sensor[@type='ray' and @name='lds_lfcd_sensor']");
// Element gSensor = gSensorList.get(0);
//
// String new_min = cSensor.getChild("range").getChild("min").getText();
// String new_max = cSensor.getChild("range").getChild("max").getText();
//
// gSensor.getChild("ray").getChild("range").getChild("min").setText(new_min);
// gSensor.getChild("ray").getChild("range").getChild("max").setText(new_max);
//###############################################
......@@ -160,23 +196,23 @@ 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]/@*");
if(test != null) xmlOutput.output(test, System.out);
System.out.println("\n");
xmlOutput.output(test2, System.out);
System.out.println("\n");
xmlOutput.output(test3, System.out);
System.out.println("\n");
if(test4 != null) xmlOutput.output(test4, System.out);
System.out.println("\n");
for(Attribute a : test5) System.out.println(a.getName()+"="+a.getValue());
// 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]/@*");
//
// if(test != null) xmlOutput.output(test, System.out);
// System.out.println("\n");
// xmlOutput.output(test2, System.out);
// System.out.println("\n");
// xmlOutput.output(test3, System.out);
// System.out.println("\n");
// if(test4 != null) xmlOutput.output(test4, System.out);
// System.out.println("\n");
// for(Attribute a : test5) System.out.println(a.getName()+"="+a.getValue());
} catch (JDOMException | IOException e) {
e.printStackTrace();
......
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