Creating custom car types

If you have cars of different types in your model (e.g. car, lorry, bus, etc) with specific custom attributes (car speed, length, etc.) and you want them to look different at model runtime, you should create custom car types and generate cars of different car types in your model. This document describes how to do it.

 To define a custom car type

  1. Drag the Car Type element from the Road Traffic Library palette into the graphical editor.


  2. The New agent wizard will open. 
  3. On the first page of the wizard, specify Agent type name (e.g. Bus). Click Next to proceed to the next step.
  1. Choose animation for the cars of this type. If you want the cars to be animated both in 2D and 3D, choose 3D and select 3D animation shape from the list below. Otherwise, select 2D and select the figure suiting your needs from the list. If there is no one, choose None, you can draw the animation later. Finished with selecting the animation, click Next to proceed to the next step.


  2. Specify the parameters for this car type. For example, let us create a parameter for the vehicle's speed. Click <add new...> in the list to create new parameter. 

  1. You will see the section in the right panel of the wizard that allows you to configure the parameter selected in the table on the left. Set the parameter's name in the Parameter field: speed. Since this parameter defines speed, select Speed from the Type drop-down list below. Set the speed units for this parameter in the list on the right: kilometers per hour. Finally, specify the parameter's Default value: 75. 

  2. When you have finished, click Finish at the bottom of the wizard.

The graphical diagram of the created car type will open. You will see the chosen car animation there and the parameters you have defined in the Wizard.

Here you can modify the car animation. If you have not set any animation shape for this car type in the Car Type creation wizard, you can add your custom 3D object or 2D figure here on the car type diagram, putting the figure center in the point (0,0)). This figure will be used in the model to animate cars of this particular type.

Generating cars of a custom type and accessing custom car attributes

To generate the cars of a custom type you should choose this type (e.g. Bus) in the New car parameter of the corresponding CarSource block. Then the cars in this flowchart will be of this custom type, and you will be able to use car in the flowchart blocks to explicitly address the additional functionality of this car type . 

For example, you can use the previously specified speed parameter to set up the speed for Bus cars generated by CarSource. In both Initial speed and Preferred speed properties of the CarSource, type car.speed


Related topics

 Car functions

 Road Traffic Library tutorial