Add a new vehicle - CARLA Simulator (2023)

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

Important

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 calledVehicleSkeleton.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: left_front_wheel
  • Right front wheel: right_front_wheel
  • Left rear wheel: left_rear_wheel
  • Right rear wheel: right_rear_wheel
  • Rest of the network: vehicle base

Use

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:

(Video) How to add a vehicle/truck in carla using Unreal Engine Editor 4 + Blender for beginners

  1. 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.
  2. glass_ext: A layer of glass that allows the interior of the vehicle to be seen from the outside.
  3. Glass_Int: A layer of glass that provides a view from the inside to the outside of the vehicle.
  4. Lighter: headlights, indicators, etc.
  5. LightGlass_Ext: A layer of glass that makes light visible from the outside in.
  6. LightGlass_Int: A layer of glass that allows light to enter from the inside to the outside.
  7. 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.
  8. Indoor: Any other data that does not fit in the previous sections can be enteredIndoor.

Materials must be named in the formatM_CarPart_CarName, for example.,M_body_mustang.

Textures must be named with the formatT_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.

Add a new vehicle - CARLA Simulator (1)

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 formatUCX_<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.

Add a new vehicle - CARLA Simulator (2)

Export the final mesh as.fbxfile namedSMC_<vehicle name>.fbx.

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.

Add a new vehicle - CARLA Simulator (3)

Export the final mesh as.fbxfile namedSM_sc_<vehicle name>.fbx.

5. Export the meshes of the vehicles.

Select all the main meshes of the vehicle and the skeleton base and export as.fbx.

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.

(Video) Building Autonomous self driving car |Installation and basics of Carla Simulator|Part 1

Create a new folder called<vehicle name>noInhale/Carla/Static/Vehicles/4Wheels.

2. Import the.fbx.

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 typeProGeometry Weights and Skinning.
  • Definenormal import methodProimport normals.
  • optionally definedMaterial import methodProdon't believe materials. deactivateimport texturesto prevent Unreal Engine from creating default materials.

Skeletal Mesh comes with two new files,<vehicle name>_PhysicsAssetsmi<Vehicle name>_Skeleton.

The rest of you matters.fbxFiles separate from the main skeleton of the vehicle..fbxArchive.

3. Define the grid of physical assets.

  1. Open mind<vehicle name>_PhysicsAssetsVoncontent browser.
  2. Right click on theBase_VehicleredSkelettbaumpanel and go toCopy collision of StaticMesh.
  3. Search and select yoursSMC_<vehicle name>Archive. The mesh outline of the physical asset should appear in the preview window.
  4. Remove the default capsule shape from theBase_Vehicle.
  5. Select all bikes:
    • I'm going toToolpanel and change theprimitive typeProShe was.
    • I'm going todetailspanel and scrollphysics boyProcinematic.
    • Definelinear dampingPro0. This eliminates any additional friction on the wheels.
  6. EnableThe simulation generates a success eventfor all points.
  7. Cliqueregenerated bodies.
  8. Adjust the wheel ball to the size of the wheel.
  9. Save and close the window.

Add a new vehicle - CARLA Simulator (4)

4. Create the animation design.

  1. nocontent browser, right-click on your vehicle's folder and selectAnimation -> Animation Project.
  2. noparent classsearch and selectVehicleAnimInstance.
  3. noskeleton goalsearch and select<Vehicle name>_Skeleton.
  4. PressOKand change the project name toAnimBP_<vehicle name>.

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:

  1. Go toContents/Carla/Statics/Vehicleand select any CARLA vehicle folder. Open your animation draft.
  2. noMy projectControl panel, double clickAnimGraphGenericName. The graph is displayed in the preview window.
  3. Click and drag to selectMesh space reference float,work handler, zlocation componentcomponents Right click and selectcopy of.
  4. Return to the animation plane of your own vehicle and paste the copied content into the graphics area.
  5. Click and drag from the character standing on thelocation componentcomponent of the figure instarting positionto connect the components.
  6. CliqueTo compilein the top left-hand corner. You should now see a pulsating line flowing through the string.
  7. Save and close the window.

Add a new vehicle - CARLA Simulator (5)

6. Create vehicle and bicycle plans.

  1. nocontent browser, Go toContents/Carla/Facilities/Vehiclesand create a new folder<vehicle name>.
  2. Right click inside the folder and go toclass model. open thisEach classsection in the popup window.
  3. SeekBaseVehiclePawnand pressureSelect.
  4. Rename the file asBP_<vehicle name>.
  5. Go to the folder of one of the native CARLA vehicles inCarla/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.

Add a new vehicle - CARLA Simulator (6)

7. Configure wheel schemes.

  1. In the vehicle blueprints folder, open the blueprints for all four wheels.
  2. noclass ruleschalkboard setcollision meshProWheel_Shape.If you skip this step, the vehicle's wheels will sink into the ground..
  3. Adjust the values ​​for the radius, width, mass, and damping ratio of the wheel shape according to your vehicle's specifications.
  4. Definetire configurationProCommonTireConfig
  5. On the front wheelsetsteering angleaccording to your configuration (default is70). deactivateAffected by the parking brake.
  6. On the rear wheel setsteering anglePro0. To verifyAffected by the parking brake.
  7. You can use the values ​​when defining the suspension valueson hereit's a guide
  8. Compile and save.

