2.1 KiB
Exercises for the Reader
In the main tutorial, we randomized the position and rotation of the cube. However, the perception package supports much more sophisticated environment randomization. In this (optional) section we will create a richer and more varied environment by adding one more randomizer to our scene.
In addition to the YRotationRandomizer
and the RobotArmObjectPositionRandomizer
, we have designed one more randomizer:
UniformPoseRandomizer
- Randomizes object's position and rotation relative to a fixed starting pose, over the specified range. We will apply this to the camera, to make our trained model more robust to small inaccuracies in placing the real camera.
Randomizing the Camera Pose
- Action: Select the
Simulation Scenario
GameObject and in the Inspector tab, on theFixed Length Scenario
component, click onAdd Randomizer
and start typingUniformPoseRandomizer
. For theRandom
parameter, set the min value of the Range to-1
. We do that because we want the change of the position and the rotation in both directions for a given axis. The Randomizer's UI snippet should look like the following:
- Action: Now we need to add the RandomizerTag to the Camera but you can add it the GameObject you want. Select the
Main Camera
GameObject and in the Inspector tab, click on the Add Component button. Start typingUniformPoseRandomizerTag
in the search bar that appears, until theUniformPoseRandomizerTag
script is found, with a # icon to the left. Then double click on it.
If you press play, you should see the cube moving around the robot and rotate, the color and the intensity of the light changing but also the camera moving.
User Project: Create Your Own
You have now learned how to create a randomizer, and seen how multiple randomizers can be used together to create a rich, varied scene. Now it is time to create your own by yourself! How could this scene be further improved?
Good luck and have fun!