NodeThing#

class blueprints.NodeThing[source]#

Bases: BaseThing, NodeThingType

If an inheriting Thing class can have children attached to it in the kinematic tree it derives from NodeThing. It contains the methods NodeThing.attach() and NodeThing.detach() can be used add or detach children.

If a Thing class inherits from NodeThing it needs to define a dictionary named _CHILDREN which 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'.

Attributes Summary

children

The names and lists of all types of children are specified in the _CHILDREN attribute as well as the type.

descendants

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.

Methods Summary

attach(*items[, globally, copy])

This method attaches *items to the parent Thing.

copy([shallow])

This method creates a copy of the Thing from which it was called.

detach(*items)

This method is used to detach Things from the kinematic tree.

Attributes Documentation

children#

The names and lists of all types of children are specified in the _CHILDREN attribute 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

descendants#

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

Methods Documentation

attach(*items, globally=False, copy=True)[source]#

This method attaches *items to 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

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 ǸodeThing itself optionally including copies or its children.

Return type:

blue.NodeThingType

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 parent attribute will be set to None.

Parameters:

*items (list[ThingType]) – Things that are no longer children of this Thing can be passed, as long as their type is a valid type for children of this NodeThing.

Raises:

TypeError – If the arguments to this function are not valid children types an error is raised.

Return type:

None

__init__(name=None, parent=None, **kwargs)#
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.

classmethod __new__(*args, **kwargs)#