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

Commit 9ba7a5fe authored by Benedikt Zoennchen's avatar Benedikt Zoennchen

merge master into this branch and resolve merge conflicts.

parents ef61e0ea 770ba017
Pipeline #265238 failed with stages
in 2 minutes and 47 seconds
......@@ -172,7 +172,8 @@
"useFreeSpaceOnly" : true,
"targetIds" : [ 1 ],
"groupSizeDistribution" : [ 1.0 ],
"dynamicElementType" : "PEDESTRIAN"
"dynamicElementType" : "PEDESTRIAN",
"attributesPedestrian" : null
} ],
"dynamicElements" : [ {
"attributes" : {
......
......@@ -172,7 +172,8 @@
"useFreeSpaceOnly" : true,
"targetIds" : [ 1 ],
"groupSizeDistribution" : [ 1.0 ],
"dynamicElementType" : "PEDESTRIAN"
"dynamicElementType" : "PEDESTRIAN",
"attributesPedestrian" : null
} ],
"dynamicElements" : [ {
"attributes" : {
......
......@@ -172,7 +172,8 @@
"useFreeSpaceOnly" : true,
"targetIds" : [ 1 ],
"groupSizeDistribution" : [ 1.0 ],
"dynamicElementType" : "PEDESTRIAN"
"dynamicElementType" : "PEDESTRIAN",
"attributesPedestrian" : null
} ],
"dynamicElements" : [ {
"attributes" : {
......
......@@ -172,7 +172,8 @@
"useFreeSpaceOnly" : true,
"targetIds" : [ 1 ],
"groupSizeDistribution" : [ 1.0 ],
"dynamicElementType" : "PEDESTRIAN"
"dynamicElementType" : "PEDESTRIAN",
"attributesPedestrian" : null
} ],
"dynamicElements" : [ {
"attributes" : {
......
{
"name" : "05-OriginalExperiment-OSMEventDriven-PsychEnabled",
"name" : "06-OriginalExperiment-OSMEventDriven-PsychEnabled",
"description" : "",
"release" : "1.11",
"commithash" : "8b612bace24cbe5d7fa92b4b47687a9726a2a719",
"processWriters" : {
"files" : [ {
"type" : "org.vadere.simulator.projects.dataprocessing.outputfile.TimestepPedestrianIdOutputFile",
......@@ -252,7 +253,8 @@
"useFreeSpaceOnly" : true,
"targetIds" : [ 1 ],
"groupSizeDistribution" : [ 1.0 ],
"dynamicElementType" : "PEDESTRIAN"
"dynamicElementType" : "PEDESTRIAN",
"attributesPedestrian" : null
} ],
"dynamicElements" : [ {
"attributes" : {
......
......@@ -2,6 +2,7 @@
"name" : "07-CounterFlow-OSMSequential-PsychDisabled",
"description" : "",
"release" : "1.11",
"commithash" : "8b612bace24cbe5d7fa92b4b47687a9726a2a719",
"processWriters" : {
"files" : [ {
"type" : "org.vadere.simulator.projects.dataprocessing.outputfile.EventtimePedestrianIdOutputFile",
......@@ -189,7 +190,8 @@
"useFreeSpaceOnly" : true,
"targetIds" : [ 1 ],
"groupSizeDistribution" : [ 1.0 ],
"dynamicElementType" : "PEDESTRIAN"
"dynamicElementType" : "PEDESTRIAN",
"attributesPedestrian" : null
}, {
"id" : 4,
"shape" : {
......@@ -210,7 +212,8 @@
"useFreeSpaceOnly" : true,
"targetIds" : [ 2 ],
"groupSizeDistribution" : [ 1.0 ],
"dynamicElementType" : "PEDESTRIAN"
"dynamicElementType" : "PEDESTRIAN",
"attributesPedestrian" : null
} ],
"dynamicElements" : [ ],
"attributesPedestrian" : {
......
{
"name" : "06-UnidirectionalFlow-OSMSequential-PsychEnabled",
"name" : "08-UnidirectionalFlow-OSMSequential-PsychEnabled",
"description" : "",
"release" : "1.11",
"commithash" : "8b612bace24cbe5d7fa92b4b47687a9726a2a719",
"processWriters" : {
"files" : [ {
"type" : "org.vadere.simulator.projects.dataprocessing.outputfile.EventtimePedestrianIdOutputFile",
......@@ -172,7 +173,8 @@
"useFreeSpaceOnly" : true,
"targetIds" : [ 1 ],
"groupSizeDistribution" : [ 1.0 ],
"dynamicElementType" : "PEDESTRIAN"
"dynamicElementType" : "PEDESTRIAN",
"attributesPedestrian" : null
} ],
"dynamicElements" : [ ],
"attributesPedestrian" : {
......
{
"name" : "08-CounterFlow-OSMSequential-PsychEnabled",
"name" : "09-CounterFlow-OSMSequential-PsychEnabled",
"description" : "",
"release" : "1.11",
"commithash" : "8b612bace24cbe5d7fa92b4b47687a9726a2a719",
"processWriters" : {
"files" : [ {
"type" : "org.vadere.simulator.projects.dataprocessing.outputfile.EventtimePedestrianIdOutputFile",
......@@ -189,7 +190,8 @@
"useFreeSpaceOnly" : true,
"targetIds" : [ 1 ],
"groupSizeDistribution" : [ 1.0 ],
"dynamicElementType" : "PEDESTRIAN"
"dynamicElementType" : "PEDESTRIAN",
"attributesPedestrian" : null
}, {
"id" : 4,
"shape" : {
......@@ -210,7 +212,8 @@
"useFreeSpaceOnly" : true,
"targetIds" : [ 2 ],
"groupSizeDistribution" : [ 1.0 ],
"dynamicElementType" : "PEDESTRIAN"
"dynamicElementType" : "PEDESTRIAN",
"attributesPedestrian" : null
} ],
"dynamicElements" : [ ],
"attributesPedestrian" : {
......
{
"name" : "09-CounterFlow-OSMSequential-PsychEnabled-SearchRadiusAdapted",
"name" : "10-CounterFlow-OSMSequential-PsychEnabled-SearchRadiusAdapted",
"description" : "",
"release" : "1.11",
"commithash" : "8b612bace24cbe5d7fa92b4b47687a9726a2a719",
"processWriters" : {
"files" : [ {
"type" : "org.vadere.simulator.projects.dataprocessing.outputfile.EventtimePedestrianIdOutputFile",
......@@ -189,7 +190,8 @@
"useFreeSpaceOnly" : true,
"targetIds" : [ 1 ],
"groupSizeDistribution" : [ 1.0 ],
"dynamicElementType" : "PEDESTRIAN"
"dynamicElementType" : "PEDESTRIAN",
"attributesPedestrian" : null
}, {
"id" : 4,
"shape" : {
......@@ -210,7 +212,8 @@
"useFreeSpaceOnly" : true,
"targetIds" : [ 2 ],
"groupSizeDistribution" : [ 1.0 ],
"dynamicElementType" : "PEDESTRIAN"
"dynamicElementType" : "PEDESTRIAN",
"attributesPedestrian" : null
} ],
"dynamicElements" : [ ],
"attributesPedestrian" : {
......
{
"name" : "10-CounterFlowChicken-OSMEventDriven-PsychEnabled",
"name" : "11-CounterFlowChicken-OSMEventDriven-PsychEnabled",
"description" : "",
"release" : "1.11",
"commithash" : "8b612bace24cbe5d7fa92b4b47687a9726a2a719",
"processWriters" : {
"files" : [ {
"type" : "org.vadere.simulator.projects.dataprocessing.outputfile.EventtimePedestrianIdOutputFile",
......@@ -225,7 +226,8 @@
"useFreeSpaceOnly" : true,
"targetIds" : [ 1 ],
"groupSizeDistribution" : [ 1.0 ],
"dynamicElementType" : "PEDESTRIAN"
"dynamicElementType" : "PEDESTRIAN",
"attributesPedestrian" : null
}, {
"id" : 4,
"shape" : {
......@@ -246,7 +248,8 @@
"useFreeSpaceOnly" : true,
"targetIds" : [ 2 ],
"groupSizeDistribution" : [ 1.0 ],
"dynamicElementType" : "PEDESTRIAN"
"dynamicElementType" : "PEDESTRIAN",
"attributesPedestrian" : null
} ],
"dynamicElements" : [ ],
"attributesPedestrian" : {
......
{
"name" : "11-RiMEA11-ExitSelection-OSMEventDriven-PsychDisabled",
"name" : "12-RiMEA11-ExitSelection-OSMEventDriven-PsychDisabled",
"description" : "",
"release" : "1.11",
"commithash" : "8b612bace24cbe5d7fa92b4b47687a9726a2a719",
"processWriters" : {
"files" : [ {
"type" : "org.vadere.simulator.projects.dataprocessing.outputfile.EventtimePedestrianIdOutputFile",
......@@ -238,7 +239,8 @@
"useFreeSpaceOnly" : true,
"targetIds" : [ 1 ],
"groupSizeDistribution" : [ 1.0 ],
"dynamicElementType" : "PEDESTRIAN"
"dynamicElementType" : "PEDESTRIAN",
"attributesPedestrian" : null
} ],
"dynamicElements" : [ ],
"attributesPedestrian" : {
......
{
"name" : "12-RiMEA11-ExitSelection-OSMEventDriven-PsychEnabled",
"name" : "13-RiMEA11-ExitSelection-OSMEventDriven-PsychEnabled",
"description" : "",
"release" : "1.11",
"commithash" : "8b612bace24cbe5d7fa92b4b47687a9726a2a719",
"processWriters" : {
"files" : [ {
"type" : "org.vadere.simulator.projects.dataprocessing.outputfile.EventtimePedestrianIdOutputFile",
......@@ -238,7 +239,8 @@
"useFreeSpaceOnly" : true,
"targetIds" : [ 1 ],
"groupSizeDistribution" : [ 1.0 ],
"dynamicElementType" : "PEDESTRIAN"
"dynamicElementType" : "PEDESTRIAN",
"attributesPedestrian" : null
} ],
"dynamicElements" : [ ],
"attributesPedestrian" : {
......
{
"name" : "13-ThreatShort-SelfCatThreatModel",
"name" : "14-ThreatShort-SelfCatThreatModel",
"description" : "",
"release" : "1.11",
"commithash" : "8b612bace24cbe5d7fa92b4b47687a9726a2a719",
"processWriters" : {
"files" : [ {
"type" : "org.vadere.simulator.projects.dataprocessing.outputfile.TimestepPedestrianIdOutputFile",
......@@ -253,7 +254,8 @@
"useFreeSpaceOnly" : true,
"targetIds" : [ 1 ],
"groupSizeDistribution" : [ 1.0 ],
"dynamicElementType" : "PEDESTRIAN"
"dynamicElementType" : "PEDESTRIAN",
"attributesPedestrian" : null
}, {
"id" : 2,
"shape" : {
......@@ -274,7 +276,8 @@
"useFreeSpaceOnly" : true,
"targetIds" : [ 2 ],
"groupSizeDistribution" : [ 1.0 ],
"dynamicElementType" : "PEDESTRIAN"
"dynamicElementType" : "PEDESTRIAN",
"attributesPedestrian" : null
} ],
"dynamicElements" : [ {
"attributes" : {
......
{
"name" : "14-ThreatLong-SelfCatThreatModel",
"name" : "15-ThreatLong-SelfCatThreatModel",
"description" : "",
"release" : "1.11",
"commithash" : "8b612bace24cbe5d7fa92b4b47687a9726a2a719",
"processWriters" : {
"files" : [ {
"type" : "org.vadere.simulator.projects.dataprocessing.outputfile.TimestepPedestrianIdOutputFile",
......@@ -253,7 +254,8 @@
"useFreeSpaceOnly" : true,
"targetIds" : [ 1 ],
"groupSizeDistribution" : [ 1.0 ],
"dynamicElementType" : "PEDESTRIAN"
"dynamicElementType" : "PEDESTRIAN",
"attributesPedestrian" : null
}, {
"id" : 2,
"shape" : {
......@@ -274,7 +276,8 @@
"useFreeSpaceOnly" : true,
"targetIds" : [ 2 ],
"groupSizeDistribution" : [ 1.0 ],
"dynamicElementType" : "PEDESTRIAN"
"dynamicElementType" : "PEDESTRIAN",
"attributesPedestrian" : null
} ],
"dynamicElements" : [ {
"attributes" : {
......
{
"name" : "15-Threat-ImitatingBehavior-SelfCatThreatModel",
"name" : "16-Threat-ImitatingBehavior-SelfCatThreatModel",
"description" : "",
"release" : "1.11",
"commithash" : "8b612bace24cbe5d7fa92b4b47687a9726a2a719",
"processWriters" : {
"files" : [ {
"type" : "org.vadere.simulator.projects.dataprocessing.outputfile.TimestepPedestrianIdOutputFile",
......@@ -253,7 +254,8 @@
"useFreeSpaceOnly" : true,
"targetIds" : [ 1 ],
"groupSizeDistribution" : [ 1.0 ],
"dynamicElementType" : "PEDESTRIAN"
"dynamicElementType" : "PEDESTRIAN",
"attributesPedestrian" : null
}, {
"id" : 2,
"shape" : {
......@@ -274,7 +276,8 @@
"useFreeSpaceOnly" : true,
"targetIds" : [ 2 ],
"groupSizeDistribution" : [ 1.0 ],
"dynamicElementType" : "PEDESTRIAN"
"dynamicElementType" : "PEDESTRIAN",
"attributesPedestrian" : null
} ],
"dynamicElements" : [ {
"attributes" : {
......@@ -372,6 +375,54 @@
},
"modelPedestrianMap" : null,
"type" : "PEDESTRIAN"
}, {
"attributes" : {
"id" : 6,
"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
},
"source" : null,
"targetIds" : [ ],
"nextTargetListIndex" : 0,
"isCurrentTargetAnAgent" : false,
"position" : {
"x" : 4.6,
"y" : 11.0
},
"velocity" : {
"x" : 0.0,
"y" : 0.0
},
"freeFlowSpeed" : 1.0043602396182303,
"followers" : [ ],
"idAsTarget" : -1,
"isChild" : false,
"isLikelyInjured" : false,
"psychologyStatus" : {
"mostImportantStimulus" : null,
"threatMemory" : {
"allThreats" : [ ],
"latestThreatUnhandled" : false
},
"selfCategory" : "TARGET_ORIENTED",
"groupMembership" : "OUT_GROUP"
},
"groupIds" : [ ],
"groupSizes" : [ ],
"trajectory" : {
"footSteps" : [ ]
},
"modelPedestrianMap" : null,
"type" : "PEDESTRIAN"
} ],
"attributesPedestrian" : {
"radius" : 0.195,
......
......@@ -655,4 +655,8 @@ public class TestClient extends org.vadere.manager.client.AbstractTestClient imp
System.out.println(res.toString());
}
@Override
public void personapi_setInformation(String[] args) throws IOException {
}
}
......@@ -13,8 +13,10 @@ import org.vadere.manager.traci.commandHandler.variables.PersonVar;
import org.vadere.manager.traci.commands.TraCICommand;
import org.vadere.manager.traci.commands.TraCIGetCommand;
import org.vadere.manager.traci.commands.TraCISetCommand;
import org.vadere.manager.traci.compound.CompoundObject;
import org.vadere.manager.traci.response.TraCIGetResponse;
import org.vadere.simulator.control.simulation.SimulationState;
import org.vadere.state.psychology.perception.types.KnowledgeItem;
import org.vadere.state.scenario.Pedestrian;
import org.vadere.state.util.StateJsonConverter;
import org.vadere.util.geometry.Vector3D;
......@@ -392,6 +394,26 @@ public class PersonCommandHandler extends CommandHandler<PersonVar> {
return cmd;
}
@PersonHandler(cmd = TraCICmd.SET_PERSON_STATE, var = PersonVar.INFORMATION_ITEM, name = "setInformation")
public TraCICommand process_setStimulus(TraCISetCommand cmd, RemoteManager remoteManager) {
CompoundObject data = (CompoundObject) cmd.getVariableValue();
double start_t = (double)data.getData(0, TraCIDataType.DOUBLE);
double obsolete_at = (double)data.getData(1, TraCIDataType.DOUBLE);
String information = (String)data.getData(2, TraCIDataType.STRING);
// LinkedList<Integer> data = tmp.stream().map(Integer::parseInt).collect(Collectors.toCollection(LinkedList::new));
remoteManager.accessState((manager, state) -> {
Pedestrian ped = state.getTopography().getPedestrianDynamicElements()
.getElement(Integer.parseInt(cmd.getElementId()));
if (checkIfPedestrianExists(ped, cmd)) {
KnowledgeItem s = new KnowledgeItem(start_t, obsolete_at, information);
ped.getKnowledgeBase().addInformation(s);
cmd.setOK();
}
});
return cmd;
}
@PersonHandler(cmd = TraCICmd.SET_PERSON_STATE, var = PersonVar.TARGET_LIST, name = "setTargetList", dataTypeStr = "ArrayList<String>")
public TraCICommand process_setTargetList(TraCISetCommand cmd, RemoteManager remoteManager) {
List<String> tmp = (List<String>) cmd.getVariableValue();
......
......@@ -36,6 +36,7 @@ public enum PersonVar {
ADD(0x80, TraCIDataType.STRING),
REMOVE_STAGE(0xc5, TraCIDataType.INTEGER), // set
TARGET_LIST(0xfe, TraCIDataType.STRING_LIST), // get, set
INFORMATION_ITEM(0xfd, TraCIDataType.COMPOUND_OBJECT)
;
......
......@@ -4,7 +4,9 @@ import org.apache.commons.lang3.tuple.Pair;
import org.vadere.manager.TraCIException;
import org.vadere.manager.traci.TraCIDataType;
import java.util.Arrays;
import java.util.Iterator;
import java.util.function.Predicate;
/**
* CompoundObject implementation based on TraCI as described in https://sumo.dlr.de/docs/TraCI/Protocol.html#atomar_types
......@@ -94,16 +96,37 @@ public class CompoundObject {
return new Iter(this, typeAssertion);
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
CompoundObject that = (CompoundObject) o;
return Arrays.equals(type, that.type) &&
Arrays.equals(data, that.data);
}
@Override
public int hashCode() {
int result = Arrays.hashCode(type);
result = 31 * result + Arrays.hashCode(data);
return result;
}
private class Iter implements Iterator<Pair<TraCIDataType, Object>> {
private final CompoundObject compoundObject;
private final Predicate<TraCIDataType> typeAssertionTest;
private final TraCIDataType typeAssertion;
private int curr;
Iter(CompoundObject compoundObject, TraCIDataType typeAssertion) {
this.compoundObject = compoundObject;
this.typeAssertion = typeAssertion;
if (typeAssertion != null) {
this.typeAssertionTest = traCIDataType -> traCIDataType.equals(typeAssertion);
} else {
this.typeAssertionTest = traCIDataType -> true;
}
this.curr = 0;
}
......@@ -112,10 +135,12 @@ public class CompoundObject {
return curr < compoundObject.size();
}
@Override
public Pair<TraCIDataType, Object> next() {
Pair<TraCIDataType, Object> p = Pair.of(compoundObject.type[curr], compoundObject.data[curr]);
if (!p.getLeft().equals(this.typeAssertion)) {
if (! this.typeAssertionTest.test(p.getLeft())) {
throw new TraCIException("Type mismatch in CompoundObject. Expected '%s' but found '%s'",
this.typeAssertion.name(), p.getLeft().name());
}
......
package org.vadere.manager.traci.commandHandler;
import org.jetbrains.annotations.NotNull;
import org.junit.Test;
import org.mockito.Mockito;
import org.vadere.manager.RemoteManager;
......@@ -12,36 +11,31 @@ import org.vadere.manager.traci.commandHandler.variables.PersonVar;
import org.vadere.manager.traci.commands.TraCICommand;
import org.vadere.manager.traci.commands.TraCIGetCommand;
import org.vadere.manager.traci.commands.TraCISetCommand;
import org.vadere.manager.traci.writer.TraCIPacket;
import org.vadere.simulator.entrypoints.ScenarioFactory;
import org.vadere.manager.traci.compound.CompoundObject;
import org.vadere.manager.traci.compound.CompoundObjectBuilder;
import org.vadere.simulator.models.MainModel;
import org.vadere.simulator.models.MainModelBuilder;
import org.vadere.simulator.models.osm.OptimalStepsModel;
import org.vadere.simulator.projects.Scenario;
import org.vadere.state.scenario.DynamicElementContainer;
import org.vadere.state.attributes.scenario.AttributesAgent;
import org.vadere.state.psychology.perception.types.KnowledgeItem;
import org.vadere.state.scenario.Pedestrian;
import org.vadere.state.types.ScenarioElementType;
import org.vadere.state.util.StateJsonConverter;
import org.vadere.util.geometry.Vector3D;
import org.vadere.util.geometry.shapes.VPoint;
import org.vadere.util.geometry.shapes.Vector2D;
import org.vadere.util.io.IOUtils;
import org.vadere.util.logging.Logger;
import java.io.IOException;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
import java.util.Random;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.junit.Assert.assertThat;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import static org.mockito.Mockito.doNothing;
public class PersonCommandHandlerTest extends CommandHandlerTest {
......@@ -673,6 +667,37 @@ public class PersonCommandHandlerTest extends CommandHandlerTest {
testSetValue(ret, varID, varType, elementID, data);
}
@Test
public void process_setInformationItem() {
PersonVar var = PersonVar.INFORMATION_ITEM;
int varID = var.id;
TraCIDataType varType = var.type;
String elementID = "10";
Pedestrian p = new Pedestrian(new AttributesAgent(10), new Random(1));
CompoundObject data = CompoundObjectBuilder.builder()
.add(TraCIDataType.DOUBLE)
.add(TraCIDataType.DOUBLE)
.add(TraCIDataType.STRING)