예제 #1
0
    def __init__(self, xml):
        LoadingHelpers.checkAttribExist(xml, "type", "ns", "z")
        LoadingHelpers.checkChildExist(xml, "scale", "orientation")

        self.Type = xml.get("type")
        LoadingHelpers.checkValueValid(self.Type, "cube", "cylinder", "sphere",
                                       "arrow", "mesh")
        self.Namespace = xml.get("ns")
        self.Z = float(xml.get("z"))

        LoadingHelpers.checkAttribExist(xml.find("scale"), "x", "y", "z")
        self.Scale = [
            float(xml.find("scale").get("x")),
            float(xml.find("scale").get("y")),
            float(xml.find("scale").get("z"))
        ]
        self.Orientation = [
            float(xml.find("orientation").get("x")),
            float(xml.find("orientation").get("z")),
            float(xml.find("orientation").get("z"))
        ]

        # Type-specific attributes
        self.MeshPath = xml.find("mesh_path").text if xml.find(
            "mesh_path") is not None else ""
예제 #2
0
    def __init__(self, xml):
        LoadingHelpers.checkAttribExist(xml, "type")
        LoadingHelpers.checkChildExist(xml, "position", "marker", "color")
        self.Name = "terrain"
        self.Position = Position2D(xml.find("position"))
        self.Shape = Shape2D(xml)
        self.Marker = Marker(xml.find("marker"))
        self.Color = Color(xml.find("color"))

        self.Layers = [Layer(l) for l in xml.findall("layer")]

        # Copy walls from other layers (includes)
        for layer in self.Layers:
            for include in layer.Includes:
                for l in self.Layers:
                    if l.Name == include:
                        for w in l.Walls:
                            layer.Walls.append(copy.deepcopy(w))
예제 #3
0
    def __init__(self, xml, obj_classes):
        LoadingHelpers.checkChildExist(xml, "shape", "containers", "color")
        self.Shape = Shape2D(xml.find("shape"))
        xml.find("containers").attrib["name"] = "robot"
        self.Container = Container(xml.find("containers"), obj_classes)
        self.Color = Color(xml.find("color"))

        #TODO temporary, considering robot as rect. real xml marker (e.g. for meshes) ?
        m = ET.Element("marker")
        m.attrib["ns"] = "robot"
        m.attrib["type"] = "cube"
        m.attrib["z"] = 0.35 / 2
        scale = ET.SubElement(m, "scale")
        scale.attrib["x"] = self.Shape.Height
        scale.attrib["y"] = self.Shape.Width
        scale.attrib["z"] = 0.35
        orientation = ET.SubElement(m, "orientation")
        orientation.attrib["x"] = 0.0
        orientation.attrib["y"] = 0.0
        orientation.attrib["z"] = 0.0
        self.Marker = Marker(m)
예제 #4
0
 def __init__(self, xml):
     LoadingHelpers.checkAttribExist(xml, "name")
     LoadingHelpers.checkChildExist(xml, "position", "shape")
     self.Name = xml.get("name")
     self.Position = Position2D(xml.find("position"))
     self.Shape = Shape2D(xml.find("shape"))