blueprints.assets module#
Note
It is recommended to not use assets directly. All property access is
handeled through a front facing ThingType. Assets are UniqueThings.
- class blueprints.assets.BaseAsset[source]#
Bases:
AssetType,UniqueThing- Assets are used to link external resources to the model. Currently only
MeshAssets, HFieldAssets,TextureAssets,MaterialAssetsare supported, butSkinAssetsand
BoneAssetswill be developed in a future version version.- property name: str#
The user specified name might potentially be altered to avoid a naming conflict by appending an enumeration scheme.
- Return type:
str
- Assets are used to link external resources to the model. Currently only
- class blueprints.assets.MaterialAsset[source]#
Bases:
MaterialAssetType,BaseAsset,ColoredThingSee
MaterialMost attribute descriptions are partially taken from Mujoco.
- __init__(texture=None, texrepeat=[1, 1], texuniform=False, emission=0.0, specular=0.5, shininess=0.5, reflectance=0.0, metallic=-1.0, roughness=-1.0, color=None, name=None)[source]#
- Parameters:
texture (TextureType | None)
texrepeat (list[int | float] | ndarray)
texuniform (bool)
emission (int | float)
specular (int | float)
shininess (int | float)
reflectance (int | float)
metallic (int | float)
roughness (int | float)
color (str | object | None)
name (str | None)
- property texrepeat: ndarray#
The number of repetitions of the Texture in two directions
- Return type:
np.ndarray
- property texuniform: bool#
For
BoxTextures, this attribute controls how cube mapping is applied. The default valueFalsemeans apply cube mapping directly, using the actual size of the object. The value “true” maps the texture to a unit object before scaling it to its actual size (geometric primitives are created by the renderer as unit objects and then scaled). In some cases this leads to more uniform texture appearance, but in general, which settings produces better results depends on the texture and the object. For 2d textures, this attribute interacts with texrepeat above. Let texrepeat be N. The default value “false” means that the 2d texture is repeated N times over the (z-facing side of the) object. The value “true” means that the 2DPlaneTextureis repeated N times over one spatial unit, regardless of object size.- Return type:
bool
- property emission: float#
If set positive, the Material emitts lights.
- Return type:
float
- property specular: float#
Specularity in OpenGL. This value should be in the range [0 1].
- Return type:
float
- property shininess: float#
Shininess in OpenGL.
- Return type:
float
- property reflectance: float#
This attribute should be in the range [0 1]. If the value is greater than 0, and the material is applied to a plane or a box geom, the renderer will simulate reflectance. The larger the value, the stronger the reflectance. For boxes, only the face in the direction of the local +Z axis is reflective. Simulating reflectance properly requires ray-tracing which cannot (yet) be done in real-time. We are using the stencil buffer and suitable projections instead. Only the first reflective geom in the model is rendered as such. This adds one extra rendering pass through all geoms, in addition to the extra rendering pass added by each shadow-casting light.
- Return type:
float
- property metallic: float#
This attribute corresponds to uniform metallicity coefficient applied to the entire material. This attribute has no effect in MuJoCo’s native renderer, but it can be useful when rendering scenes with a physically-based renderer. In this case, if a non-negative value is specified, this metallic value should be multiplied by the metallic texture sampled value to obtain the final metallicity of the material.
- Return type:
float
- property roughness: float#
This attribute corresponds to uniform roughness coefficient applied to the entire material. This attribute has no effect in MuJoCo’s native renderer, but it can be useful when rendering scenes with a physically-based renderer. In this case, if a non-negative value is specified, this roughness value should be multiplied by the roughness texture sampled value to obtain the final roughness of the material.
- Return type:
float
- class blueprints.assets.TextureAsset[source]#
Bases:
TextureAssetType,BaseAssetSee
TextureMost attribute descriptions are partially taken from Mujoco.
- __init__(content=None, file=None, grid_size=[1, 1], grid_layout=None, fileright=None, fileleft=None, fileup=None, filedown=None, filefront=None, fileback=None, builtin=None, color_1=[0.8, 0.8, 0.8], color_2=[0.5, 0.5, 0.5], mark=None, color_mark=[0.0, 0.0, 0.0], random=0.01, width=0, height=0, h_flip=False, v_flip=False, n_channel=3, name=None)[source]#
- Parameters:
content (str | None)
file (str | None)
grid_size (list[int])
grid_layout (str | None)
fileright (str | None)
fileleft (str | None)
fileup (str | None)
filedown (str | None)
filefront (str | None)
fileback (str | None)
builtin (str | None)
color_1 (object)
color_2 (object)
mark (str | None)
color_mark (object)
random (float)
width (int)
height (int)
h_flip (bool)
v_flip (bool)
n_channel (int)
name (str | None)
- property type: str#
Derived type attribute for Mujoco,
- Return type:
str
- property content_type: str | None#
Content type (MIME type) taking values
None,'image/png','image/ktx'and'image/vnd.mujoco.texture'.- Return type:
str | None
- property gridsize: list[int]#
Grid size attrigute
[n_rows, n_cols]defining the grid. For non-grid Textures this value is ignored.- Return type:
list[int]
- property gridlayout: str | None#
The layout of the grid. See example above.
- Return type:
str | None
- property rgb1: ndarray#
The first color of a procedural Texture.
- Return type:
blue.ColorType
- property rgb2: ndarray#
The second color of a procedural Texture.
- Return type:
blue.ColorType
- property markrgb: ndarray#
The mark color of a procedural Texture.
- Return type:
blue.ColorType
- property hflip: bool#
If true, images loaded from file are flipped in the horizontal direction. Does not affect procedural textures.
- Return type:
bool
- property vflip: bool#
If true, images loaded from file are flipped in the vertical direction. Does not affect procedural textures.
- Return type:
bool
- property nchannel: int#
The number of channels in the texture image file. This allows loading 4-channel textures (RGBA) or single-channel textures (e.g., for Physics-Based Rendering properties such as roughness or metallic).
- Return type:
int
- property content: str | None#
Content type (MIME type) taking values
None,'image/png','image/ktx'and'image/vnd.mujoco.texture'.- Return type:
str | None
- property file: str | None#
Name of the texture file.
- Return type:
str | None
- property grid_size: list[int]#
Grid size attrigute
[n_rows, n_cols]defining the grid. For non-grid Textures this value is ignored.- Return type:
list[int]
- property grid_layout: str | None#
The layout of the grid. See example above.
- Return type:
str | None
- property fileright: str | None#
The file name for the right side of a
Box.- Return type:
str | None
- property fileleft: str | None#
The file name for the left side of a
Box.- Return type:
str | None
- property fileup: str | None#
The file name for the upper side of a
Box.- Return type:
str | None
- property filedown: str | None#
The file name for the down side of a
Box.- Return type:
str | None
- property filefront: str | None#
The file name for the front side of a
Box.- Return type:
str | None
- property fileback: str | None#
The file name for the back side of a
Box.- Return type:
str | None
- property builtin: str | None#
If set, this attribute specifies a builtin procedural Texture. See examples above.
- Return type:
str | None
- property mark: str | None#
If set this attribute specifies additional markings on a procedural Texture. Possible values are
None,'edge','cross'and'random'. See examples above.- Return type:
str | None
- property random: float#
If the
markattribute is set to'random', this attribute specifies the probability of a pixel in the texture being themark_color.- Return type:
float
- property width: int#
The width of a procedural texture, i.e., the number of columns in the image. Larger values usually result in higher quality images, although in some cases (e.g. checker patterns) small values are sufficient. For textures loaded from files, this attribute is ignored.
- Return type:
int
- property height: int#
The height of the procedural texture, i.e., the number of rows in the image. For
BoxandSkyboxtextures, this attribute is ignored and the height is set to 6 times the width. For textures loaded from files, this attribute is ignored.- Return type:
int
- property n_channel: int#
The number of channels in the texture image file. This allows loading 4-channel textures (RGBA) or single-channel textures (e.g., for Physics-Based Rendering properties such as roughness or metallic).
- Return type:
int
- property h_flip: bool#
If true, images loaded from file are flipped in the horizontal direction. Does not affect procedural textures.
- Return type:
bool
- property v_flip: bool#
If true, images loaded from file are flipped in the vertical direction. Does not affect procedural textures.
- Return type:
bool
- class blueprints.assets.MeshAsset[source]#
Bases:
MeshAssetType,BaseAsset,MoveableThingMeshAssets handle access to the data attributes used to define the
Mesh. All vertex, face, normals and texture coordinate data are stored in the MeshAssetsMeshCachein thecacheattribute.In general, all Mesh data that are structured for xml representation and insufficient for user manipulation are named as singular
vertex,face,texcoordandnormalwhile their plural formvertecies,faces,cache.texcoordsandcache.normalsare used for user interpretable representations and manipulation.Note
The position of MeshAssets is defined in mujoco via the
refposattribute, which differs to the standardposattribute in that it defines the reference frames relative position w.r.t. to its position instead of the vice versa the relative position w.r.t. the reference frames origin, effectively makingrefpos = - pos. We find this to be unnecessarily confusing and opted to implement the standard position attribute only translating when the kinematic tree gets converted to Mujoco xml. It is highly recommended to use theposargument to modify the MeshAssets position.- built#
A flag indicating whether the MeshAssets has been built. This is necessary since multiple
Meshesmight use the sameMeshAssetin which case it should be built only once.- Type:
bool
- filename#
The filename from which the Mesh data is loaded or to which it will be saved.
- Type:
str
- xml_data#
A flag indicating whether the Mesh data is written into the xml directly or into and external file which is then linked to in the xml asset element.
- Type:
bool
- __init__(pos=[0.0, 0.0, 0.0], vertecies=None, faces=None, scale=[1.0, 1.0, 1.0], filename=None, centered=False, xml_data=False, cache=None, name=None, **kwargs)[source]#
- Parameters:
pos (
np.ndarray | list[int | float], optional) – pos : np.ndarray | list[int | float], optional Represents the position of the Asset. Changing this attribute also changes the propertiesx,yandz.vertecies (
np.ndarray | list[np.ndarray | list[float | int]] | None, optional) – A list of all vertex positions. The vertecies are stored incache.faces (
list[np.ndarray | list[float | int]] | None, optional) – A list of all faces. A face consists of at least 3 indecies of vertecies. The faces are stored incache.scale (
np.ndarray | list[int | float], optional) – The scale is a 1D array like object of length 3. Each component is used to scale the X, Y and Z-axis respectively. Changing the scale is computationally cheap since it does not change the vertecies or other data incache.filename (
str | None, optional) – The filename from which the mesh data is loaded and to to which the mesh will be saved. The file is saved in a special directory such that no input file is overwritten by the output file.centered (
bool, optional) – IfTruethe vertecies are normalized such that their mean position is the reference frames origin.xml_data (
bool, optional) – IfTruethe Mesh data is not written to an external file and linked to in the xml, but written into the xml directly. It is recommended to only use this option if the Mesh data is small enough to not blot the xml.cache (
blue.ThingType | None, optional) – TheCachewhich stores the Mesh data.name (
str | None, optional) – The user specified name might potentially be altered to avoid a naming conflict by appending an enumeration scheme.**kwargs – Keyword arguments are passed to
super().__init__.
- Return type:
None
- load(filename)[source]#
This methods loads the mesh data from the filename to the assets cache.
- Parameters:
filename (
str) – The filename must be binary or ascii for OBJ files or binary for STL files.- Return type:
None
- save(filename)[source]#
This method saves the mesh data from the cache to the filename.
- Parameters:
filename (
str) – The filename must either end with the'.objor'.stl'file extension. Both file formats are saved as binary files.- Return type:
None
- property file: str | None#
Derived dummy variable for Mujoco XML
- Return type:
str
- property filename: str | None#
The filename of the Mesh
- Return type:
str
- property refpos: ndarray#
The negative
pos. This attribute is implemented for mujoco, but synchronized withposwhich is recommended to to be used instead.- Return type:
np.ndarray
- property vertex: ndarray#
This attribute is used to write construct the mujoco xml. It returns a flattened list of coordinates that is written raw to xml. For a structured list of vertecies see
vertecies.- Return type:
np.ndarray
- property face: ndarray | None#
This attribute is used to write to xml. It returns a flattened list of indecies that is written raw to xml. For a structured list of faces see
faces.- Return type:
np.ndarray | None
- property texcoord: ndarray | None#
This attribute is used to write to xml. It returns a flattened list of texture coordinates that is written raw to xml. For a structured list of texture coordinates see
texcoords.- Return type:
np.ndarray | None
- property normal: ndarray | None#
This attribute is used to write to xml. It returns a flattened list of face normals that is written raw to xml. For a structured list of face normals see
normals.- Return type:
np.ndarray | None
- property size: ndarray#
The size attribute specifies the ranges for each axis that the Mesh occupies.
- Return type:
np.ndarray
- property scale: ndarray#
The scale is a 1D array like object of length 3. Each component is used to scale the X, Y and Z-axis respectively. Changing the scale is computationally cheap since it does not change the vertecies or other data in
cache.- Return type:
np.ndarray
- property vertecies: list[ndarray]#
The list of vertecies. Each vertex is a np.ndarray with 3 components for each of the spatial dimensions.
- Return type:
list[np.ndarray]
- property faces: list[ndarray] | None#
The list of faces. Each face is a np.ndarray with n indecies for each of the vertecies of the face.
- Return type:
list[np.ndarray] | None
- class blueprints.assets.HFieldAsset[source]#
Bases:
HFieldAssetType,BaseAsset,MoveableThingSee
HFieldMost attribute descriptions are partially taken from Mujoco.
- __init__(filename=None, pos=[0.0, 0.0, 0.0], terrain=None, x_length=1, y_length=1, z_length=1, height_offset=1, xml_data=False, cache=None, name=None, **kwargs)[source]#
- Parameters:
filename (str | None)
pos (ndarray | list[int | float])
terrain (ndarray | list[int | float] | None)
x_length (int | float | None)
y_length (int | float | None)
z_length (int | float | None)
height_offset (int | float | None)
xml_data (bool)
cache (ThingType | None)
name (str | None)
- Return type:
None
- property size: ndarray#
Derived size attribute for Mujoco XML.
- Return type:
np.ndarray
- property name: str#
The user specified name might potentially be altered to avoid a naming conflict by appending an enumeration scheme.
- Return type:
str
- property x_length#
Length along the
X-axis of the HField.- Return type:
float
- property y_length#
Length along the
Y-axis of the HField.- Return type:
float
- property z_length#
Length along the
Z-axis of the HField.- Return type:
float
- property height_offset#
Height offset along the
Z-axis of the HField.- Return type:
float
- property terrain: list[ndarray]#
The terrain data of the HField
- Return type:
list[np.ndarray]