This tutorial describes how to add a new vehicle to CARLA. There are two sections, one for 4 wheels and one for 2 wheels. Provides an overview of the basic requirements that need to be met when modeling your vehicle to work well in CARLA, and instructions on the configuration required after importing the vehicle into Unreal Engine.
- Add a 4 wheeler
- Link and model the vehicle
- Import and configure the vehicle
- Add a two-wheeler
This tutorial only applies to users who are working on a build from source and have access to the Unreal Engine editor.
Add a 4 wheeler
Vehicles added to CARLA must use acommon frameworkthat will be foundon here. This link will download a folder called
VehicleSkeleton.rarcontaining the basic skeleton in two
.fbxformats, one in ASCII and one in binary. The format used depends on the requirements of the 3D modeling software.
The positions of the bones in the skeleton can be changed, but any other manipulation, such as rotation, adding new bones, or changing the current hierarchy, will result in errors.
Link and model the vehicle
This section describes the minimum requirements in the modeling phase of your vehicle to ensure that it can be used successfully in CARLA. The process includes properly connecting the skeleton to the vehicle's base and wheels, creating physical assets and ray emission sensor meshes, and exporting them in the correct format.
1. Import the base skeleton.
Import the basic skeleton into your favorite 3D modeling software. Common editors are Maya and Blender.
2. Tie the bones together.
Tie the bones to the appropriate parts of the vehicle mesh according to the following nomenclature. Be sure to center the wheel bones within the mesh.
- Left front wheel:
- Right front wheel:
- Left rear wheel:
- Right rear wheel:
- Rest of the network:
Do not make changes to the names or hierarchies of the bones, and do not add new bones.
3. Model your vehicle.
Vehicles must have between 50,000 and 100,000 tris approximately. We model the vehicles in the size and scale of real cars.
We recommend that you divide the vehicle into the following materials:
- Body: The metal part of the vehicle. This material will be changed to Unreal Engine material. Logos and details can be added, but to be visible they must be drawn in a different color using the alpha channels in the Unreal Engine editor.
- glass_ext: A layer of glass that allows the interior of the vehicle to be seen from the outside.
- Glass_Int: A layer of glass that provides a view from the inside to the outside of the vehicle.
- Lighter: headlights, indicators, etc.
- LightGlass_Ext: A layer of glass that makes light visible from the outside in.
- LightGlass_Int: A layer of glass that allows light to enter from the inside to the outside.
- sign: A rectangular plan of 29x12 cm. You can use the provided CARLA
.fbxdownload it for best resultson here. The texture is automatically assigned in Unreal Engine.
- Indoor: Any other data that does not fit in the previous sections can be enteredIndoor.
Materials must be named in the format
M_CarPart_CarName, for example.,
Textures must be named with the format
T_CarPart_CarName, for example.,
T_mustang_body. Textures must be 2048 x 2048 in size.
Unreal Engine creates LODs automatically, but you can also create them manually in your 3D editor. The tricounts are as follows:
- LOD 0: 100.000 tris
- WELDING 1: 80.000 tris
- WELDING 2: 60.000 tris
- WELDING 3: 30.000 tris
4. Create the physical asset mesh.
The physical asset mesh is an additional mesh that Unreal Engine can use to compute vehicle physics. It should be as simple as possible, with a low polygon count, and cover the entire vehicle except the wheels. See the image below for an example.
The physical asset mesh must be exported as a separate file
.fbxArchive. The final file must meet the following requirements:
- Do you have a home network? This must be a copy of the physical asset grid. It must have the same name as the original vehicle.
- The physical asset mesh must be named with the format
UCX_<vehicle name>_<network number>,Otherwise, Unreal Engine won't recognize it.
- The mesh must not exceed the limits of the original model.
- The mesh must be in the same position as the original model.
Export the final mesh as
5. Create the mesh for the lightning emission sensor.
The raycast sensor network configures the shape of the vehicle that is detected by raycast sensors (RADAR, LiDAR and Semantic LiDAR). This mesh should have a slightly sharper geometry than the Physical Asset Mesh to increase the realism of the sensor simulation, but not as detailed as the Car Mesh for performance reasons.
Consider the following points when networking the Raycast sensor:
- The mesh must cover all aspects of the vehicle, including the wheels, side mirrors, and grill.
- The wheels must be cylinders with a maximum of 16 turns.
- If necessary, several meshes can be connected.
- The networks must not exceed the limits of the original model.
- The stitch(es) must be in the same position as the original.
Export the final mesh as
5. Export the meshes of the vehicles.
Select all the main meshes of the vehicle and the skeleton base and export as
Import and configure the vehicle
This section describes the process of importing the vehicle into Unreal Engine for use in CARLA. Complete these steps in the Unreal Engine editor.
1. Create the vehicle folder.
Create a new folder called
2. Import the
In the new vehicles folder, import the skeleton of your main vehicle
.fbxRight click on thecontent browserand selectImportar para Game/Carla/Static/Vehicles/4Wheeled/<vehicle_name>.
In the dialog that appears:
- Defineimport content typePro
Geometry Weights and Skinning.
- Definenormal import methodPro
- optionally definedMaterial import methodPro
don't believe materials. deactivateimport texturesto prevent Unreal Engine from creating default materials.
Skeletal Mesh comes with two new files,
The rest of you matters
.fbxFiles separate from the main skeleton of the vehicle.
3. Define the grid of physical assets.
- Open mind
<vehicle name>_PhysicsAssetsVoncontent browser.
- Right click on the
Base_VehicleredSkelettbaumpanel and go toCopy collision of StaticMesh.
- Search and select yours
SMC_<vehicle name>Archive. The mesh outline of the physical asset should appear in the preview window.
- Remove the default capsule shape from the
- Select all bikes:
- I'm going toToolpanel and change theprimitive typePro
- I'm going todetailspanel and scrollphysics boyPro
- Definelinear dampingPro
0. This eliminates any additional friction on the wheels.
- EnableThe simulation generates a success eventfor all points.
- Cliqueregenerated bodies.
- Adjust the wheel ball to the size of the wheel.
- Save and close the window.
4. Create the animation design.
- nocontent browser, right-click on your vehicle's folder and selectAnimation -> Animation Project.
- noparent classsearch and select
- noskeleton goalsearch and select
- PressOKand change the project name to
5. Set up the animation project.
To make the animation plane setup process easier, let's copy an existing plane of a native CARLA vehicle:
- Go to
Contents/Carla/Statics/Vehicleand select any CARLA vehicle folder. Open your animation draft.
- noMy projectControl panel, double clickAnimGraphGenericName. The graph is displayed in the preview window.
- Click and drag to selectMesh space reference float,work handler, zlocation componentcomponents Right click and selectcopy of.
- Return to the animation plane of your own vehicle and paste the copied content into the graphics area.
- Click and drag from the character standing on thelocation componentcomponent of the figure instarting positionto connect the components.
- CliqueTo compilein the top left-hand corner. You should now see a pulsating line flowing through the string.
- Save and close the window.
6. Create vehicle and bicycle plans.
- nocontent browser, Go to
Contents/Carla/Facilities/Vehiclesand create a new folder
- Right click inside the folder and go toclass model. open thisEach classsection in the popup window.
- Rename the file as
- Go to the folder of one of the native CARLA vehicles in
Carla/Plants/Vehicles. Voncontent browser, copy the blueprints for all four wheels into your own vehicle's blueprint folder. Rename the files to replace the old vehicle name with your own vehicle name.
7. Configure wheel schemes.
- In the vehicle blueprints folder, open the blueprints for all four wheels.
- noclass ruleschalkboard setcollision meshPro
Wheel_Shape.If you skip this step, the vehicle's wheels will sink into the ground..
- Adjust the values for the radius, width, mass, and damping ratio of the wheel shape according to your vehicle's specifications.
- Definetire configurationPro
- On the front wheelsetsteering angleaccording to your configuration (default is
70). deactivateAffected by the parking brake.
- On the rear wheel setsteering anglePro
0. To verifyAffected by the parking brake.
- You can use the values when defining the suspension valueson hereit's a guide
- Compile and save.
8. Set up the vehicle layout.
- Voncontent browser, open your
- nocomponentspanel, selectMesh (VehicleMesh) (legacy).
- nodetailsPanel, ir askeleton meshand browse and select your vehicle skeleton base file (located in the
- Go toanimation classnodetailsBoard. Search and select yours
- nocomponentspanel, selectCustom collision (inherited).
- Selectstatic meshnodetailsDashboard and find yours
- nocomponentspanel, selectVehicleMovement (MovementComp) (herdado).
- nodetailsboard search
Rad. You will find adjustments for each of the wheels. Click on eachwheel classand look for them
BP_<vehicle name>_<wheel name>File corresponding to the correct position of the wheel.(Video) CARLA fundamentals
If you have additional grilles for your vehicle (doors, lights, etc.), separate them from the base grille:
- squeeze themMesh (VehicleMesh) (legacy)nest onecomponentsMesa.
- Select the additional meshes in the hierarchy and browse
- DefineCollision PresetsPro
there was no collision.
- Select any light web in the hierarchy. Seek
MarcosnodetailsPanel and add the label
Cliqueointment miTo compile.
9. Add the vehicle to the drawing library.
Contents/Carla/Plant/Vehicle, open this
- nogenerate definitionstab, double clickvehicles.
- nodetailsDashboard, expand theDefault valuesection and add a new item to the vehicles array.
- to completeAgainmimodelyour vehicle
- to completeClassvalue with your
- Optionally, specify a set of recommended vehicle colors.
- Compile and save.
10. Test drive the vehicle.
Start CARLA, open a terminal under
PythonAPI/Examplesand run the following command:
python3 manual_control.py --filter <model_name> # The make or model defined in step 9
Even if you used uppercase letters in your make and model, they must be converted to lowercase when passed to the filter.
Add a wheeled vehicle N
Adding an N-Wheeler follows the same import process as the previous 4-Wheelers, with a few different steps.
5. Set up the animation layout for an N-Wheeler
6. Create wheel and vehicle blueprints
Go to the folder of any CARLA vehicle in Carla/Blueprints/Vehicles. In the content browser, copy the blueprints for all four wheels into your own vehicle's blueprints folder. Rename the files to replace the old vehicle name with your own vehicle name.
Copy all four wheels and copy again for more wheels. A 6-wheeled vehicle requires 6 different wheels: FLW, FRW, MLW, MRW, RLW, RRW.
7. Configure wheel schemes
follow section7as above for 4 wheel vehicles. The main difference in an N wheeled vehicle is the parameters affected by parking brake and steering. On some vehicles (eg, a long wheelbase truck), both pairs of front wheels turn and one set may turn more than the others. The rearmost pairs can be affected by the handbrake, the particularities will depend on the vehicle you are modeling.
8. Configure vehicle model
Look in the details panel
Rad. You will find adjustments for each of the wheels. For each one, click on Wheel Class and find the BP_
That's correct, but to be precise, on vehicles with N wheels you must define ALL wheels. This is an example with a 6-wheeler:
Finally, an additional consideration is the definition of the spread. On a 4 wheeler we have different diff presets (Limited Slip, Open 4W etc) but on N wheel vehicles you have to choose which wheels you want to apply the torque to. In this case we select only the intermediate and rear wheels with torque, while the front wheels do not. You can set other preferences. The numbers are the same as in the image above this text (for example, 0 is the left front wheel as above).
All other parameters such as engine, transmission, and steering curve are the same as 4-wheelers.
Add a two-wheeler
Adding a two-wheeler is similar to adding a four-wheeler, but due to the complexity of the animation, you'll need to set up additional bones to control the driver's animation.On hereis the link to the reference skeleton for two-wheeled vehicles.
As with 4-wheelers, orient the model in the positive "x" direction and each bone axis in the positive x-direction and with the z-axis facing up.
Bone Setup: - Bike_Rig: # The origin point of the mesh. Place it at point 0 of the scene comment - BikeBody: # Center point of the model's body. - Pedals: # If the vehicle is a bicycle, attach the cranks to this bone, it rotates with the acceleration of the bicycle. - RightPedal: # Defines the position of the driver's feet and turns with the pedal if the vehicle is a bicycle. - LeftPedal: # ^ - RearWheel: # Rear wheel of the vehicle - Manipulator: # Turns with the front wheel of the vehicle, connecting the manipulator vehicle to it. - HandlerMidBone: # It is placed on the bone of the front wheel to guide the handler with the wheel - HandlerRight: # Defines the position of the rider's hand without having to hold it to anything. - HandlerLeft: # ^ - Frontwheel: # Front wheel of the vehicle. - RightHelperRotator: # These four extra bones are here for an outdated system that makes the bike stable with extra invisible wheels - RightHelprWheel: # ^ - LeftHelperRotator: # ^ - LeftHelperWheel: # ^ - Seat: # Sets the position of the bone The driver's hip is fixed. You don't need to attach it to anything, but position it carefully.
1.Import fbx as a skeletal mesh in its own folder inside
Inhale/Carla/Static/Vehicles/2Wheels. When importing, select General2WheeledVehicleSkeleton as the skeleton. A physics resource should be automatically created and linked.
2.Fit physical function. Delete automatically created and added boxes
BicycleBodyBone trying to match the possible shape, make sure Generate Success Events is checked. Add a sphere to each wheel and set the "Physics Type" to "Kinematics".
4.In this folder, create two Blueprint classes that derive from the VehicleWheel class. call the
<vehicle model>_RearWheel. Set the "Shape Radius" to exactly match the radius of the mesh wheel (careful, radius, not diameter). Set the "Tire Configuration" to "CommonTireConfig". Disable Affected by Parking Brake on the front wheel and set the Steering Angle to zero on the rear wheel.
5.In the same folder, create a Blueprint class that derives from
<vehicle model>. Open it for editing and select the "Mesh" component, set the "Skeletal Mesh" and "Anim Class" to the appropriate ones. Then select the VehicleBounds component and set the size to cover the area of the vehicle seen from above.
6.Select the VehicleMovement component, under Vehicle Setup, expand Wheel Setups and configure each wheel.
- 0:row class =
<vehicle model>_FrontWheel, bone name=
- 1:row class =
<vehicle model>_FrontWheel, bone name=
- 2:row class =
<vehicle model>_RearWheel, bone name=
- 3:row class =
<vehicle model>_RearWheel, bone name=
(You'll notice that we're basically putting two wheels on each bone. The unrealistic vehicle class provided doesn't support vehicles with wheel numbers other than 4, so we had to make believe the vehicle had 4 wheels.)
7.Select the variable "is bike" and check if your model is a bike. This will activate the crankset rotation. Leave it disabled when riding a motorcycle.
8.Locate the Back Rotation variable and set it to best fit, select the SkeletalMesh (The Rider) component and move it along the x-axis until it is in the seated position.
9.Give it a try, go to the CarlaGameMode model and change the "Default Pawn Class" to the newly created bike model.