blueprints.body module#
- class blueprints.body.Body[source]#
Bases:
BodyType,MoveableThing,NodeThingThis class is available through the shortcut
blueprints.Body.Attributes from base classes
MoveableThingandNodeThingare inherited.A
Bodyis the primary Thing used to build the structure of a kinematic tree. This is done by attaching them to other bodies as well as other bodies to them. Bodies do have a position and an orientation but no further physical properties like a shape, a size or mass. Positions and orientations are local meaning that a body is placed relative to its parents frame of reference.To flesh out aBodythe following Things can be attached to it:Geom: This Thing is used to fill in the Body with matter. Geoms have a shape, mass, friction etc.Site: Sites similar to Geoms have shape, but do not effect the simulation physics. InsteadSensorinstances as well asActuatorcan be attached to it.Camera: If attached to the Body, the Camera can be view troughWorld.viewby setting therenderingcamera value to the Cameras name. If the Body is included in anAgent(not existing right now) the camera will be available in the Agents observations.Placeholder: A placeholder can be used to specify a position and orientation relative to the Body to which it is attached, that is of special interest. If a Thing is attached to a placeholder it is instead attached to its parent in a position and orientation, that matches attachment to the placeholder.Actuator: Actuators are used to apply force to the kinematic tree at the node they are attached to. If the Body is included in anAgent(not yet implemented) the actuators input will appear in the Agents action space.Light: Light sources illuminate the space around them, but are not necessary for the model to be visible, since a base luminescence is presence always present.Joint: This Thing is used to move theBody:. If a force is applied to the Body it moves along the degrees of freedom defined by the Joint.
Note
Unintuitively Bodies are not connected with each other via a Joint. Instead a Joint attached to a body defines the way in which a Body can be moved w.r.t. to the Bodies parent.
A kinematic tree can either be constructed bottom up or top down. The following two examples are used to create a kinematic tree of this structure:
XML Structure#<body name="tree"> <body pos="0.0 0.0 8.0" name="stem"> <body euler="0.0 -0.7853982 0.0" pos="0.0 0.0 4.0" name="branch_(0)"> <body euler="0.0 -0.7853982 0.0" pos="0.0 0.0 2.0" name="twig_(0)"> <body euler="0.0 -0.7853982 0.0" pos="0.0 0.0 1.0" name="leaf_(0)" /> <body euler="0.0 0.7853982 0.0" pos="0.0 0.0 1.0" name="leaf_(1)" /> </body> <body euler="0.0 0.7853982 0.0" pos="0.0 0.0 2.0" name="twig_(1)"> <body euler="0.0 -0.7853982 0.0" pos="0.0 0.0 1.0" name="leaf_(2)" /> <body euler="0.0 0.7853982 0.0" pos="0.0 0.0 1.0" name="leaf_(3)" /> </body> </body> <body euler="0.0 0.7853982 0.0" pos="0.0 0.0 4.0" name="branch_(1)"> <body euler="0.0 -0.7853982 0.0" pos="0.0 0.0 2.0" name="twig_(2)"> <body euler="0.0 -0.7853982 0.0" pos="0.0 0.0 1.0" name="leaf_(4)" /> <body euler="0.0 0.7853982 0.0" pos="0.0 0.0 1.0" name="leaf_(5)" /> </body> <body euler="0.0 0.7853982 0.0" pos="0.0 0.0 2.0" name="twig_(3)"> <body euler="0.0 -0.7853982 0.0" pos="0.0 0.0 1.0" name="leaf_(6)" /> <body euler="0.0 0.7853982 0.0" pos="0.0 0.0 1.0" name="leaf_(7)" /> </body> </body> </body> </body>
Bottom-Up#>>> tree = blue.Body(name='tree') >>> stem = blue.Body(name='stem', pos=[0, 0, 8]) >>> bran = blue.Body(name='branch', pos=[0, 0, 4]) >>> twig = blue.Body(name='twig', pos=[0, 0, 2]) >>> leaf = blue.Body(name='leaf', pos=[0, 0, 1]) >>> angle = TAU/8 >>> # starting at the leafs >>> twig.attach(leaf.rotate(beta=-angle), leaf.rotate(beta=angle)) >>> bran.attach(twig.rotate(beta=-angle), twig.rotate(beta=angle)) >>> stem.attach(bran.rotate(beta=-angle), bran.rotate(beta=angle)) >>> tree.attach(stem)
Top-Down#>>> tree = blue.Body(name='tree') >>> stem = blue.Body(name='stem', pos=[0, 0, 0]) >>> bran = blue.Body(name='branch', pos=[0, 0, 4]) >>> twig = blue.Body(name='twig', pos=[0, 0, 2]) >>> leaf = blue.Body(name='leaf', pos=[0, 0, 1]) >>> angle = TAU/8 >>> # starting at the stem >>> tree.attach(stem) >>> tree.bodies.attach(bran.rotate(beta=-angle), bran.rotate(beta=angle)) >>> tree.bodies.bodies.attach(twig.rotate(beta=-angle), twig.rotate(beta=angle)) >>> tree.bodies.bodies.bodies.attach(leaf.rotate(beta=-angle), leaf.rotate(beta=angle)) Attributes ---------- bodies, cameras, geoms, sites, joints, lights, cameras, actuators, placeholders : :class:`View <blueprints.utils.view.View>` All children that have been attached to the Body are retrieved by the attribute as a :class:`View <blueprints.utils.view.View>`.
- __init__(pos=[0.0, 0.0, 0.0], alpha=0.0, beta=0.0, gamma=0.0, geoms=None, sites=None, joints=None, bodies=None, lights=None, cameras=None, actuators=None, placeholders=None, name=None, copy=True, x=None, y=None, z=None, quat=None, **kwargs)[source]#
- Parameters:
pos (
list[int | float] | np.ndarray, optional) – Represents the position of the object. Changing this attribute also changes the propertiesx,yandz.alpha (
int | float | None, optional) – (Improper) euler angle of rotation around the x-axis in radian. Changing this value also changes theeulerproperty.beta (
int | float | None, optional) – (Improper) euler angle of rotation around the y-axis in radian. Changing this value also changes theeulerproperty.gamma (
int | float | None, optional) – (Improper) euler angle of rotation around the z-axis in radian. Changing this value also changes theeulerproperty.geoms (
list[blue.ThingType] | blue.ThingType | None, optional) – Thegeomsargument mus either be a list of Geoms or a single Geom.sites (
list[blue.ThingType] | blue.ThingType | None, optional) – Thesitesargument mus either be a list of Sites or a single Site.joints (
list[blue.ThingType] | blue.ThingType | None, optional) – Thejointsargument mus either be a list of Joints or a single Joint.bodies (
list[blue.ThingType] | blue.ThingType | None, optional) – Thebodiesargument mus either be a list of Bodies or a single Body.lights (
list[blue.ThingType] | blue.ThingType | None, optional) – Thelightsargument mus either be a list of Lights or a single Light.cameras (
list[blue.ThingType] | blue.ThingType | None, optional) – Thecamerasargument mus either be a list of Cameras or a single Camera.actuators (
list[blue.ThingType] | blue.ThingType | None, optional) – Theactuatorsargument mus either be a list of Actuators or a single Actuator.placeholders (
list[blue.ThingType] | blue.ThingType | None, optional) – Theplaceholdersargument mus either be a list of Placeholders or a single Placeholder.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.copy (
bool, optional) – This argument indicates whether the children should be copied before they are attached. If copy if set to False this will result in graph cycles if a parent of the Body is attached resulting in further errors.x (
int | float |np.int32 | np.int64 | np.float32 | np.float64 | None, optional) – If pos is not specified, this argument sets the X position coordinate.y (
int | float |np.int32 | np.int64 | np.float32 | np.float64 | None, optional) – If pos is not specified, this argument sets the Y position coordinate.z (
int | float |np.int32 | np.int64 | np.float32 | np.float64 | None, optional) – If pos is not specified, this argument sets the Z position coordinate.quat (
list [ int | float ] | np.ndarray | None, optional) – If set, the quaternion orientation overwrites the euler anglesalpha,betaandgamma.**kwargs – Keyword arguments are passed to
super().__init__.
- Return type:
None