Set up your environment
You've now set up your simulation with all of the pieces you need—vehicle models, controllers, sensors—all configured and connected to your application the way you want them. The next thing you want to do is configure the rest of your simulation—what else is in the area that your robot is mapping? What physical obstacles might get in the way of your agents, and how does that affect obstacle avoidance?
You can configure your simulation to answer these types of questions by varying the initial conditions of objects in your environment. For example, you may want to model different states of a busy loading dock or vary the location of your device's charging station. We have tools to help you set these initial simulation states in our Permutations package.
The Scene Initializers, like sensors, live in their own package and can be used independently from vehicle models, controllers, and sensors. The functionalities of this package are agnostic to the environment assets used, so you can use the sample warehouse assets that come with this package, import models from another source like the Unity Asset Store, or even just use Unity primitives to model your environment.
This package contains sample warehouse assets, pre-configured Initializers to set an initial state for your simulation, as well as APIs to customize and create your own!
Introduction
So, what is an Initializer?
You can use an Initializer to assign initial states to the objects in your simulation environment. Our Initializers allow you to:
- Select a set or subset of objects to modify in your environment
- Select or randomize assets from disk to spawn into your environment
- Configure a series of steps and rules to execute on your environment, and
- Write your own Initializers using our APIs!
Consider the scenario of testing a localization algorithm. You've mapped out a warehouse environment, but your estimates are failing when boxes get bumped, or a shelving rack is moved. For your simulation, you can initialize your pallets, boxes, and shelving racks to be placed in varying ways that best allow you to investigate the fail states for your algorithm.
What's in the box?
We currently provide the following Initializers out-of-the-box:
- Spawn: This places objects you've chosen in the area you've chosen using Poisson disk sampling. This might be useful if you want to investigate a pseudo-random scattering of objects on a conveyor belt.
- Maybe Spawn: This randomly chooses to spawn a few objects within an area you've chosen based on the parameters you've set. This can be used in modeling a loading dock where a variable number of pallets may be dropped off.
- Perturb: This takes the objects in the area you've chosen and slightly shifts and rotates them, simulating general displacement. You might use this to investigate what happens when pallets get shifted in the loading bay.
- Prune Colliding: This removes any objects within the area you've chosen that overlap other objects by more than your specified threshold. This can prevent the "exploding" effect you might get when the physics step tries to resolve overlapping colliders.
- Prune Random: This removes objects within the area you've chosen based on a configurable range, meaning you can remove a subset of objects, rather than all of the ones in an area. You might use this when simulating how different pallets being removed from shelves affects your algorithm.
You can learn more about each of these Initializers in the Configure a predefined Scene Initializer guide.
There are several ways to set up an Initializer in your simulation. We'll walk through the high-level steps of using the out-of-the-box Initializers here, but if you want to customize the steps or write your own Operations, check out their specific guides for more information.
Getting Started
Here are the high-level steps you'll need to walk through in order to get your Initializer set up:
- Add an Initializer: You will need to get the initializer into your scene. To add it, right click in your Hierarchy, and navigate to Permutations > Add New Scene Initializer. This will create a new GameObject in your scene with the Scene Initializer component already attached
- Select the action: Your Initializer will be doing an action on some objects—here is where you select what that action is. In the Inspector of your newly made Initializer, expand the Initializer dropdown and select your desired Initializer
- Select assets: Initializers operate on assets. Some operate on assets that are already in the scene; in this case, you have to first configure a Region of the scene that contains the assets, and then you have the option of further filtering assets in the region based on names. Other assets operate on assets not yet in the scene; in this case, you'll have to configure an Asset Group to use assets from disk
- Set the parameters: Set the necessary parameters for your Initializer (described in the Configure a predefined Scene Initializer
- Run it: On your Scene Initializer component, click Execute Plan to run your Initializer
- Modify it: Duplicate your scene and modify the configurations as necessary for your test suite
- Build it: Create your player build and execute your tests!
For specifics on any components and customizing these steps, check out the other guides.