To define a custom pedestrian type
-
Drag the
Ped Source block from the
Pedestrian Library palette into the graphical editor.
-
Click on the pedSource block to open its properties.
-
In the Pedestrian section locate New pedestrian property. Open the list by clicking on the agent type in the property. Click Create new agent type.
The New agent type wizard will open.
-
In the wizard, specify the Name of the new pedestrian type (e.g., Passenger).
Pedestrian is an agent type, so its name should start with an uppercase letter. -
Choose the animation shape for the new agent type.
-
The Person 3D shape is suggested automatically for the pedestrians. Leave the Shape field unchanged if this shape meets your requirements.
-
If you wish to change the shape, click on the Person shape.
For the 2D and 3D animation, select the shape from the 3D tab. For the 2D animation, choose the shape from the 2D tab.
- For the custom 2D pedestrian animation or if you do not plan to create any animation for this pedestrian type at all, choose None in the Animation field.
After completing 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)).
-
-
Specify the parameters for this agent type.
-
Click Add parameters.
The new wizard view will open. To return to the previous view, click Back.
-
Click Add to create a new parameter.
To remove a parameter from the list, click the
button.
-
Set the name, type, and default value of the parameter.
-
- Click Finish.
The graphical diagram of the created pedestrian type will open in the next tab. If you click on it, you will see the chosen pedestrian animation and the parameters you have defined in the pedestrian type wizard.
You can now use the new pedestrian type in the Pedestrian Library block parameters. It is automatically specified in the properties of the pedSource block you used to create the pedestrian.
- 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 — The speed of the pedestrian.
Rotate animation towards movement — The heading of the pedestrian.
Rotate vertically (incline on ramps) — 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.
- Expert
-
The parameters in this section are derived from agent type and are rarely used for pedestrians.
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?
-