Skip to content

Latest commit

 

History

History
142 lines (85 loc) · 7.4 KB

1_create_unity_project_with_unity_packages.md

File metadata and controls

142 lines (85 loc) · 7.4 KB

Drone Pose Estimation And Navigation Tutorial: Part 1

In this first part of the tutorial, we will start by downloading and installing the Unity Editor. We will install our project's dependencie(s): the Perception package. We will then use a set of provided prefabs to easily prepare a simulated environment containing a drone, a target, a wall and few distractor objects.

Table of Contents


To follow this tutorial you need to clone this repository even if you want to create your Unity project from scratch.

  1. Open a terminal and navigate to the folder where you want to host the repository.
git clone [email protected]:Unity-Technologies/drone-pose-estimation-navigation.git
  1. Install Unity 2020.3.*. or a later version of it.

When you first run Unity, you will be asked to open an existing project, or create a new one.

  1. Open Unity and create a new project using the Universal Render Pipeline. Name your new project Drone Pose Estimation Tutorial, and specify a desired location as shown below.

Once your new project is created and loaded, you will be presented with the Unity Editor interface. From this point on, whenever we refer to the "editor", we mean the Unity Editor.

How to install packages

We will need to download and install the Perception package. In general, packages can be installed in Unity with the following steps:

  • From the top menu bar, open Window -> Package Manager. As the name suggests, the Package Manager is where you can download new packages, update or remove existing ones, and access a variety of information and additional actions for each package.

  • Click on the + sign at the top-left corner of the Package Manager window and then choose the option Add package from git URL....

  • Enter the package address and click Add.

It can take a few minutes for the manager to download and import packages.

Install Dependencies

Install the following packages with the provided git URL:

  1. Perception package - [email protected]
    • This will help us collect training data for our machine learning model.

The Hierarchy, Scene, Game, Inspector, Project, and Console windows of the Unity Editor, as well as the Play/Pause/Step toolbar have been highlighted below for reference, based on the default layout. Custom Unity Editor layouts may vary slightly. A top menu bar option is available to re-open any of these windows: Window > General.

The Perception package relies on a "Ground Truth Renderer Feature" to output labeled images as training data. Follow the steps below to add this component to your rendering settings:

  1. The Project tab contains a search bar; use it to find the file named ForwardRenderer, and click on the file named ForwardRenderer.asset as shown below:

  1. Click on the found file to select it. Then, from the Inspector tab of the editor, click on the Add Renderer Feature button, and select Ground Truth Renderer Feature from the dropdown menu:

The Scene

Simply put in Unity, a Scene contains any object that exists in the world. This world can be a game, or in this case, a data-collection-oriented simulation. Every new project contains a Scene named SampleScene, which is automatically opened when the project is created. This Scene comes with several objects and settings that we do not need, so let's create a new one.

  1. In the Project tab, right-click on the Assets/Scenes folder and click Create -> Scene. Name this new Scene TutorialDronePoseEstimationNagivation and double-click on it to open it.

The Hierarchy tab of the editor displays all the Scenes currently loaded, and all the objects currently present in each loaded Scene, as shown below:

As seen above, the new Scene already contains a camera (Main Camera) and a light (Directional Light). We will now modify the camera's field of view and position to prepare it for the tutorial.

  1. Still in the Inspector tab of the Main Camera, modify the camera's Position and Rotation to match the values shown below. This orients the camera so that it will have a good view of the objects we are about to add to the scene.

  1. Click on Directional Light and in the Inspector tab, modify the light's Position and Rotation to match the screenshot below.

Adding Tutorial Files

Now it is time to add some more objects to our scene. Before doing so, we need to import some folders containing the required assets.

  1. Download TutorialAssets.zip, and unzip it. It should contain the following subfolders: Materials, Prefabs, Scripts.

  2. Drag and Drop the TutorialAssets folder from your operating system's file explorer onto the Assets folder in the Project tab of the editor.

Your Assets folder should like this:

Using Prefabs

Unity’s Prefab system allows you to create, configure, and store a GameObject complete with all its components, property values, and child GameObjects as a reusable Unity Asset. It is a convenient way to store complex objects.

A Prefab is just a file, and you can easily create an instance of the object in the scene from a Prefab by dragging it into the Hierarchy tab.

For your convenience, we have provided Prefabs for most of the components of the scene (the cube, goal, table, and floor).

  1. We are going to use multiple lights and we will group them into one object. Thus, for your convenience, please delete the Directional Light Game Object. To do that, Go in the Hierarchy tab, right click on the Directional Light and select delete.

  2. In the Project tab, go to Assets/TutorialAssets/Prefabs/Part1 and drag and drop the Target Prefab into the Hierarchy tab.

  3. Repeat the above action with the Wall and Lights Prefabs.

  4. In the Project tab, go to Assets/TutorialAssets/Prefabs/Part1/Drone and drag and drop the Drone Prefab into the Hierarchy tab.

Proceed to Part 2.