Camera on transporter of population

Viewed 76

I want to put a camera on a transporter of an agent type AGV. Since there are multiple AGV transporters I cannot simply put it on the agent since it will give errors. So I tried to randomly select an AGV of the population, based on the busy parameter of the AGV agent. But when I try this it gives the next error: AGV can not be resolved to a variable.

AGV is an Agent type in my model and I've created a transporter fleet with as agent type the AGV (I also do not know if this is the correct method).

I've tried to code it in the following manner:

Code of transporterfleetpart

Code of selecting a camera

I'm not really sure what I'm doing wrong, but I also could not find any simple example of putting a camera on AGVs or containers or something, only very complex examples or examples where there was just one agent (e.g. an airplane).

Later added:

Camerasettings Gray screen

Thanks in advance, Aron

2 Answers

Just put the camera into your AGV agent type. Make sure that your TransporterFleet is adding new transporters to a custom population of AGV agents (myPop), see below: enter image description here

In your model, you can now change the camera using my3DWindow.setCamera(((AGV)randomFrom(myPop)).myCamera);

In your code you need to provide a population for the randomWhere function

enter image description here

And to add newly generated transporters to a population simply set it up in the transporter fleet

enter image description here

The easiest option to follow any agent is to have a camera inside the agent

enter image description here

And then in your code you simply set the 3DWindow camera to the camera of the selected AGV (You add true to the last parameter so that the 3D window follows the camera location)

enter image description here

Also check out the code in this model where AnyLogic implemented the follow camera logic in detail

https://cloud.anylogic.com/model/3291f1d6-d388-4d18-9060-29fad93d651d?mode=SETTINGS

Also in the example models inside AnyLogic

Related