8.8 KiB
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 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.
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.
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/<model_of_vehicle>
.
1.2 Press right-click
on SM_<model_of_vehicle>
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.
2.2 Save the new mesh as FBX. Name de mesh as sm_sc_<model_of_vehicle>.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/<model_of_vehicle>
.
3.2 Press right-click
to import the new mesh SM_sc_<model_of_vehicle>.fbx
.
4-Add the mesh as collider
4.1 Go to Content/Carla/Blueprints/Vehicles/<model_of_vehicle>
and open the blueprint of the vehicle named as BP_<model_of_vehicle>
.
4.2 Add a new element of type Static mesh
. This will create an empty object in the blueprint.
4.3 Rename this as CustomCollision
.
4.4 Go to the Static mesh
property and choose the new mesh SM_sc_<model_of_vehicle>.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
.
5.2 In CollisionPresets
, choose CustomSensorCollision
.
Automatic approach
!!! Important This tutorial is based on a contribution made by yankagan! The contributor also wants to aknowledge Francisco E for the tutorial on how to import custom collisions in UE.
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.
2. Create a custom collision boundary that describes the mesh more accurately and can be used with skeletal meshes.
The later method will be discussed in this tutorial. It requires some knowledge of 3D modelling, but it is accessible for newcomers. The following image shows a more detailed collider created with this tutorial.
Prerequisites
- Build CARLA from source on Linux or Windows.
- Blender 2.80 or newer from the official site for free (open-source 3D modelling software).
- VHACD Plugin for Blender following the using the instructions in here. This plugin automatically creates an approximation of a selected object using a collection of convex hulls. Read more.
!!! Note This series and Udemy course may be a good introduction to Blender for newcomers.
Create custom colliders for a Skeletal Mesh
Here is a brief summary of the steps to follow.
Step 1. (UE) — Add collision boundaries for the wheels.
Step 2. (UE) — Export the skeletal mesh asset of a vehicle to an FBX file.
Step 3. — Import the FBX file into Blender.
Step 4. (Blender) — Add convex hull meshes to form the new collision boundary (UE requirement for computational efficiency). This is the hardest step.
Step 5. (Blender) — Export the custom collision boundaries into an FBX file.
Step 6. (UE) — Import the new FBX into CARLA as an Unreal asset file (static mesh).
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.
1-Define custom collision for wheels in Unreal Editor
https://www.youtube.com/watch?v=bECnsTw6ehI
2-Export the vehicle as FBX
https://www.youtube.com/watch?v=fDmxIRV-j5g
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:
If you select the entire car and create the collision boundary with the VHACD Plugin you will get a very ugly approximation and the wheels will contains sharp edges which will mess-up the drive on the road (it will make them collide with the road every time it's not straight). It's important that the wheels have smooth boundaries around them. If you used convex decomposition on the car's body the mirror would still not look right.
For computer vision applications, we need some important features of the vehicles, such as side mirrors, wheels that look right, etc. It is with this in mind that I break down the vehicle into several parts.
Generally the steps are:
Cut out the bottom parts of the wheels, the side mirrors and the top part of the car's body to create the first boundary using the VHACD tool
Cut out the bottom half of the car to create the second boundary (top part of the car) using the VHACD tool
Create separate boundaries for side mirrors using the VHACD tool
Be very careful about naming the objects!! Each boundary should have "UCX_" at the beginning and the rest of the name has to be EXACTLY the same as the original mesh
The full example is shown in these two clips:
https://www.youtube.com/watch?v=oROkK3OCuOA
https://www.youtube.com/watch?v=L3upzdC602s
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".
6 to 8-Import collider and define physics
https://www.youtube.com/watch?v=aqFNwAyj2CA
That is all there is so far, regarding the different map customization tools available in CARLA.
Open CARLA and mess around for a while. If there are any doubts, feel free to post these in the forum.