Add a new vehicle - CARLA Simulator (7)

8. Set up the vehicle layout.

  1. Voncontent browser, open yourBP_<vehicle name>.
  2. nocomponentspanel, selectMesh (VehicleMesh) (legacy).
  3. nodetailsPanel, ir askeleton meshand browse and select your vehicle skeleton base file (located in theCarla/Static/Vehicles/4 wheels/<vehicle_name>Pasta).
  4. Go toanimation classnodetailsBoard. Search and select yoursAnimBP_<vehicle name>Archive.
  5. nocomponentspanel, selectCustom collision (inherited).
  6. Selectstatic meshnodetailsDashboard and find yoursSM_sc_<vehicle name>Raycast-Sensornetz.
  7. nocomponentspanel, selectVehicleMovement (MovementComp) (herdado).
  8. nodetailsboard searchRad. You will find adjustments for each of the wheels. Click on eachwheel classand look for themBP_<vehicle name>_<wheel name>File corresponding to the correct position of the wheel.

Add a new vehicle - CARLA Simulator (8)

(Video) CARLA fundamentals

If you have additional grilles for your vehicle (doors, lights, etc.), separate them from the base grille:

  1. squeeze themMesh (VehicleMesh) (legacy)nest onecomponentsMesa.
  2. Select the additional meshes in the hierarchy and browsecollisionnodetailsMesa.
  3. DefineCollision PresetsProthere was no collision.
  4. Select any light web in the hierarchy. SeekMarcosnodetailsPanel and add the labelradiating.

Cliqueointment miTo compile.

9. Add the vehicle to the drawing library.

  1. noContents/Carla/Plant/Vehicle, open thisvehicle factoryArchive.
  2. nogenerate definitionstab, double clickvehicles.
  3. nodetailsDashboard, expand theDefault valuesection and add a new item to the vehicles array.
  4. to completeAgainmimodelyour vehicle
  5. to completeClassvalue with yourBP_<vehicle name>Archive.
  6. Optionally, specify a set of recommended vehicle colors.
  7. Compile and save.

Add a new vehicle - CARLA Simulator (9)

10. Test drive the vehicle.

Start CARLA, open a terminal underPythonAPI/Examplesand run the following command:

python3 manual_control.py --filter <model_name> # The make or model defined in step 9

supervision

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

SeekBaseVehiclePawnNWand pressureSelect.

Add a new vehicle - CARLA Simulator (10)

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.

Add a new vehicle - CARLA Simulator (11)

7. Configure wheel schemes

(Video) CARLA Simulator

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 panelRad. You will find adjustments for each of the wheels. For each one, click on Wheel Class and find the BP__File corresponding to the correct position of the wheel.

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:

Add a new vehicle - CARLA Simulator (12)

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).

Add a new vehicle - CARLA Simulator (13)

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 insideInhale/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 boxesBicycleBodyBone 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".

3.create folderContents/Attachments/Vehicles/<Vehicle model>

4.In this folder, create two Blueprint classes that derive from the VehicleWheel class. call the<vehicle model>_FrontWheelmi<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 fromBase2WheelsVehiclecall him<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=front wheel
  • 1:row class =<vehicle model>_FrontWheel, bone name=front wheel
  • 2:row class =<vehicle model>_RearWheel, bone name=rear wheel
  • 3:row class =<vehicle model>_RearWheel, bone name=rear wheel
    (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.

(Video) Programming Autonomous self-driving cars with Carla and Python

9.Give it a try, go to the CarlaGameMode model and change the "Default Pawn Class" to the newly created bike model.

Videos

1. SDV Course: Creating and moving a vehicle in Carla Simulator
(Copotron)
2. SDV Course: Attach a Camera to your vehicle in carla Simulator
(Copotron)
3. Self driving car setting up Pygame Environment |Carla Simulator
(Deepak Singh)
4. Unreal Engine Carla Build Windows
(Andrew 's Channels)
5. How to change the car in Carla SImulator
(H G)
6. Autonomous Parking of Vehicle Fleet in Tight Environments (Carla)
(Xu Shen)
Top Articles
Latest Posts
Article information

Author: Jamar Nader

Last Updated: 01/19/2023

Views: 5744

Rating: 4.4 / 5 (75 voted)

Reviews: 90% of readers found this page helpful

Author information

Name: Jamar Nader

Birthday: 1995-02-28

Address: Apt. 536 6162 Reichel Greens, Port Zackaryside, CT 22682-9804

Phone: +9958384818317

Job: IT Representative

Hobby: Scrapbooking, Hiking, Hunting, Kite flying, Blacksmithing, Video gaming, Foraging

Introduction: My name is Jamar Nader, I am a fine, shiny, colorful, bright, nice, perfect, curious person who loves writing and wants to share my knowledge and understanding with you.