blueprints.thing.base module#
Note
If you found yourself here not being a dev, you should probably skip this section or
look up the correspinging docs page of the Thing you were looking after for which this module only
implements its corresponding mirror types. A link to the docs page is to be found in the Types doc
string.
- class blueprints.thing.base.BaseThing[source]#
Bases:
ThingTypeBaseThing implements the basic attributes that are used by all Things.
All Things have certain attributes that are included in the mujoco XML construction. The names of those attributes can be obtained from the
_MUJOCO_ATTRproperty which is dictionary with attribute names as keys and the types their value will have in the Thing instance. If a new Thing class is defined that inherits from BaseThing that introduces new attributes to be written to xml, they can be added by defining a class property_NEW_MUJOCO_ATTRin the same structure that_MUJOCO_ATTRis defined._MUJOCO_ATTRthen simply aggregates the new additions from_NEW_MUJOCO_ATTR. If a new Thing class inherits a mujoco attribute, that is no longer used, it can be deleted from_MUJOCO_ATTRby defining it in a class property_DEL_MUJOCO_ATTR, must be a set of the names to be detached.When a Thing is copied, all attributes needed to reconstruct it are retrieved to create a new instance. For this the
blueprints.type.ThingType._BLUEPRINT_ATTRproperty is used. New attributes that are feed into the inheritingThing.__init__are registered in the class property_NEW_BLUEPRINTS_ATTRand old attributes that are no longer used are registered in_DEL_BLUEPRINTS_ATTR. Their structures are analogous to the_MUJOCO_ATTR.If a Thing gets copied all attributes necessary to instantiate the copy are themselves copied to ensure that the Thing and its copy do not share a reference to the same object in any attribute. However, if an attribute is added to
blueprints.type.ThingType._NO_COPY_VALSit is not copied. New attributes to be excluded from being copied can be added by setting the class property_NEW_NO_COPY_VALSto the classes Type as a set of attribute names.If a Thing is reconstructed from an xml string, some attribute in the xml tag are not attributes of the Thing class. For example, a geom xml tag will have a type defining its shape
<geom type='sphere'>but the correspondingblueprints.geoms.Sphereclass specifies the type only implicitly in its name. To retrieve the correct class in reconstruction from xml then, those implicit attributes are gathered in the class propertyblueprints.type.ThingType._DERIVED_ATTRto explicitly derived later. Adding new attributes to it is done by setting the class property_NEW_DERIVED_ATTRof the Things Type as a set of attribute names.To ensure readability of the resulting xml, attributes that are set to their mujoco defaults are omitted from the xml representations (even though all attributes are set in the Thing instance). To check whether an attributes value equals its default, it can be obtained from the
_DEFAULT_VALSclass property, which is structured as a dictionary of attribute names as keys and their defaults as values. New default values of inheriting classes are added analogously to the previous cases by setting them in a class property_NEW_DEFAULT_VALSof its Type.- Parameters:
name (
str | None, optional) – This is the name for the object specified by the user. It differs from other user specified properties, in that it might be altered without the users knowledge to resolve name conflicts.parent (
blue.NodeThingType | None, optional) – The parent to which the Thing is attach, if it unattached parent is None.**kwargs – The aggregation of keyword arguments that have not yet been caught by other inheriting Things __init__ are not used and serve as a dummy variable.
- ID#
Each Thing has a unique ID that is gets on initialization from the global REGISTER.
- Type:
int
- __init__(name=None, parent=None, **kwargs)[source]#
- Parameters:
name (
str | None, optional) – This is the name for the object specified by the user. It differs from other user specified properties, in that it might be altered without the users knowledge to resolve name conflicts.parent (
blue.NodeThingType | None, optional) – The parent to which the Thing is attach, if it unattached parent is None.**kwargs – The aggregation of keyword arguments that have not yet been caught by other inheriting Things __init__ are not used and serve as a dummy variable.
- copy(**kwargs)[source]#
This method constructs a copy of the Thing with possible alterations to its attributes as specified in kwargs.
- Parameters:
**kwargs – Keyword arguments are passed to the Thing.__init__ to replace the attributes of the current Thing from which copy is called.
- Returns:
A new instance of the Thing
- Return type:
blue.ThingType
- property root: ThingType#
The root attribute is immutable and changes only if the structure of the kinematic tree is altered.
- Returns:
Retrieves the root of the kinematic tree the Thing in part of, possibly the Thing itself if it has no parent.
- Return type:
blue.ThingType
- property path: list#
The path attribute is immutable and changes only if the structure of the kinematic tree is altered.
- Returns:
Retrieves a list of all Things that lead from the Thing itself to its root.
- Return type:
list
- property parent: ThingType | None#
If the Thing is attach to a
blueprints.Worldit is informed that its child was altered such that on the next method call on the World, that require the current build, that it needs to rebuild.- Parameters:
attr (
str) – The name of the attribute to be set.value (
object) – The value assigned to the attribute.
- property name: str#
The returned name might differ from the user specification by an enumerations scheme that is applied if two Things of the same type in a kinematic tree share the same name.
- Returns:
possibly extended name of the Thing
- Return type:
str