blueprints.placeholder module#

Placeholders can be attached to a blueprints.body.Body to mark prominent locations. They do not appear in the resulting xml model and cannot be reconstructed from xml. Is is used to mimic a node in the kinematic tree that can be used to specify default attachment locations. If a Thing is attached to a Placeholder it is instead attached to the Placeholders parent in a position and orienation as if it would have been attached to the Placeholder directly. This can either be used for conveniance if many Things are attached to the same spot on the parent Body or in constructing a template with predefined spots for attachment. The following example shows how to build the template of a table.

Example table construction#
>>> top = blue.geoms.Box(name='top', x_length=2, y_length=1, z_length=0.002)
>>> leg = blue.geoms.Box.from_points([0, 0, 0], [0, 0, 1], radius=0.03, name='leg')
>>> table = blue.Body(name='table', pos=[0, 0, 1], geoms=top)
>>> table.attach(blue.Placeholder(pos=[ 0.9, 0.4, 0], alpha=PI),
>>>              blue.Placeholder(pos=[ 0.9,-0.4, 0], alpha=PI),
>>>              blue.Placeholder(pos=[-0.9, 0.4, 0], alpha=PI),
>>>              blue.Placeholder(pos=[-0.9,-0.4, 0], alpha=PI))
>>> table.placeholders.attach(leg)
>>> table.geoms
View[5|table.geoms]
>>> table.attach(blue.Placeholder(name='plate', pos=[-0.7, 0, 0]),
>>>              blue.Placeholder(name='plate', pos=[ 0.7, 0, 0]))
>>> table.placeholders
['leg_(0)', 'leg_(1)', 'leg_(2)', 'leg_(3)', 'plate_(0)', 'plate_(1)']
XML structure#
<body pos="0.0 0.0 1.0" name="table">
        <geom size="1.0 0.5 0.001" type="box" name="top" />
        <geom size="0.015 0.015 0.5" type="box" euler="3.1415927 0.0 0.0" pos=" 0.9  0.4 -0.5" name="leg_(0)" />
        <geom size="0.015 0.015 0.5" type="box" euler="3.1415927 0.0 0.0" pos=" 0.9 -0.4 -0.5" name="leg_(1)" />
        <geom size="0.015 0.015 0.5" type="box" euler="3.1415927 0.0 0.0" pos="-0.9  0.4 -0.5" name="leg_(2)" />
        <geom size="0.015 0.015 0.5" type="box" euler="3.1415927 0.0 0.0" pos="-0.9 -0.4 -0.5" name="leg_(3)" />
</body>
class blueprints.placeholder.Placeholder[source]#

Bases: PlaceholderType, MoveableThing

This class is available through the shortcut blueprints.Placeholder.

Placeholders can be attached to a blueprints.body.Body to mark special places and orientations for attachment. It will not be included into the xml.

Parameters:
  • pos (list[int | float] | np.ndarray, optional) – Represents the position of the object. Changing this attribute also changes the properties x, y and z.

  • alpha (int | float | None, optional) – (Improper) euler angle of rotation around the x-axis in radian. Changing this value also changes the euler property.

  • beta (int | float | None, optional) – (Improper) euler angle of rotation around the y-axis in radian. Changing this value also changes the euler property.

  • gamma (int | float | None, optional) – (Improper) euler angle of rotation around the z-axis in radian. Changing this value also changes the euler property.

  • name (str | None, optional) – The user specified name of the Body. In the case of a naming conflict the name is appended by an enumeration scheme.

  • **kwargs – Keyword arguments are passed to super().__init__.

parent#

When a Thing is attached to the Placeholder, it instead gets attached to the parent and its position and orientation will be adjusted such that it is positioned and oriented as if it were attached of the Placeholder.

Type:

blue.NodeThingType | None

attach(*args)[source]#

Things that are attached to a Placeholder are instead attached to the Placeholders parent Body in a position and orientation as if they were attached to the Placeholder directly.

Parameters:

*args – the Things that sould be attached to the Placeholders parent

Raises:

Expection – If the Placeholder is not attached to a parent an error is raised.

detach(*args)[source]#

This method redirects to the Placeholders parent. This means, that Things that have not been attached to the parent directly (not via the Placeholder) can also be detached with this method.

Parameters:

*args – the Things that sould be detached from the Placeholders parent