Add New Vehicle
This document describes process of adding new vehicle model to Unity project.
Prepare Vehicle 3D model
A good example of how to prepare the 3D vehicle model prefab is Lexus RX450h which is already added and used in AWSIM project.
The model can be found under Assets/AWSIM/Models/Vehicles/Lexus RX450h 2015
directory.
To add new model user have to divide the model's meshes in the following parts:
- Body
- Each wheel
- Steering
The division needs also to be applied regarding the materials:
- HeadLight
- BrakeLight
- TurnSignal
- ReverseLight
Setup Physics & Collider
To make the vehicle model properly interact with other parts of simulation system, the following steps need to be conducted:
- Attach and configure
Rigidbody
- Create
MeshCollider
for models body - Set up
WheelCollider
on each wheel. Also attach the editor extension script forWheelColliderConfig.cs
, which automatically sets unnecessary parameters ofWheelCollider
. Set up parameters through theWheelColliderConfig
inspector.
Attach control scripts
The last step is to attach proper component scripts to the vehicle model prefab. The scripts will make the vehicle controllable and interactive with Autoware:
-
Wheel.cs
Attach
Wheel.cs
script to eachWheelCollider
in the 3D modelproperty feature WheelCollider See Unity documentation WheelVisualTransform Reference to WheelVisual Object -
Vehicle.cs
Attach
Vehicle.cs
script to vehicle root GameObjectproperty feature CenterOfMass Center of Mass position set by transform UseInertia Flag enabling moment of inertia usage Inertia Moment of inertia when UseInertia
is enabled (kgm^2)Front, Rear Axle Reference to each Wheel
component -
VehicleVisualEffect.cs
Attach
VehicleVisualEffect.cs
script to the GameObject to whichVehicle.cs
is attachedproperty feature Vehicle Reference to Vehicle
componentBrake Lights Brake light materials Left, Right Turn Signal Lights Turn signal light materials Turn Signal Timer Interval Sec Blink time of turn signal light Reverse Lights Reverse light materials -
VehicleROSInput.cs
Attach
VehicleROSInput.cs
script to the GameObject to whichVehicle.cs
is attached. You can configure the topic of each msg to subscribe in ROS2. When this script is attached, default values are set.
Info
Attach VehicleKeyboardInput.cs
for keyboard operation instead.