To define a custom pedestrian type
- Drag the Pedestrian Type from the Pedestrian Library palette into the graphical editor.
- The New agent dialog box will be shown.
- On the first page of the wizard, specify Agent type name (e.g. Passenger). Click Next.
- Choose the animation for the pedestrians of this type. If you want the pedestrians to be animated both in 2D and 3D, choose 3D and select 3D animation shape from the list below. If you do not plan to create 3D animation for your model, choose None. Having completed the pedestrian type creation, you will be able to draw 2D animation on the pedestrian type diagram (we recommend to put a small circle with Radius: 2 in the point (0,0)).
- Finished with choosing the animation, click Next to proceed to the next step.
- Specify the parameters for this agent type. Click <add new> in the list to create new parameter. Having selected a parameter in this list, you can set its name, type, and initial value using the controls in the right panel. Click the button to remove a parameter from the list.
- Click Finish.
The graphical diagram of the created pedestrian type will open. You will see there the chosen pedestrian animation and the parameters you have defined in the Pedestrian Type Wizard.
- General
-
Name — The name of the pedestrian type.
Since AnyLogic generates Java class for each pedestrian type, you should follow Java naming guidelines and start the name with an uppercase letter.Ignore — If selected, the pedestrian type is excluded from the model.
- Parameters preview
-
Parameters preview properties are available only when this pedestrian type has any parameters. Here you can rearrange parameters of this pedestrian. Pedestrians of this type will list parameters in their property view in this well-defined order.
- Agent actions
-
On startup — Code to be executed after all agents throughout the whole model are constructed, connected, and initialized, and before anything else is done. This is a place for some additional initialization of the pedestrian. The order of execution of On startup code of different agents is not guaranteed. We recommend to perform pedestrian initialization not here, but in the On exit action property of the PedSource block that generates pedestrians in your model.
On destroy — Code to be executed on destroying pedestrian of this type. This parameter is derived from agent type and is rarely used for pedestrians. For details refer to the Agent article.
On arrival to target destination — This parameter is derived from agent type and is not applied to the movement defined with a Pedestrian Library flowchart.
On before step — This parameter is derived from agent type and is rarely used for pedestrians. For details refer to the Agent article.
On step — This parameter is derived from agent type and is rarely used for pedestrians. For details refer to the Agent article.
- Agent in flowcharts
-
Use in flowcharts as — Here you choose the role for agents of this type in the flowcharts. To enable using these agents as pedestrians in the blocks of the Pedestrian Library, leave the Pedestrian option selected. This way the agents of this type obtain pedestrian-specific functions: getComfortableSpeed(), getDiameter(), getTargetX(), etc.
On enter flowchart block — Here you can write the code to be executed when this pedestrian enters the flowchart.
On exit flowchart block — Here you can write the code to be executed when this pedestrian exits the flowchart.
On seize resource — This parameter is derived from agent type and is rarely used for pedestrians.
On release resource — This parameter is derived from agent type and is rarely used for pedestrians.
- Dimensions and movement
-
Initial speed — [Visible if Space type: Continuous or GIS] The speed of the pedestrian.
Rotate animation towards movement — [Visible if Space type: Continuous or GIS] The heading of the pedestrian.
Rotate vertically as well (along Z-axis) — If selected, the pedestrian shape will be headed towards the target during the pedestrian movement.
- Space and network
-
The parameters in this section are derived from agent type and are rarely used for pedestrians. For details refer to the Agent article.
- Advanced Java
-
The parameters in this section are derived from agent type and are rarely used for pedestrians. For details refer to the Agent article.
- Advanced
-
The parameters in this section are derived from agent type and are rarely used for pedestrians. For details refer to the Agent article.
Accessing parameters of custom pedestrians from the flowchart block parameters
To generate the pedestrians of a custom type, you must choose this type in the New pedestrian parameter of the corresponding PedSource block. The pedestrians in this flowchart will be of this custom type and you will be able to use the ped local variable in the flowchart blocks to explicitly address the additional functionality of this pedestrian type.
For example, we specify Passenger in the New pedestrian field of the PedSource block in the flowchart below. Now all pedestrians in this process will be of the Passenger type. If you have defined the timeArrived and waitingTime parameters in the Passenger pedestrian type, you will be able to store the time pedestrian waits in the block by writing simple code like ped.timeArrived = time() in the On enter parameter of the PedWait and ped.waitingTime = time()-ped.timeArrived in its On exit parameter.
if( ped instanceof Passenger ) ((Passenger)ped) waitingTime = time() - ((Passenger)ped).timeArrived
-
How can we improve this article?
-