diff --git a/Docs/img/tuto_D_colliders_CustomCollision.jpg b/Docs/img/tuto_D_colliders_CustomCollision.jpg new file mode 100644 index 000000000..c5e759074 Binary files /dev/null and b/Docs/img/tuto_D_colliders_CustomCollision.jpg differ diff --git a/Docs/img/tuto_D_colliders_collider.jpg b/Docs/img/tuto_D_colliders_collider.jpg new file mode 100644 index 000000000..57866d50b Binary files /dev/null and b/Docs/img/tuto_D_colliders_collider.jpg differ diff --git a/Docs/img/tuto_D_colliders_mesh.jpg b/Docs/img/tuto_D_colliders_mesh.jpg new file mode 100644 index 000000000..d81cf9a3d Binary files /dev/null and b/Docs/img/tuto_D_colliders_mesh.jpg differ diff --git a/Docs/img/tuto_D_colliders_staticmesh.jpg b/Docs/img/tuto_D_colliders_staticmesh.jpg new file mode 100644 index 000000000..d01ca0b10 Binary files /dev/null and b/Docs/img/tuto_D_colliders_staticmesh.jpg differ diff --git a/Docs/img/tuto_D_colliders_visible.jpg b/Docs/img/tuto_D_colliders_visible.jpg new file mode 100644 index 000000000..d52f99eda Binary files /dev/null and b/Docs/img/tuto_D_colliders_visible.jpg differ diff --git a/Docs/tuto_D_generate_colliders.md b/Docs/tuto_D_generate_colliders.md index 3eebd0f88..641ac3cce 100644 --- a/Docs/tuto_D_generate_colliders.md +++ b/Docs/tuto_D_generate_colliders.md @@ -1,28 +1,86 @@ # Generate detailed colliders -This tutorial explains how to create more accurate collision boundaries for vehicles (relative to the original shape of the object). These are used not only to detect collisions between elements in the scenes, but also for sensors such as the LIDAR. These colliders can be integrated into CARLA so that all the community can benefit from these. Details on how to contribute are explained in the last section of the tutorial. +This tutorial explains how to create more accurate collision boundaries for vehicles (relative to the original shape of the object). These are used by raycast-based sensors such a the LIDAR to retrieve more accurate data. New colliders can be integrated into CARLA so that all the community can benefit from these. Find out more about how to contribute to the content repository [here](cont_contribution_guidelines.md). -* [__Motivation__](#motivation) -* [__Prerequisites__](#prerequisites) -* [__Create custom colliders for a Skeletal Mesh__](#create-custom-colliders-for-a-skeletal-mesh) +There are two approaches to create the new colliders. + +* __Manual approach__ — This approach requires some basic 3D modelling skills, as the collider mesh will be generated manually. +* __Automatic approach__ — This approach follows the tutorial created by the contributor __Yan Kaganovsky / yankagan__ to create a mesh with no need of manual modelling. + + +* [__Manual approach__](#manual-approach) + * [1-Export the vehicle FBX](#1-export-the-vehicle-fbx) + * [2-Generate a low density mesh](#2-generate-a-low-density-mesh) + * [3-Import the mesh into UE](#3-import-the-mesh-into-ue) + * [4-Add the mesh as collider](#4-add-the-mesh-as-collider) + * [5-Configure the collider](#5-configure-the-collider) +--- +* [__Automatic approach__](#automatic-approach) + * [0-Prerequisites](#0-prerequisites) * [1-Define custom collision for wheels in Unreal Editor](#1-define-custom-collision-for-wheels-in-unreal-editor) * [2-Export the vehicle as FBX](#export-the-vehicle-as-fbx) * [3-Import to Blender and create custom boundary](#import-to-blender-and-create-custom-boundary) * [4-Export from Blender to FBX](#export-from-blender-to-fbx) * [5-Import collider and define physics](#Import-collider-and-define-physics) -* [__Submit new colliders__](#submit-new-colliders) + +--- +## Automatic approach + +### 1-Export the vehicle FBX + +First of all, the original mesh of the vehicle is necessary to be used as reference. For the sake of this tutorial, let's choose the mesh of a CARLA vehicle. +__1.1__ open CARLA in UE and go to `Content/Carla/Static/Vehicles/4Wheeled/`. +__1.2__ Press `right-click` on `SM_` to export the vehicle mesh as FBX. + +### 2-Generate a low density mesh + +__2.1__ Open a 3D modelling software and, using the original mesh as reference, model a low density mesh that stays reliable to the original. + +![manual_meshgen](img/tuto_D_colliders_mesh.jpg) + +__2.2__ Save the new mesh as FBX. Name de mesh as `sm_sc_.fbx`. E.g. `sm_sc_audiTT.fbx`. + +!!! Note + As for the wheels and additional elements such as roofs, mudguards, etc. the new mesh should follow the geometry quite accurately. Placing simple cubes will not do it. + +### 3-Import the mesh into UE + +__3.1__ Open CARLA in UE and go to `Content/Carla/Static/Vehicles/4Wheeled/`. +__3.2__ Press `right-click` to import the new mesh `SM_sc_.fbx`. + +### 4-Add the mesh as collider + +__4.1__ Go to `Content/Carla/Blueprints/Vehicles/` and open the blueprint of the vehicle named as `BP_`. + +__4.2__ Add a new element of type `Static mesh`. This will create an empty object in the blueprint. + +![manual_staticmesh](img/tuto_D_colliders_staticmesh.jpg) + +__4.3__ Rename this as `CustomCollision`. + +![manual_customcollision](img/tuto_D_colliders_CustomCollision.jpg) + +__4.4__ Go to the `Static mesh` property and choose the new mesh `SM_sc_.fbx`. + +### 5-Configure the collider + +There are two properties to set before the new collider is fully functional. + +__5.1__ Uncheck the property `Visible` and check `Hidden in Game`. + +![manual_visible](img/tuto_D_colliders_visible.jpg) + +__5.2__ In `CollisionPresets`, choose `CustomSensorCollision`. + +![manual_collider](img/tuto_D_colliders_collider.jpg) + + +--- +## Automatic approach !!! Important This tutorial is based on a [contribution](https://bitbucket.org/yankagan/carla-content/wiki/Home) made by __yankagan__! The contributor also wants to aknowledge __Francisco E__ for the tutorial on [how to import custom collisions in UE](https://www.youtube.com/watch?v=SEH4f0HrCDM). ---- -## Motivation - -CARLA uses [Skeletal meshes](https://docs.unrealengine.com/en-US/Engine/Content/Types/SkeletalMeshes/index.html) to create create vehicle animations in UE. Unfortunately, UE does not allow using the original mesh as collider for these objects, due to computational costs. Instead, the vehicle is approximated as a box with for spherical wheels. Hereunder there is an image of the original collider created by UE. - -![not detailed collider](img/tuto_D_collider_detailed_not.jpg) -
Original collider for vehicle.
- There are two ways to improve these colliders. __1. Use a collection of static meshes__ and move them around as if they were part of the vehicle. This requires significant redesign of CARLA and creates new problems such as how certain features such as suspension or wheels should be animated. @@ -33,8 +91,8 @@ The later method will be discussed in this tutorial. It requires some knowledge [![detailed collider](img/tuto_D_collider_detailed.jpg)](https://www.youtube.com/watch?v=CXK2M2cNQ4Y)
Detailed collider for vehicle.
---- -## Prerequisites + +### Prerequisites * __Build CARLA from source__ on [Linux](build_linux.md) or [Windows](build_windows.md). * __Blender 2.80 or newer__ from the [official site](https://www.blender.org/download/) for free (open-source 3D modelling software). @@ -57,16 +115,16 @@ __Step 6.__ *(UE)* — Import the new FBX into CARLA as an Unreal asset file (st __Step 7.__ *(UE)* — Import the custom collider into the physics asset for the specific vehicle, so that it is used for computations. __Step 8.__ *(UE)* — Create constraints that connect the different joints and define the physics of all parts. -### Step 1-Define custom collision for wheels in Unreal Editor +### 1-Define custom collision for wheels in Unreal Editor https://www.youtube.com/watch?v=bECnsTw6ehI -### Step 2-Export the vehicle as FBX +### 2-Export the vehicle as FBX https://www.youtube.com/watch?v=fDmxIRV-j5g -### Steps 3 to 4-Import to Blender and create custom boundary +### 3 to 4-Import to Blender and create custom boundary Below you will find 2 clips that gives an example of this process but before you watch it let me explain a bit about the logic that goes into this process: @@ -88,25 +146,14 @@ https://www.youtube.com/watch?v=oROkK3OCuOA https://www.youtube.com/watch?v=L3upzdC602s -### Step 5-Export from Blender to FBX +### 5-Export from Blender to FBX This clip: https://youtu.be/aJPyskYjzWo explains this simple step. Follow it exactly. Select only the original car object + all the newly added objects for collision. Make sure that in the export menu you check "selected objects" and select only "Mesh". -### Steps 6 to 8-Import collider and define physics +### 6 to 8-Import collider and define physics https://www.youtube.com/watch?v=aqFNwAyj2CA ---- -## Submit new colliders - -It is worth pointing out that the goal of this repo is to collect all the unreal physics asset files with custom collisions in one place, so other people can use it! - -Please consider submitting your creations so that everyone can benefit. The process is very simple: - - Create a branch with the name "dev/" and upload the new physics asset you created. - Create a pull request to let us know you submitted it - We will occasionally test the newly submitted physics assets and copy them to the master branch - ---