Notice to GitKraken users: A vulnerability has been found in the SSH key generation of GitKraken versions 7.6.0 to 8.0.0 (https://www.gitkraken.com/blog/weak-ssh-key-fix). If you use GitKraken and have generated a SSH key using one of these versions, please remove it both from your local workstation and from your LRZ GitLab profile.

21.10.2021, 9:00 - 11:00: Due to updates GitLab may be unavailable for some minutes between 09:00 and 11:00.

Commit 9242f483 authored by Benedikt Zoennchen's avatar Benedikt Zoennchen
Browse files

reactivate the teleporter.

parent 2fe334bb
......@@ -26,12 +26,14 @@ public class TeleporterController {
VPoint newPos = new VPoint(position.x
+ teleporter.getTeleporterShift().x, position.y);
ped.setPosition(newPos);
scenario.moveElement(ped, position);
}
if (position.x < teleporter.getTeleporterPosition().x
+ teleporter.getTeleporterShift().x) {
VPoint newPos = new VPoint(position.x
- teleporter.getTeleporterShift().x, position.y);
ped.setPosition(newPos);
scenario.moveElement(ped, position);
}
}
}
......
......@@ -122,6 +122,6 @@ public class PedestrianRepulsionPotentialCycle implements
@Override
public void initialize(List<Attributes> attributesList, Topography topography,
AttributesAgent attributesPedestrian, Random random) {
// TODO should be used to initialize the Model
potentialFieldPedestrian.initialize(attributesList, topography, attributesPedestrian, random);
}
}
......@@ -3,10 +3,12 @@ package org.vadere.simulator.projects.dataprocessing.processor;
import org.vadere.annotation.factories.dataprocessors.DataProcessorClass;
import org.vadere.simulator.control.SimulationState;
import org.vadere.simulator.projects.dataprocessing.ProcessorManager;
import org.vadere.simulator.projects.dataprocessing.datakey.PedestrianIdKey;
import org.vadere.simulator.projects.dataprocessing.datakey.TimestepPedestrianIdKey;
import org.vadere.state.attributes.processor.AttributesPedestrianVelocityProcessor;
import org.vadere.state.attributes.processor.AttributesProcessor;
import org.vadere.state.scenario.Pedestrian;
import org.vadere.state.simulation.VTrajectory;
import org.vadere.util.geometry.shapes.VPoint;
import java.util.LinkedList;
......@@ -24,8 +26,7 @@ import java.util.stream.Stream;
*/
@DataProcessorClass()
public class PedestrianVelocityProcessor extends DataProcessor<TimestepPedestrianIdKey, Double> {
private PedestrianPositionProcessor pedPosProc;
//private PedestrianTrajectoryProcessor
private PedestrianTrajectoryProcessor pedTrajProc;
private int backSteps;
private LinkedList<Double> lastSimTimes;
......@@ -39,7 +40,7 @@ public class PedestrianVelocityProcessor extends DataProcessor<TimestepPedestria
@Override
public void doUpdate(final SimulationState state) {
pedPosProc.update(state);
pedTrajProc.update(state);
Integer timeStep = state.getStep();
state.getTopography().getElements(Pedestrian.class)
......@@ -58,9 +59,7 @@ public class PedestrianVelocityProcessor extends DataProcessor<TimestepPedestria
public void init(final ProcessorManager manager) {
super.init(manager);
AttributesPedestrianVelocityProcessor attVelProc = (AttributesPedestrianVelocityProcessor) getAttributes();
this.pedPosProc =
(PedestrianPositionProcessor) manager.getProcessor(attVelProc.getPedestrianPositionProcessorId());
this.pedTrajProc = (PedestrianTrajectoryProcessor) manager.getProcessor(attVelProc.getPedestrianTrajectoryProcessorId());
this.backSteps = attVelProc.getBackSteps();
this.lastSimTimes = new LinkedList<>();
this.lastSimTimes.add(0.0);
......@@ -73,14 +72,15 @@ public class PedestrianVelocityProcessor extends DataProcessor<TimestepPedestria
if(pastStep >= 0) {
TimestepPedestrianIdKey keyBefore = new TimestepPedestrianIdKey(pastStep, pedId);
if (timeStep <= 1 || !pedPosProc.hasValue(keyBefore))
if (timeStep <= 1)
return 0.0; // For performance
VPoint posBefore = pedPosProc.getValue(keyBefore);
VPoint posNow = pedPosProc.getValue(new TimestepPedestrianIdKey(timeStep, pedId));
double duration = (currentSimTime - lastSimTimes.getFirst());
VTrajectory trajectory = pedTrajProc.getValue(new PedestrianIdKey(pedId));
double startTime = lastSimTimes.getFirst();
double endTime = currentSimTime;
double duration = (endTime - startTime);
velocity = duration > 0 ? posNow.subtract(posBefore).scalarMultiply(1 / duration).distanceToOrigin() : 0;
velocity = trajectory.cut(startTime, endTime).speed().orElse(0.0);
return velocity;
}
......
......@@ -42,7 +42,7 @@ public class PedestrianVelocityProcessorTestEnv extends ProcessorTestEnv<Timeste
//add ProcessorId of required Processors to current Processor under test
AttributesPedestrianVelocityProcessor attr =
(AttributesPedestrianVelocityProcessor) testedProcessor.getAttributes();
attr.setPedestrianPositionProcessorId(pedPosProcId);
attr.setPedestrianTrajectoryProcessorId(pedPosProcId);
//create required Processor enviroment and add it to current Processor under test
pedPosProcEnv = new PedestrianPositionProcessorTestEnv(pedPosProcId);
......
......@@ -6,16 +6,16 @@ package org.vadere.state.attributes.processor;
*/
public class AttributesPedestrianVelocityProcessor extends AttributesProcessor {
private int pedestrianPositionProcessorId;
private int pedestrianTrajectoryProcessorId;
private int backSteps = 1;
public int getPedestrianPositionProcessorId() {
return this.pedestrianPositionProcessorId;
public int getPedestrianTrajectoryProcessorId() {
return pedestrianTrajectoryProcessorId;
}
public void setPedestrianPositionProcessorId(int pedestrianPositionProcessorId) {
public void setPedestrianTrajectoryProcessorId(int pedestrianTrajectoryProcessorId) {
checkSealed();
this.pedestrianPositionProcessorId = pedestrianPositionProcessorId;
this.pedestrianTrajectoryProcessorId = pedestrianTrajectoryProcessorId;
}
public int getBackSteps() {
......
......@@ -277,6 +277,13 @@ public abstract class StateJsonConverter {
if (attributesPedestrianNode != null)
((ObjectNode) attributesPedestrianNode).remove("id");
AttributesTeleporter attributesTeleporter = null;
if(topography.getTeleporter() != null) {
attributesTeleporter = topography.getTeleporter().getAttributes();
}
JsonNode node = mapper.convertValue(attributesTeleporter, JsonNode.class);
topographyNode.set("teleporter", node);
JsonNode attributesCarNode = mapper.convertValue(topography.getAttributesCar(), JsonNode.class);
topographyNode.set("attributesCar", attributesCarNode);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment