This example workspace main purpose is to get familiar with scripting for filling an empty warehouse with different items that keeps coherence based on attributes and names. The warehouse will be filled with shelves, containers, stacked boxes, stacked metal barrels and office elements.
The workspace is ready to generate variations of the previously defined containers and objects in/on them. To add more variability to the images, materials are also changed to increase the number of different items you can find in the scene.
In this first warehouse example, an already created warehouse will be provided in the workspace. It has a base, where all the locators for variability are placed; a middle section, to add another floor to the warehouse to increase its size; and a rooftop.
As you can see, the place is fully covered with locators, where containers will be created.
Locators are a very important concept in Anyverse. They are used to position other elements with respect to them, any entity place in a locator will have a (0, 0, 0) position and rotation (transform for short) with respect to it. That means that the “effective” transform of the placed element will be the same ase the locator’s. Changing the transform of the element with respect to the locator will change its “effective” transform and it’s calculated adding the locator’s one.
In fact the nesting of element transforms apply to all elements in the simulation. The “efective” transform of an element is the sum of all the predecessor’s transforms and its own relative to its immediate parent.
This “efective” transform is what gets annotated as the position and rotation of an element in the generated data
You will notice that in the workspace
Simulation there is an entity named
Ego. That is a special entity we use to rig the cameras and you can think of it as the origin of the world from a camera perspective. In our workspace we have defined a camera that uses the Sony sensor IMX265.
In this workspace there is another special camera that will not generate images. The hidden camera “Frustum” is here for performance population purposes. As the only locators that will be populated, the original camera could not have some locators in its frustum but the objects on them could appear in the image. The “Frustum” camera helps on this by making its frustum wider and collecting those useful locators.
You can change the 3 viewer point of view by selecting a camera in the top left pulldown or by pressing P to toggle between cameras.
The elements that will be used to populate the warehouse can be seen using the “Resource” view by filttering by tag.
On the left image are displayed the shelves that will be added as containers, and on the right image are displayed the objects that will be in the shelves.
On the left image are displayed the cages that will be added as containers, and on the right image are displayed the objects that will be on the cages.
Here there is a special asset, the cages_container_01. As cages can be directly on the floor, to keep code simple and coherent, this assets does not have any mesh, it just have a locator with the expected name to allow cages on it.
On the left image are displayed the stacked boxes that will be added as containers with the same case as the cages with the empty asset, and on the right image are displayed the objects that will be on other boxes.
Warehouse office assets:
In this workspace there are some specific locators to populate the scene.
Column locators are those that are close to the wall that are not aligned with the ones that are inside the warehouse. Office elements and some shelves are placed here.
Row locators are those that follow lines across the warehouse. All stackable elements are placed here.
There are lots of materials that have been added to add variability to all the resources that we have been seen. Some of those materials have been design to have a better performance and be more physically accurate to some specific asset. How to connect assets to their materials will be seen in the scripting section.
In this example, we will focus on the begin iteration script.
This python code is executed for each iteration, before the simulation begins. As there will not be any simulation in thes example as all the images are generated as single images, the key point here is that this script will be used to setup the scene each time a new image is generated. An “iteration_index” value is provided to allow the user to do some specific logic based on the current iteration.
For editing this script, select the “Generator” node in the workspace, go the scripting section in tthe properties panel and edit the “OnBeginIteration” script by clicking on the pencil next to it.
Variations between iterations can be added in two ways combined in Anyverse and are executed in this order.
The first one is the variations system, that can be setup using the UI for selecting the entity and the property that you want to have different values between iterations.
The second one is the on begin iteration script that will be explain in this article.
The OnBeginIteration script contains all the code necessary to make variations over the warehouse. This code can be in an extern file and import it from the script, but for simplicity of this tutorial, it is self-contained.
The code has the following sections: the Warehouse class and the configuration section.
The warehouse class has all the code used to find locators and populate it using random choices to add variability.
The behaviour of this code is defined by a configuration JSON. This configuration must keep this structure, but its values can be changed by the user to get the distribution of assets required by the user.
In this configuration, for each type of container, it can be selected the maximum different models that will appear in the scene, the maximum number of different types of objects inside the container and a probability to ave a container without an object to allow empty containers with some probability.
The different types of containers can be selected in the “distribution_probabilities” section.
The “total_containers” value set the maximum number of containers that will be added to the scene. The minimum number of elements will be given by the amount of the locators that will be in the frustum of the carmera.
This script is also ready to be used in the “Script Console” view. Copy the code and paste it a new tab. Execute it to get a random distribution of the objects in the workspace. This will allow you to see an example of which objects are placed and how. For each execution of the script, you will get a new distribution. The following image is an example of how a workspace could end after the execution of the script.
Some of the assets that are placed in the warehouse follows a material policy description that is useful to asign only valid materials to those objects. For doind this, assets and materials have some attributes and tags that, combined, allows the user to know which materials can be safetly replaced.
Let’s get this asset as example of material variations using attributes, the Shelving_05_set_2.
In the image below, materials that can be replaced are displayed under the Asset Materials container. By default, materials that have not been overriden are tthose that where used to generate the thumbnail that you can see in the resource inspector or when you select the Fixed entity in the Asset Reference property.
To know which materials may be set in the Material Override Configuration , select the asset entity referenced by the Fixed entity. You will see all the attributes related to that asset.
In this image, all attributes are displayed. Let’s focus on those who’s name is one of the material parts that can be override.
In this case, those attributes are “tape_01” and “plastic_01”. If you find attributes with the same name of a material part, it means that those materials are special and there are some other materials in the Materials resources that can be applied to that material part.
The value of those attributes are the compatibility value, which is the key to find other materials that can be applied here.
Go to the resource inspector and filter Materials by an attribute called “compatibility” with the attribute value seen before; for example, adhesivetape_pipes
The next images show the different results you get when applying each material:
You can find how to do all this by scripting in the function “RandomizeMaterials” in the class Warehouse provided with the workspace.
The material’s attribute “compatibility” does not restrict the material that can be assign to an asset’s material part, but makes a recomendation of those materials that have special UVs that matches the geometry where the material will apply.
There are many materials in the Material Resource database that are not made with textures. Those materials can be applied to any material part.
Some additionar variations have been added to increase variability to the generated datasets. The workspace defines variations for the Ego in position and rotation. Changing the position of the ego will result on diferent altitudes of the camera. By changing the rotation of the camera we will get images all around the warehouse, pointing a little up or down and some roll to generate images that are not perfectly aligned to the ground, as may happen in real world.
Generate a batch
To generate a batch from your workspace, you first have to create a dataset with the output channels you require. Go to the generator inspector space (1), then click the + icon to the right in the
Dataset node of the tree (2), give it a name and select the channels you need for your dataset (you won’t be able to change them after creation) (3) and the Create button (4).
Now you are ready to generate a batch, right click on the
Generate node in the workspace and select a dataset (the one you just created, for example). A pop-up will give you the details of the generation you are going to run, after giving a meaningful name to the result there will be another popo-up with the progress of the generation. when closing you can go to the dataset in the generation inspector space to see the execution progress in the cloud. When all the render finish you will see the results.
Here there are some examples of the generated images using this workspace:
This workspace provides an already generated warehouse with some types of objects in it. As the source code for generating everything from scratch is provided, you can change it to achive new distributions or layouts of the warehouse you want.
Add variability in time of day to change how the sun enters the warehouse.
The environment lights are on by default. Vary its intensity in “Simulation” node to change the light in the warehouse.