simulation.utils.urdf.core module¶
Class definitions of core building blocks of the package.
Summary¶
Classes:
Basic class that will be converted into a xml attribute. |
|
Base class for all urdf xml objects. |
Reference¶
-
class
Attribute(val: str, name: Optional[str] = None)[source]¶ Bases:
strBasic class that will be converted into a xml attribute.
Important: Within a subclass of
XmlObjectan attribute can be defined by simply annotating a class variable with py:class:Attribute!Example
>>> from dataclasses import dataclass >>> from urdf.core import XmlObject, Attribute >>> @dataclass ... class Example(XmlObject): ... TAG = "example" ... name: Attribute ... value1: str ... value2: float = None >>> ex = Example("example_name",value1="I'm an example.")
The code block defines a simple example class that results in the xml string:
<example name="example_name"> <value1>I'm an example.</value1> </example>
- Parameters
val – Attribute value.
name – Optionally the name of the can be provided. By default the name of the Attribute instance defines the name of the resulting xml attribute.
-
class
XmlObject[source]¶ Bases:
objectBase class for all urdf xml objects.
-
TAG= None¶
-
create_xml(root_el: Optional[xml.etree.ElementTree.Element] = None) → xml.etree.ElementTree.Element[source]¶ Convert this instance into a xml element.
If the class of this instance does not define a tag, new xml elements from this instance are appended to the root_el. Otherwise, a sub element is created and returned.
Additionally to all instance attributes, a dictionary
parameterscan be used to define sub elements.A
Attributetype annotation for any of the object`s attributes, will result in a xml attribute.
- Parameters
root_el – Optional element that is used a parent xml element when provided.
-
-
class
Origin(xyz: simulation.utils.urdf.core.Attribute = <factory>, rpy: simulation.utils.urdf.core.Attribute = <factory>)[source]¶ Bases:
simulation.utils.urdf.core.XmlObject-
TAG= 'origin'¶
-
classmethod
from_vector(vector: simulation.utils.geometry.vector.Vector)[source]¶
-
-
class
Axis(xyz: simulation.utils.urdf.core.Attribute = <factory>)[source]¶ Bases:
simulation.utils.urdf.core.XmlObject-
TAG= 'axis'¶
-