Hello,
I'm trying to use the pedestrian library to model an environment, and then take control over some of the peds to
control them manually (well, programatically), instead of having them follow the flowchart.
I know how to get existing peds, from pedConfiguration HashSet.
When I use ped.x and ped.y, I get relative coordinates. To what are they relative ?
When I use Ped's getY, getOffsetY() methods, I get 0, which is obviously not the case. Why ?
When I use Ped's setTarget, it does not seem to be taken into account (beside the fact I don't know how to give them
valid x and y for destination)
So, how can I have peds aware of others and environment but not following flowchart ? (I tried to add peds myself in
the pedconf but got a NullPointerException)
How can i input targets or positions myself to my peds ?
Best regards,
Nicolas Pays.
Pavel Lebedev — 21.04.08
Hello Nicolas,
The ‘ped.x’ and ‘ped.y’ methods return coordinates in metric units. They are relative to the left upper corner
of the presentation window.
Ped class is inherited from Enterprise Library Entity class and inherits all properties of the Entity class. But Peds
live in the metric space. The ‘getY()’ and ‘getOffsetsY()’ methods return coordinates in animation units, so
they are undefined for Ped class. If you want to get ped’s coordinates in animation units you should use the following
equation:
pedX_inAnimationUnits = ped.x * pedConfiguration.animationScale
The ‘animationScale’ parameter you can set in the general properties of the ‘Ped Configuration’ element.
The ‘setTarget()’ method is the internal method of the Pedestrian Library. It is recommended to use ‘Ped Cmd Go
To’ element for such purposes. You can set line, polyline or pixel as a destination for ped in this element. More
information about this block you can find in Help|Help Contents| Pedestrian Library Reference Guide| Pedestrian Library
objects.
Every block from Pedestrian library has the ‘cancel’ port and ‘On cancel’ field in the general properties. So
you can take one of the peds and make him follow through the ‘cancel’ port to another flowchart.
Best regards,
Pavel Lebedev
Nicolas Pays — 26.05.08
Hello Pavel,
"pedX_inAnimationUnits = ped.x * pedConfiguration.animationScale"
Thanks, saved my life. I can now create agents at the exact position a ped was.
I'll now try to do the opposit --> inject a new Ped at the exact position an agent was.
As I've been unable to create peds "manually", Do I have to put ped sources everywhere and make the source
nearest to my agent inject the ped ?
Best Regards,
Nicolas Pays
Nicolas Pays — 26.05.08
Hi,
Ok, here is what i've tried to create a new ped from an agent :
MyAgentClass agent = (MyAgentClass) iterator.next();
//sourcePeds.inject(); <-- do not return Ped object, so I can't set it's position
Ped ped = sourceEntree2.newPed(); <-- returns Ped object, but is not injected
// sets ped position exactly where agent was
ped.x = agent.getX()/pedConfiguration.animationScale;
ped.y = agent.getY()/pedConfiguration.animationScale;
//adds my new ped with the others --> generates nullpointerexception at
com.xj.anylogic.libraries.pedestrian.PedConfiguration.executeActionOf(Unknown Source)
pedConfiguration.peds.add(ped);
Is there a way to mannually create peds and add them to the pedconfiguration in use ?
Best regards,
Nicolas Pays
Pavel Lebedev — 30.05.08
Hi Nicolas,
I recommend you to use "Ped Cmd Go To" element to define the position of the injected peds.
Please create a "Pixel" and type its name in the "Destination" field of the"Ped Cmd Go
To". You may set its coordinates in runtime, thus it is possible to type the following code:
pixel.setPos(agent.getX(), agent.getY());
Please use the "pedSource.inject(required_number_of_peds);" method in combination with the code above to
create peds manually and define its position according to the e.g. agent's position.
Best regards,
Pavel Lebedev
Nicolas Pays — 02.06.08
Hi,
ok thanks, I'll try playing with the goTo objects to get the effect I want.
Regards,
Nicolas.