blueprints.thing.node module#
- class blueprints.thing.node.NodeThing[source]#
Bases:
BaseThing,NodeThingTypeIf an inheriting Thing class can have children attached to it in the kinematic tree it derives from NodeThing. It contains the methods
NodeThing.attach()andNodeThing.detach()can be used add or detach children.If a Thing class inherits from
NodeThingit needs to define a dictionary named_CHILDRENwhich has the names of children attributes as keys and as values a second level dictionary containing the ThingType of the respective children under the keys'type'and a reference to the list in which the children are stored under the key'children'.- copy(shallow=False, **kwargs)[source]#
This method creates a copy of the Thing from which it was called. Additional modifications to the copy can be set as keyword arguments. If shallow is True only the Thing itself, otherwise its children are also copied and attached.
- Parameters:
shallow (
bool, optional) – Indicating whether the children should be copied and attached as well.**kwargs – Specifies additional attributes that are passed to the copied
NodeThing.__init__().
- Returns:
The returned value is a copy of the
ǸodeThingitself optionally including copies or its children.- Return type:
blue.NodeThingType
- attach(*items, globally=False, copy=True)[source]#
This method attaches
*itemsto the parent Thing. If copy is set true, a copy of the items is created. If copy is set to false, the kinematic graph might no longer be a tree resulting in infinite loops or naming conflicts if the same item is included in the tree twice. All items of a specific type can be accessed via the types attribute.- Parameters:
*items (
list[blue.ThingType]) – All items that are to be attached.globally (
bool) – A flag specifing whether the Things are attached in the local or global position and orientation.copy (
bool, optional) – A flag indicating whether a copy of the items should be attached. It is recommended for the user to not set this argument to false.
- Raises:
TypeError – If an item is not a valid child an error is raised.
- Return type:
None
- detach(*items)[source]#
This method is used to detach Things from the kinematic tree. They are afterwards no longer present in this Things children attributes and their
parentattribute will be set toNone.
- property children: dict#
The names and lists of all types of children are specified in the
_CHILDRENattribute as well as the type. This property is a reduced dictionary only containing names and lists.- Returns:
A dictionary containing all children of the NodeThing.
- Return type:
dict
- property descendants: dict#
Nested dictionaries — The top level contains the names of the respective descendants property names, on the second level there are the keys
'type'and'descendant'containing the ThingType and the descendant of the attribute.- Returns:
The structure of descendants differs from
children.- Return type:
dict
- property all: AllViewType#
This property gives access to a
Viewthrough which attributes of all descendants can be handled. SeeAllViewfor details.- Returns:
A handle for accessing attributes of all descendants of the NodeThing.
- Return type:
AllViewType