Commit fbd7356e authored by Benedikt Kleinmeier's avatar Benedikt Kleinmeier
Browse files

Merge branch 'master' into add_change_target_scripted_cognition_model

parents 8b9b55a8 8644643c
Pipeline #230542 passed with stages
in 123 minutes and 31 seconds
......@@ -20,7 +20,7 @@
* Hover over hash to see full value
* Left-Click to copy full hash to clipboard.
- TraCI commands:
* getHash: return Scenario hash for given scenario
* getHash: return scenario hash for given scenario
* CompoundObject implementation to allow complex get/set commands (i.e. create pedestrian hat
random location during simulation run)
- osm2vadere converter:
......
......@@ -13,7 +13,17 @@ research group at the [Munich University of Applied Sciences](https://www.hm.edu
[department for Computer Science and Mathematics](http://cs.hm.edu/).
However, we welcome contributions from external sources.
The Vadere framework includes a mesh generator for unstructured high-quality 2D meshes called **EikMesh** which is described [here](https://gitlab.lrz.de/vadere/vadere/wikis/eikmesh/Overview).
The Vadere framework includes a mesh generator for unstructured high-quality 2D meshes called **EikMesh** which is described [here](https://gitlab.lrz.de/vadere/vadere/wikis/eikmesh/Overview).
If you are using Vadere for your publication, please cite: http://dx.doi.org/10.17815/CD.2019.21.
## Contact
If you have questions about Vadere, have found a software bug or have a suggestion for improvements, please feel free to either
* [open an issue](https://gitlab.lrz.de/vadere/vadere/issues) (Note: you require an LRZ account), or
* send an e-mail with your enquiry to our mailing list [vadere@lists.lrz.de](vadere@lists.lrz.de)
## Pipeline Status
......
{
"name" : "separation_slow_fast",
"description" : "",
"release" : "1.11",
"commithash" : "f1fb53d68af6f8f4b84898b4e1c6a4be0bc89982",
"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" : "overlaps.csv",
"processors" : [ 3 ]
}, {
"type" : "org.vadere.simulator.projects.dataprocessing.outputfile.NoDataKeyOutputFile",
"filename" : "overlapCount.txt",
"processors" : [ 4 ]
} ],
"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
}
} ],
"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" : true,
"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" : 0.45,
"pedPotentialPersonalSpaceWidth" : 1.2,
"pedPotentialHeight" : 50.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" : 500.0,
"simTimeStepLength" : 0.4,
"realTimeSimTimeRatio" : 0.1,
"writeSimulationData" : true,
"visualizationEnabled" : true,
"printFPS" : false,
"digitsPerCoordinate" : 2,
"useFixedSeed" : true,
"fixedSeed" : -2527134724682099102,
"simulationSeed" : 0
},
"attributesPsychology" : {
"usePsychologyLayer" : false,
"psychologyLayer" : {
"perception" : "SimplePerceptionModel",
"cognition" : "CooperativeCognitionModel"
}
},
"topography" : {
"attributes" : {
"bounds" : {
"x" : 0.0,
"y" : 0.0,
"width" : 100.0,
"height" : 60.0
},
"boundingBoxWidth" : 0.5,
"bounded" : true,
"referenceCoordinateSystem" : null
},
"obstacles" : [ {
"shape" : {
"x" : 0.0,
"y" : 10.0,
"width" : 90.0,
"height" : 90.0,
"type" : "RECTANGLE"
},
"id" : 3
} ],
"measurementAreas" : [ ],
"stairs" : [ ],
"targets" : [ {
"id" : 1,
"absorbing" : true,
"shape" : {
"x" : 92.0,
"y" : 55.0,
"width" : 5.5,
"height" : 3.0,
"type" : "RECTANGLE"
},
"waitingTime" : 0.0,
"waitingTimeYellowPhase" : 0.0,
"parallelWaiters" : 0,
"individualWaiting" : true,
"deletionDistance" : 0.1,
"startingWithRedLight" : false,
"nextSpeed" : -1.0
} ],
"targetChangers" : [ ],
"absorbingAreas" : [ ],
"sources" : [ {
"id" : 1,
"shape" : {
"x" : 1.0,
"y" : 5.5,
"width" : 3.0,
"height" : 4.0,
"type" : "RECTANGLE"
},
"interSpawnTimeDistribution" : "org.vadere.state.scenario.ConstantDistribution",
"distributionParameters" : [ 1.0 ],
"spawnNumber" : 3,
"maxSpawnNumberTotal" : -1,
"startTime" : 0.0,
"endTime" : 0.0,
"spawnAtRandomPositions" : false,
"spawnAtGridPositionsCA" : false,
"useFreeSpaceOnly" : true,
"targetIds" : [ 1 ],
"groupSizeDistribution" : [ 1.0 ],
"dynamicElementType" : "PEDESTRIAN",
"attributesPedestrian" : {
"id" : -1,
"radius" : 0.2,
"densityDependentSpeed" : false,
"speedDistributionMean" : 1.8,
"speedDistributionStandardDeviation" : 0.0,
"minimumSpeed" : 0.5,
"maximumSpeed" : 2.2,
"acceleration" : 2.0,
"footstepHistorySize" : 4,
"searchRadius" : 1.0,
"walkingDirectionCalculation" : "BY_TARGET_CENTER",
"walkingDirectionSameIfAngleLessOrEqual" : 45.0
}
}, {
"id" : 2,
"shape" : {
"x" : 1.0,
"y" : 1.0,
"width" : 3.0,
"height" : 4.0,
"type" : "RECTANGLE"
},
"interSpawnTimeDistribution" : "org.vadere.state.scenario.ConstantDistribution",
"distributionParameters" : [ 1.0 ],
"spawnNumber" : 3,
"maxSpawnNumberTotal" : -1,
"startTime" : 0.0,
"endTime" : 0.0,
"spawnAtRandomPositions" : false,
"spawnAtGridPositionsCA" : false,
"useFreeSpaceOnly" : true,
"targetIds" : [ 1 ],
"groupSizeDistribution" : [ 1.0 ],
"dynamicElementType" : "PEDESTRIAN",
"attributesPedestrian" : {
"id" : -1,
"radius" : 0.2,
"densityDependentSpeed" : false,
"speedDistributionMean" : 0.9,
"speedDistributionStandardDeviation" : 0.0,
"minimumSpeed" : 0.5,
"maximumSpeed" : 2.2,
"acceleration" : 2.0,
"footstepHistorySize" : 4,
"searchRadius" : 1.0,
"walkingDirectionCalculation" : "BY_TARGET_CENTER",
"walkingDirectionSameIfAngleLessOrEqual" : 45.0
}
} ],
"dynamicElements" : [ ],
"attributesPedestrian" : {
"radius" : 0.2,
"densityDependentSpeed" : false,
"speedDistributionMean" : 1.34,
"speedDistributionStandardDeviation" : 0.26,
"minimumSpeed" : 0.5,
"maximumSpeed" : 2.2,
"acceleration" : 2.0,
"footstepHistorySize" : 4,
"searchRadius" : 1.0,
"walkingDirectionCalculation" : "BY_TARGET_CENTER",
"walkingDirectionSameIfAngleLessOrEqual" : 45.0
},
"teleporter" : null,
"attributesCar" : {
"id" : -1,
"radius" : 0.2,
"densityDependentSpeed" : false,
"speedDistributionMean" : 1.34,
"speedDistributionStandardDeviation" : 0.26,
"minimumSpeed" : 0.5,
"maximumSpeed" : 2.2,
"acceleration" : 2.0,
"footstepHistorySize" : 4,
"searchRadius" : 1.0,
"walkingDirectionCalculation" : "BY_TARGET_CENTER",
"walkingDirectionSameIfAngleLessOrEqual" : 45.0,
"length" : 4.5,
"width" : 1.7,
"direction" : {
"x" : 1.0,
"y" : 0.0
}
}
},
"stimulusInfos" : [ ]
}
}
\ No newline at end of file
......@@ -41,22 +41,19 @@ public class ActionPlaceRandomPedestrians extends TopographyAction {
@Override
public void actionPerformed(ActionEvent e) {
ActionRandomPedestrianDialog dialog = new ActionRandomPedestrianDialog();
if (dialog.getValue()){
if (dialog.showDialog() && dialog.isValid()) {
IDrawPanelModel model = getScenarioPanelModel();
int numOfPeds = dialog.getNumOfPeds();
Supplier<LinkedList<Integer>> targetSupplier = getTargetSupplier(dialog);
Random random = dialog.getRandom();
Rectangle2D.Double topographyBound = model.getTopographyBound();
Rectangle2D.Double legalBound = new Rectangle2D.Double(topographyBound.x + 0.8, topographyBound.y + 0.8,
topographyBound.width -1.6, topographyBound.height -1.6);
Rectangle2D.Double legalBound = dialog.getBoundaryRectangle();
SimpleReachablePointProvider provider = SimpleReachablePointProvider.uniform(random, legalBound, model.getTopography().getObstacleDistanceFunction());
int placedPedestrians = 0;
while (placedPedestrians < numOfPeds){
while (placedPedestrians < numOfPeds) {
IPoint p = provider.stream(dist -> dist > 0.25).findFirst().get();
getScenarioPanelModel().setSelectionShape(new VCircle(p.getX(), p.getY(), this.dotRadius));
......
......@@ -4,6 +4,7 @@ package org.vadere.gui.topographycreator.view;
import org.vadere.gui.projectview.view.ProjectView;
import java.awt.*;
import java.awt.geom.Rectangle2D;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.Random;
......@@ -16,17 +17,20 @@ import javax.swing.event.DocumentEvent;
public class ActionRandomPedestrianDialog {
private JTextField numberOfPeds_field;
private JTextField boundaryRectangle_field;
private JTextField targets_field;
private JTextField seed_field;
private JPanel panel;
private boolean valid;
private int numOfPeds;
private Rectangle2D.Double boundaryRectangle;
private LinkedList<Integer> selectedTargets;
private int seed;
private Random random;
public ActionRandomPedestrianDialog(){
public ActionRandomPedestrianDialog() {
numberOfPeds_field = new JTextField("10", 15);
numberOfPeds_field.setHorizontalAlignment(JTextField.RIGHT);
numberOfPeds_field.getDocument().addDocumentListener(new SimpleDocumentListener() {
......@@ -35,14 +39,40 @@ public class ActionRandomPedestrianDialog {
String text = numberOfPeds_field.getText();
try{
numOfPeds = Integer.parseInt(text);
ActionRandomPedestrianDialog.this.valid = true;
valid = true;
numberOfPeds_field.setForeground(Color.BLACK);
} catch (Exception ex){
ActionRandomPedestrianDialog.this.valid = false;
valid = false;
numberOfPeds_field.setForeground(Color.RED);
}
}
});
boundaryRectangle_field = new JTextField("x, y, width, height", 15);
boundaryRectangle_field.setHorizontalAlignment(JTextField.RIGHT);
boundaryRectangle_field.getDocument().addDocumentListener(new SimpleDocumentListener() {
@Override
public void handle(DocumentEvent e) {
String text = boundaryRectangle_field.getText();
try{
String[] numbersAsString = text.split(",");
boundaryRectangle = new Rectangle2D.Double(
Double.parseDouble(numbersAsString[0]),
Double.parseDouble(numbersAsString[1]),
Double.parseDouble(numbersAsString[2]),
Double.parseDouble(numbersAsString[3])
);
valid = true;
boundaryRectangle_field.setForeground(Color.BLACK);
} catch (Exception ex){
valid = false;
boundaryRectangle_field.setForeground(Color.RED);
}
}
});
targets_field = new JTextField("-1", 15);
targets_field.setHorizontalAlignment(JTextField.RIGHT);
targets_field.getDocument().addDocumentListener(new SimpleDocumentListener() {
......@@ -60,7 +90,7 @@ public class ActionRandomPedestrianDialog {
}
targets_field.setForeground(Color.BLACK);
}catch (Exception ex){
ActionRandomPedestrianDialog.this.valid = false;
valid = false;
targets_field.setForeground(Color.RED);
}
}
......@@ -72,10 +102,10 @@ public class ActionRandomPedestrianDialog {
public void handle(DocumentEvent e) {
try{
seed = Integer.parseInt(seed_field.getText());
ActionRandomPedestrianDialog.this.valid = true;
valid = true;
seed_field.setForeground(Color.BLACK);
} catch (Exception ex){
ActionRandomPedestrianDialog.this.valid = false;
valid = false;
seed_field.setForeground(Color.RED);
}
}
......@@ -87,12 +117,14 @@ public class ActionRandomPedestrianDialog {
panel.add(new JLabel("Set Number of Pedestrians"), c(GridBagConstraints.HORIZONTAL, 0, 0));
panel.add(numberOfPeds_field, c(GridBagConstraints.HORIZONTAL, 1, 0));
panel.add(new JLabel("Set Targets (-1 for random)"), c(GridBagConstraints.HORIZONTAL, 0, 1));
panel.add(targets_field, c(GridBagConstraints.HORIZONTAL, 1, 1));
panel.add(new JLabel("Set Random Seed (-1 for random)"), c(GridBagConstraints.HORIZONTAL, 0, 2));
panel.add(seed_field, c(GridBagConstraints.HORIZONTAL, 1, 2));
panel.add(new JLabel("In Boundary Rectangle"), c(GridBagConstraints.HORIZONTAL, 0, 1));
panel.add(boundaryRectangle_field, c(GridBagConstraints.HORIZONTAL, 1, 1));
panel.add(new JLabel("Set Targets (-1 for random)"), c(GridBagConstraints.HORIZONTAL, 0, 2));
panel.add(targets_field, c(GridBagConstraints.HORIZONTAL, 1, 2));
panel.add(new JLabel("Set Random Seed (-1 for random)"), c(GridBagConstraints.HORIZONTAL, 0, 3));
panel.add(seed_field, c(GridBagConstraints.HORIZONTAL, 1, 3));
panel.add(new JLabel("May take a while because intelligent distance function not available yet..."),
c(GridBagConstraints.HORIZONTAL, 0,3,2));
c(GridBagConstraints.HORIZONTAL, 0,4,2));
numOfPeds = 10;
selectedTargets = new LinkedList<>();
......@@ -126,6 +158,8 @@ public class ActionRandomPedestrianDialog {
return numOfPeds;
}
public Rectangle2D.Double getBoundaryRectangle() { return boundaryRectangle; }
public boolean useRandomTargets(){
return selectedTargets.isEmpty() || selectedTargets.peekFirst() == -1;
}
......@@ -145,11 +179,15 @@ public class ActionRandomPedestrianDialog {
return selectedTargets;
}
public boolean getValue(){
public boolean showDialog(){
return JOptionPane.showConfirmDialog(
ProjectView.getMainWindow(),
panel,
"Create Random Pedestrians",
JOptionPane.OK_CANCEL_OPTION) == JOptionPane.OK_OPTION;
}
public boolean isValid() {
return valid;
}
}
package org.vadere.simulator.control.scenarioelements;
import org.apache.commons.math3.distribution.RealDistribution;
import org.apache.commons.math3.random.JDKRandomGenerator;
import org.apache.commons.math3.random.RandomGenerator;
import org.vadere.simulator.models.DynamicElementFactory;
import org.vadere.state.attributes.scenario.AttributesAgent;
import org.vadere.state.attributes.scenario.AttributesDynamicElement;
......@@ -17,6 +19,7 @@ import org.vadere.util.geometry.LinkedCellsGrid;
import org.vadere.util.geometry.shapes.VCircle;
import org.vadere.util.geometry.shapes.VPoint;
import org.vadere.util.geometry.shapes.VShape;
import org.vadere.util.math.TruncatedNormalDistribution;
import java.util.LinkedList;
import java.util.List;
......@@ -162,11 +165,15 @@ public abstract class SourceController {
topography.addElement(newElement);
}
private DynamicElement createDynamicElement(final VPoint position) {
Agent result;
switch (sourceAttributes.getDynamicElementType()) {
case PEDESTRIAN:
result = (Agent) dynamicElementFactory.createElement(position, AttributesAgent.ID_NOT_SET, Pedestrian.class);
if (source.getAttributes().getAttributesPedestrian() == null) {
result = (Agent) dynamicElementFactory.createElement(position, AttributesAgent.ID_NOT_SET, Pedestrian.class);}
else{
result = (Agent) dynamicElementFactory.createElement(position, AttributesAgent.ID_NOT_SET, source.getAttributes().getAttributesPedestrian(), Pedestrian.class); }
break;
case CAR:
result = (Agent) dynamicElementFactory.createElement(position, AttributesAgent.ID_NOT_SET, Car.class);
......
package org.vadere.simulator.models;
import org.jetbrains.annotations.NotNull;
import org.vadere.state.attributes.Attributes;
import org.vadere.state.scenario.DynamicElement;
import org.vadere.state.scenario.Topography;
import org.vadere.util.geometry.shapes.VPoint;
......@@ -14,7 +15,16 @@ public interface DynamicElementFactory {
* Note: Every attribute of the given element should be cloned for each individual in this
* method, because some fields are individual.
*/
<T extends DynamicElement> DynamicElement createElement(VPoint position, int id, Class<T> type);
<T extends DynamicElement> DynamicElement createElement(VPoint position, int id, Class<T> type);
/**
* Override the DynamicElement Attributes given in the topography by the values given here.
* Note: The Attribute values come from the source and are set by the SourceController
* during DynamicElement Creation.
*/
<T extends DynamicElement> DynamicElement createElement(VPoint position, int id, Attributes attr, Class<T> type);
/**
* Ensure all Ids are unique within the topography.
......
......@@ -84,11 +84,19 @@ public class BehaviouralHeuristicsModel implements MainModel {
@Override
public <T extends DynamicElement> PedestrianBHM createElement(VPoint position, int id, Class<T> type) {
return createElement(position, id, this.attributesPedestrian, type);
}
@Override
public <T extends DynamicElement> PedestrianBHM createElement(VPoint position, int id, Attributes attr, Class<T> type) {
AttributesAgent aAttr = (AttributesAgent)attr;
if (!Pedestrian.class.isAssignableFrom(type))
throw new IllegalArgumentException("BHM cannot initialize " + type.getCanonicalName());
AttributesAgent pedAttributes = new AttributesAgent(
this.attributesPedestrian, registerDynamicElementId(topography, id));
aAttr, registerDynamicElementId(topography, id));
PedestrianBHM pedestrian = createElement(position, pedAttributes);
pedestrian.setPosition(position);
......
......@@ -58,10 +58,18 @@ public class BiomechanicsModel implements MainModel {
@Override
public <T extends DynamicElement> PedestrianBMM createElement(VPoint position, int id, Class<T> type) {
return createElement(position, id, this.attributesPedestrian, type);
}
@Override
public <T extends DynamicElement> PedestrianBMM createElement(VPoint position, int id, Attributes attr, Class<T> type) {
AttributesAgent aAttr = (AttributesAgent)attr;
if (!Pedestrian.class.isAssignableFrom(type))
throw new IllegalArgumentException("BMM cannot initialize " + type.getCanonicalName());
AttributesAgent pedAttributes = new AttributesAgent(
this.attributesPedestrian, registerDynamicElementId(topography, id));
aAttr, registerDynamicElementId(topography, id));
PedestrianBMM pedestrian = createElement(position, pedAttributes);
this.pedestriansBMM.add(pedestrian);
......
......@@ -152,10 +152,17 @@ public class GradientNavigationModel extends ODEModel<Pedestrian, AttributesAgen
@Override
public <T extends DynamicElement> Pedestrian createElement(VPoint position, int id, Class<T> type) {
return createElement(position, id, this.elementAttributes, type);
}
public <T extends DynamicElement> Pedestrian createElement(VPoint position, int id, Attributes attr, Class<T> type) {
AttributesAgent aAttr = (AttributesAgent)attr;
if (!Pedestrian.class.isAssignableFrom(type))
throw new IllegalArgumentException("GNM cannot initialize " + type.getCanonicalName());
AttributesAgent pedAttributes = new AttributesAgent(elementAttributes, registerDynamicElementId(domain.getTopography(), id));
AttributesAgent pedAttributes = new AttributesAgent(aAttr, registerDynamicElementId(domain.getTopography(), id));
Pedestrian result = create(position, pedAttributes);
return result;
}
......