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 e012fe0f authored by Benedikt Kleinmeier's avatar Benedikt Kleinmeier
Browse files

Merge branch 'master' into psychology

parents 6daae747 1a3fac8c
Pipeline #260570 passed with stages
in 153 minutes and 4 seconds
{
"name" : "Liddle_osm_v4_clone_1",
"description" : "",
"release" : "1.12",
"processWriters" : {
"files" : [ {
"type" : "org.vadere.simulator.projects.dataprocessing.outputfile.EventtimePedestrianIdOutputFile",
"filename" : "postvis.traj",
"processors" : [ 1, 2 ]
}, {
"type" : "org.vadere.simulator.projects.dataprocessing.outputfile.TimestepPedestrianIdOverlapOutputFile",
"filename" : "overlap.csv",
"processors" : [ 3 ]
}, {
"type" : "org.vadere.simulator.projects.dataprocessing.outputfile.NoDataKeyOutputFile",
"filename" : "overlapCount.txt",
"processors" : [ 4 ]
}, {
"type" : "org.vadere.simulator.projects.dataprocessing.outputfile.TimestepPedestriansNearbyIdOutputFile",
"filename" : "pedsNearby.txt",
"processors" : [ 5 ]
} ],
"processors" : [ {
"type" : "org.vadere.simulator.projects.dataprocessing.processor.FootStepProcessor",
"id" : 1
}, {
"type" : "org.vadere.simulator.projects.dataprocessing.processor.FootStepTargetIDProcessor",
"id" : 2
}, {
"type" : "org.vadere.simulator.projects.dataprocessing.processor.PedestrianOverlapProcessor",
"id" : 3
}, {
"type" : "org.vadere.simulator.projects.dataprocessing.processor.NumberOverlapsProcessor",
"id" : 4,
"attributesType" : "org.vadere.state.attributes.processor.AttributesNumberOverlapsProcessor",
"attributes" : {
"pedestrianOverlapProcessorId" : 3
}
}, {
"type" : "org.vadere.simulator.projects.dataprocessing.processor.PedestriansNearbyProcessor",
"id" : 5,
"attributesType" : "org.vadere.state.attributes.processor.AttributesPedestrianNearbyProcessor",
"attributes" : {
"maxDistanceForANearbyPedestrian" : 1.5,
"sampleEveryNthStep" : 1,
"allowedAbsenceTimestepsIfContactReturns" : 2,
"minTimespanOfContactTimesteps" : 5,
"printContactTrajectories" : false,
"printForPostVis" : false
}
} ],
"isTimestamped" : true,
"isWriteMetaData" : false
},
"scenario" : {
"mainModel" : "org.vadere.simulator.models.osm.OptimalStepsModel",
"attributesModel" : {
"org.vadere.state.attributes.models.AttributesOSM" : {
"stepCircleResolution" : 4,
"numberOfCircles" : 1,
"optimizationType" : "NELDER_MEAD",
"varyStepDirection" : false,
"movementType" : "ARBITRARY",
"stepLengthIntercept" : 0.4625,
"stepLengthSlopeSpeed" : 0.2345,
"stepLengthSD" : 0.036,
"movementThreshold" : 0.0,
"minStepLength" : 0.1,
"minimumStepLength" : true,
"maxStepDuration" : 1.7976931348623157E308,
"dynamicStepLength" : true,
"updateType" : "EVENT_DRIVEN",
"seeSmallWalls" : false,
"targetPotentialModel" : "org.vadere.simulator.models.potential.fields.PotentialFieldTargetGrid",
"pedestrianPotentialModel" : "org.vadere.simulator.models.potential.PotentialFieldPedestrianCompactSoftshell",
"obstaclePotentialModel" : "org.vadere.simulator.models.potential.PotentialFieldObstacleCompactSoftshell",
"submodels" : [ ]
},
"org.vadere.state.attributes.models.AttributesPotentialCompactSoftshell" : {
"pedPotentialIntimateSpaceWidth" : 1.5,
"pedPotentialPersonalSpaceWidth" : 2.25,
"pedPotentialHeight" : 200.0,
"obstPotentialWidth" : 0.8,
"obstPotentialHeight" : 6.0,
"intimateSpaceFactor" : 1.2,
"personalSpacePower" : 1,
"intimateSpacePower" : 1
},
"org.vadere.state.attributes.models.AttributesFloorField" : {
"createMethod" : "HIGH_ACCURACY_FAST_MARCHING",
"potentialFieldResolution" : 0.1,
"obstacleGridPenalty" : 0.1,
"targetAttractionStrength" : 1.0,
"cacheType" : "NO_CACHE",
"cacheDir" : "",
"timeCostAttributes" : {
"standardDeviation" : 0.7,
"type" : "UNIT",
"obstacleDensityWeight" : 3.5,
"pedestrianSameTargetDensityWeight" : 3.5,
"pedestrianOtherTargetDensityWeight" : 3.5,
"pedestrianWeight" : 3.5,
"queueWidthLoading" : 1.0,
"pedestrianDynamicWeight" : 6.0,
"loadingType" : "CONSTANT",
"width" : 0.2,
"height" : 1.0
}
}
},
"attributesSimulation" : {
"finishTime" : 60.0,
"simTimeStepLength" : 0.4,
"realTimeSimTimeRatio" : 0.5,
"writeSimulationData" : true,
"visualizationEnabled" : true,
"printFPS" : false,
"digitsPerCoordinate" : 2,
"useFixedSeed" : false,
"fixedSeed" : 1,
"simulationSeed" : 0
},
"attributesPsychology" : {
"usePsychologyLayer" : false,
"psychologyLayer" : {
"perception" : "SimplePerceptionModel",
"cognition" : "CooperativeCognitionModel"
}
},
"topography" : {
"attributes" : {
"bounds" : {
"x" : 0.0,
"y" : 0.0,
"width" : 40.0,
"height" : 15.0
},
"boundingBoxWidth" : 0.5,
"bounded" : true,
"referenceCoordinateSystem" : null
},
"obstacles" : [ {
"shape" : {
"x" : 3.0,
"y" : 9.0,
"width" : 5.0,
"height" : 6.0,
"type" : "RECTANGLE"
},
"id" : 1
}, {
"shape" : {
"x" : 3.0,
"y" : 0.0,
"width" : 5.0,
"height" : 8.0,
"type" : "RECTANGLE"
},
"id" : 2
} ],
"measurementAreas" : [ {
"shape" : {
"x" : 8.5,
"y" : 6.0,
"width" : 1.0,
"height" : 3.0,
"type" : "RECTANGLE"
},
"id" : 1
}, {
"shape" : {
"x" : 8.0,
"y" : 5.6,
"width" : 2.0,
"height" : 4.0,
"type" : "RECTANGLE"
},
"id" : 2
} ],
"stairs" : [ ],
"targets" : [ {
"id" : 1,
"absorbing" : true,
"shape" : {
"x" : 1.0,
"y" : 6.8,
"width" : 1.4,
"height" : 1.4,
"type" : "RECTANGLE"
},
"waitingTime" : 0.0,
"waitingTimeYellowPhase" : 0.0,
"parallelWaiters" : 0,
"individualWaiting" : true,
"deletionDistance" : 0.1,
"startingWithRedLight" : false,
"nextSpeed" : -1.0
} ],
"targetChangers" : [ ],
"absorbingAreas" : [ ],
"sources" : [ {
"id" : 3,
"shape" : {
"x" : 19.0,
"y" : 1.0,
"width" : 20.0,
"height" : 13.0,
"type" : "RECTANGLE"
},
"interSpawnTimeDistribution" : "org.vadere.state.scenario.ConstantDistribution",
"distributionParameters" : [ 1.0 ],
"spawnNumber" : 70,
"maxSpawnNumberTotal" : -1,
"startTime" : 0.0,
"endTime" : 0.0,
"spawnAtRandomPositions" : true,
"spawnAtGridPositionsCA" : false,
"useFreeSpaceOnly" : true,
"targetIds" : [ 1 ],
"groupSizeDistribution" : [ 1.0 ],
"dynamicElementType" : "PEDESTRIAN",
"attributesPedestrian" : null
} ],
"dynamicElements" : [ ],
"attributesPedestrian" : {
"radius" : 0.195,
"densityDependentSpeed" : false,
"speedDistributionMean" : 1.34,
"speedDistributionStandardDeviation" : 0.26,
"minimumSpeed" : 0.01,
"maximumSpeed" : 5.0,
"acceleration" : 2.0,
"footstepHistorySize" : 4,
"searchRadius" : 1.0,
"walkingDirectionCalculation" : "BY_TARGET_CENTER",
"walkingDirectionSameIfAngleLessOrEqual" : 45.0
},
"teleporter" : null,
"attributesCar" : null
},
"stimulusInfos" : [ ]
}
}
\ No newline at end of file
......@@ -225,6 +225,8 @@ SettingsDialog.chbShowPedestrianIds.text=Show PedestrianIds
SettingsDialog.chbShowPedestrianInOutGroup.text=Show Pedestrian In/Outgroup
PostVis.chShowEvacTimeColor.text=Coloring by Evacuation Times
PostVis.chShowCriteriaColor.text=Coloring by Predicate
PostVis.ShowContactsErrorMessage.text=Contacts were not processed for this scenario. To process contacts for scenarios add PedestriansNearbyProcessor and a corresponding file contacts.txt to data output.
PostVis.additional.border.text=PostVis
PostVis.btnPlay.tooltip=Play (Space)
......@@ -311,6 +313,7 @@ SettingsDialog.chbLogo.text=Show the Vadere logo
ProjectView.btnShowWalkingDirection.tooltip=Show the walking direction of all pedestrians
ProjectView.btnShowGroupInformation.tooltip=Draw pedestrians within one group with same shape and color
ProjectView.btnShowPedestrian.tooltip=Show Pedestrians
ProjectView.btnShowContacts.tooltip=Show Contacts
ProjectView.btnShowPotentialfield.tooltip=Show Potential Field (only possible after adding potential field file)
ProjectView.btnShowTrajectories.tooltip=Show Trajectories
ProjectView.btnShowGrid.tooltip=Show Grid
......
......@@ -33,6 +33,7 @@ public class DefaultSimulationConfig extends DefaultConfig {
private boolean showStairs = true;
private boolean showPedestrians = true;
private boolean showContacts = true;
private boolean contactsRecorded = false;
private boolean showWalkdirection = false;
private boolean showTargetPotentialField = false;
private boolean showTargetPotentielFieldMesh = false;
......@@ -109,6 +110,13 @@ public class DefaultSimulationConfig extends DefaultConfig {
return showContacts;
}
public boolean isContactsRecorded() {
return contactsRecorded;
}
public void setContactsRecorded(boolean contactsRecorded) {
this.contactsRecorded = contactsRecorded;
}
public boolean isShowWalkdirection() {
return showWalkdirection;
......
......@@ -222,27 +222,22 @@ public class OnlineVisualisationWindow extends JPanel implements Observer {
mainPanel.addRendererChangeListener(generateINETenv);
mainPanel.addRendererChangeListener(showPotentialField);
SwingUtils.addActionToToolbar(toolbar, paintPedestriansAction,
Messages.getString("ProjectView.btnShowPedestrian.tooltip"));
SwingUtils.addActionToToolbar(toolbar, paintTrajectories,
Messages.getString("ProjectView.btnShowTrajectories.tooltip"));
SwingUtils.addActionToToolbar(toolbar, paintArrowAction,
Messages.getString("ProjectView.btnShowWalkingDirection.tooltip"));
SwingUtils.addActionToToolbar(toolbar, showGroupInformationAction,
Messages.getString("ProjectView.btnShowGroupInformation.tooltip"));
SwingUtils.addActionToToolbar(toolbar, drawVoronoiDiagram,
Messages.getString("ProjectView.btnDrawVoronoiDiagram.tooltip"));
SwingUtils.addActionToToolbar(toolbar, drawMesh,
Messages.getString("ProjectView.btnDrawMesh.tooltip"));
// Pedestrian-related options
SwingUtils.addActionToToolbar(toolbar, paintPedestriansAction, Messages.getString("ProjectView.btnShowPedestrian.tooltip"));
SwingUtils.addActionToToolbar(toolbar, paintTrajectories, Messages.getString("ProjectView.btnShowTrajectories.tooltip"));
SwingUtils.addActionToToolbar(toolbar, paintArrowAction, Messages.getString("ProjectView.btnShowWalkingDirection.tooltip"));
SwingUtils.addActionToToolbar(toolbar, showGroupInformationAction, Messages.getString("ProjectView.btnShowGroupInformation.tooltip"));
toolbar.addSeparator();
// "Measuring" tools
SwingUtils.addActionToToolbar(toolbar, drawVoronoiDiagram, Messages.getString("ProjectView.btnDrawVoronoiDiagram.tooltip"));
SwingUtils.addActionToToolbar(toolbar, drawMesh, Messages.getString("ProjectView.btnDrawMesh.tooltip"));
SwingUtils.addActionToToolbar(toolbar, paintGridAction, Messages.getString("ProjectView.btnShowGrid.tooltip"));
SwingUtils.addActionToToolbar(toolbar, paintDensity, Messages.getString("ProjectView.btnShowDensity.tooltip"));
SwingUtils.addActionToToolbar(toolbar, showPotentialField, Messages.getString("OnlineVis.btnShowPotentialfield.tooltip"));
toolbar.addSeparator();
// Snapshot options
ArrayList<Action> imgOptions = new ArrayList<>();
imgOptions.add(generatePNG);
imgOptions.add(generateSVG);
......@@ -253,16 +248,12 @@ public class OnlineVisualisationWindow extends JPanel implements Observer {
ActionOnlineVisMenu imgDialog = new ActionOnlineVisMenu(
"camera_menu",
resources.getIcon("camera.png", iconWidth, iconHeight), imgOptions);
JButton imgMenuBtn =
SwingUtils.addActionToToolbar(toolbar, imgDialog, Messages.getString("ProjectView.btnSnapshot.tooltip"));
JButton imgMenuBtn = SwingUtils.addActionToToolbar(toolbar, imgDialog, Messages.getString("ProjectView.btnSnapshot.tooltip"));
imgDialog.setParent(imgMenuBtn);
SwingUtils.addActionToToolbar(toolbar, showPotentialField, Messages.getString("OnlineVis.btnShowPotentialfield.tooltip"));
toolbar.add(Box.createHorizontalGlue());
SwingUtils.addActionToToolbar(toolbar, openSettingsDialog,
Messages.getString("ProjectView.btnSettings.tooltip"));
SwingUtils.addActionToToolbar(toolbar, openSettingsDialog, Messages.getString("ProjectView.btnSettings.tooltip"));
splitPaneForTopographyAndJsonPane = new JSplitPane();
splitPaneForTopographyAndJsonPane.setResizeWeight(0.8);
......
......@@ -104,6 +104,7 @@ public class PostvisualizationModel extends SimulationModel<PostvisualizationCon
this.simTimeStepLength = scenario.getAttributesSimulation().getSimTimeStepLength();
this.trajectories = new TableTrajectoryFootStep(trajectories);
if (contactTrajectories != null) {
this.config.setContactsRecorded(true);
this.contactData = new ContactData(contactTrajectories);
}
this.visTime = 0;
......
......@@ -2,42 +2,34 @@ package org.vadere.gui.postvisualization.view;
import org.vadere.gui.components.view.DefaultRenderer;
import org.vadere.gui.components.view.SimulationRenderer;
import org.vadere.gui.postvisualization.model.ContactData;
import org.vadere.gui.postvisualization.model.PostvisualizationModel;
import org.vadere.gui.postvisualization.model.TableTrajectoryFootStep;
import org.vadere.gui.renderer.agent.AgentRender;
import org.vadere.state.scenario.Pedestrian;
import org.vadere.state.simulation.FootStep;
import org.vadere.util.geometry.shapes.VPoint;
import org.vadere.util.logging.Logger;
import org.vadere.util.visualization.ColorHelper;
import tech.tablesaw.api.Row;
import tech.tablesaw.api.Table;
import java.awt.*;
import java.awt.geom.Path2D;
import java.util.*;
import java.util.List;
import tech.tablesaw.api.Row;
import tech.tablesaw.api.Table;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
public class PostvisualizationRenderer extends SimulationRenderer {
private static final double MIN_ARROW_LENGTH = 0.1;
private static Logger logger = Logger.getLogger(PostvisualizationRenderer.class);
private PostvisualizationModel model;
private final Map<Integer, VPoint> lastPedestrianPositions;
private final Map<Integer, VPoint> pedestrianDirections;
private ColorHelper colorHelper;
public PostvisualizationRenderer(final PostvisualizationModel model) {
super(model);
this.model = model;
this.pedestrianDirections = new HashMap<>();
this.lastPedestrianPositions = new HashMap<>();
this.colorHelper = new ColorHelper(model.getStepCount());
}
public PostvisualizationModel getModel() {
......@@ -46,81 +38,40 @@ public class PostvisualizationRenderer extends SimulationRenderer {
@Override
protected void renderSimulationContent(final Graphics2D g) {
this.colorHelper = new ColorHelper(model.getStepCount());
renderPedestrians(g, null);
}
private void renderPedestrians(final Graphics2D g, final Color color) {
if (!model.isEmpty()) {
renderTrajectories(g);
if (model.config.isShowContacts() && model.getContactData() != null) {
renderConnectingLinesByContact(g);
}
}
}
private void renderConnectingLinesByContact(Graphics2D g) {
if (!model.config.isShowAllTrajectories()) return;
Color color = g.getColor();
Stroke stroke = g.getStroke();
g.setStroke(new BasicStroke(getLineWidth() / 4.0f));
g.setColor(Color.red);
Collection<Pedestrian> agents = model.getPedestrians();
Map<Integer, VPoint> pedPositions = new HashMap<>();
agents.forEach(a -> pedPositions.put(a.getId(), a.getPosition()));
Table pairs = model.getContactData().getPairsOfPedestriansInContactAt(model.getSimTimeInSec());
for (Row row: pairs) {
int id1 = row.getInt(0);
int id2 = row.getInt(1);
VPoint ped1Pos = pedPositions.get(id1);
VPoint ped2Pos = pedPositions.get(id2);
Path2D.Double path = new Path2D.Double();
path.moveTo(ped1Pos.x, ped1Pos.y);
path.lineTo(ped2Pos.x, ped2Pos.y);
draw(path, g);
// paint agents in contact red
if (model.config.isShowPedestrians()) {
agents.stream().filter(a -> a.getId() == id1 || a.getId() == id2).forEach(a -> getAgentRender().render(a, Color.red, g));
}
}
Color savedColor = g.getColor();
g.setStroke(stroke);
g.setColor(color);
}
Table slice = (model.config.isShowAllTrajectories()) ? model.getAppearedPedestrians() : model.getAlivePedestrians() ;
Collection<Pedestrian> pedestrians = model.getPedestrians();
private void renderTrajectories(final Graphics2D g) {
Color color = g.getColor();
AgentRender agentRender = getAgentRender();
Map<Integer, Color> pedestrianColors = new HashMap<>();
pedestrians.forEach(ped -> pedestrianColors.put(ped.getId(), getPedestrianColor(ped)));
// sorted (by ped id) agent table
TableTrajectoryFootStep trajectories = model.getTrajectories();
renderTrajectories(g, slice, pedestrianColors);
renderPedestrians(g, pedestrians, pedestrianColors);
renderConnectingLinesByContact(g);
Table slice;
if (model.config.isShowAllTrajectories()) {
slice = model.getAppearedPedestrians();
} else {
slice = model.getAlivePedestrians();
g.setColor(savedColor);
}
}
Collection<Pedestrian> agents = model.getPedestrians();
private void renderTrajectories(Graphics2D g, Table slice, Map<Integer, Color> pedestrianColors) {
Map<Integer, Color> agentColors = new HashMap<>();
agents.forEach(agent -> agentColors.put(agent.getId(), getPedestrianColor(agent)));
Color savedColor = g.getColor();
Stroke savedStroke = g.getStroke();
TableTrajectoryFootStep trajectories = model.getTrajectories();
Color c = g.getColor();
Stroke stroke = g.getStroke();
if (model.config.isShowTrajectories()) {
for (Row row : slice) {
for(Row row : slice) {
boolean isLastStep = row.getDouble(trajectories.endTimeCol) > model.getSimTimeInSec();
double startX = row.getDouble(trajectories.startXCol);
double startY = row.getDouble(trajectories.startYCol);
double endX = row.getDouble(trajectories.endXCol);
double endY = row.getDouble(trajectories.endYCol);
if (isLastStep && model.config.isInterpolatePositions()) {
if(isLastStep && model.config.isInterpolatePositions()) {
VPoint interpolatedPos = FootStep.interpolateFootStep(startX, startY, endX, endY, row.getDouble(trajectories.startTimeCol), row.getDouble(trajectories.endTimeCol), model.getSimTimeInSec());
endX = interpolatedPos.getX();
endY = interpolatedPos.getY();
......@@ -132,11 +83,11 @@ public class PostvisualizationRenderer extends SimulationRenderer {
g.setColor(Color.MAGENTA);
g.setStroke(new BasicStroke(getLineWidth() / 2.0f));
} else {
Color cc = agentColors.get(pedId);
if (cc == null) {
Color cc = pedestrianColors.get(pedId);
if(cc == null) {
System.out.println("wtf");
}
g.setColor(agentColors.get(pedId));
g.setColor(pedestrianColors.get(pedId));
g.setStroke(new BasicStroke(getLineWidth() / 4.0f));
}
......@@ -146,55 +97,102 @@ public class PostvisualizationRenderer extends SimulationRenderer {
draw(path, g);
}
}
g.setColor(c);
g.setStroke(stroke);
g.setColor(savedColor);
g.setStroke(savedStroke);
}
private void renderPedestrians(Graphics2D g, Collection<Pedestrian> pedestrians, Map<Integer, Color> agentColors) {
AgentRender agentRender = getAgentRender();
// render agents i.e. circles
if (model.config.isShowPedestrians()) {
for (Pedestrian agent : agents) {
if (model.config.isShowFaydedPedestrians() || model.isAlive(agent.getId())) {
agentRender.render(agent, agentColors.get(agent.getId()), g);
for(Pedestrian pedestrian : pedestrians) {
if (model.config.isShowFaydedPedestrians() || model.isAlive(pedestrian.getId())) {
agentRender.render(pedestrian, agentColors.get(pedestrian.getId()), g);
if (model.config.isShowPedestrianIds()) {
DefaultRenderer.paintAgentId(g, agent);
DefaultRenderer.paintAgentId(g, pedestrian);
}
if (model.config.isShowPedestrianInOutGroup()) {
renderPedestrianInOutGroup(g, pedestrian);
}
}
// renderImage the arrows indicating the walking direction
if (model.config.isShowWalkdirection() &&
(model.config.isShowFaydedPedestrians() || trajectories.getDeathTime(agent.getId()) > model.getSimTimeInSec())) {
int pedestrianId = agent.getId();
VPoint lastPosition = lastPedestrianPositions.get(pedestrianId);
VPoint position = agent.getPosition();
lastPedestrianPositions.put(pedestrianId, position);
if (lastPosition != null) {
VPoint direction;
if (lastPosition.distance(position) < MIN_ARROW_LENGTH) {
direction = pedestrianDirections.get(pedestrianId);
} else {
direction = new VPoint(lastPosition.getX() - position.getX(),
lastPosition.getY() - position.getY());
direction = direction.norm();
pedestrianDirections.put(pedestrianId, direction);
}
if (!pedestrianDirections.containsKey(pedestrianId)) {
pedestrianDirections.put(pedestrianId, direction);
}
if (direction != null) {
double theta = Math.atan2(-direction.getY(), -direction.getX());
DefaultRenderer.drawArrow(g, theta,
position.getX() - agent.getRadius() * 2 * direction.getX(),
position.getY() - agent.getRadius() * 2 * direction.getY());
}
}
(model.config.isShowFaydedPedestrians() || model.getTrajectories().getDeathTime(pedestrian.getId()) > model.getSimTimeInSec())) {
renderWalkingDirection(g, pedestrian);
}
}
}
g.setColor(color);