71 myStopWatch(10), myRNG(
"JuPedSim"), myNetwork(net), myShapeContainer(net->getShapeContainer()), myJPSDeltaT(
string2time(oc.getString(
"pedestrian.jupedsim.step-length"))),
72 myExitTolerance(oc.getFloat(
"pedestrian.jupedsim.exit-tolerance")), myGEOSPedestrianNetworkLargestComponent(nullptr),
73 myHaveAdditionalWalkableAreas(false) {
76 if (
myJPSModel.find(
"Model") == std::string::npos) {
79 if (
myJPSModel ==
"CollisionFreeSpeedV2Model") {
84 std::string address = oc.
getString(
"pedestrian.jupedsim.address");
87 const char* pythonEnv = getenv(
"PYTHON");
88 const std::string python = (pythonEnv ==
nullptr) ?
"python" : pythonEnv;
89 const char* sumoHomeEnv = getenv(
"SUMO_HOME");
90 const std::string sumoHome = (sumoHomeEnv ==
nullptr) ?
"." : sumoHomeEnv;
91 command = python +
" " + sumoHome +
"/tools/jupedsim_grpc/servicer.py";
92 if (oc.
isSet(
"pedestrian.jupedsim.py")) {
93 command +=
" --debug " + oc.
getString(
"pedestrian.jupedsim.py");
96 for (
int i = 0; i < 2; i++) {
100 myJuPedSimServer = std::unique_ptr<bp::child>(
new bp::child(command +
" --port " + port));
101 address =
"localhost:" + port;
103 WRITE_WARNINGF(
TL(
"No boost process support, you will need to start the JuPedSim server manually using %."), command);
107 myGrpcChannel = grpc::CreateChannel(address, grpc::InsecureChannelCredentials());
108 if (
myGrpcChannel->WaitForConnected(std::chrono::system_clock::now() + std::chrono::seconds(5))) {
112 WRITE_WARNINGF(
TL(
"Could not connect to JuPedSim gRPC server on '%' (will retry on demand)."), address);
114 if (myJuPedSimServer ==
nullptr || myJuPedSimServer->running()) {
131 if (myJuPedSimServer !=
nullptr) {
132 myJuPedSimServer->terminate();
140#ifdef DEBUG_GRPC_TIMING
141 std::cout <<
myStopWatch[0].getTotal() / (1e6) <<
"ms, iteration: "
142 <<
myStopWatch[1].getTotal() / (1e6) <<
"ms, agent data retrieval: "
143 <<
myStopWatch[2].getTotal() / (1e6) <<
"ms, journey creation: "
144 <<
myStopWatch[3].getTotal() / (1e6) <<
"ms, insertion: "
145 <<
myStopWatch[4].getTotal() / (1e6) <<
"ms, removal: "
146 <<
myStopWatch[5].getTotal() / (1e6) <<
"ms, add waiting set: "
147 <<
myStopWatch[6].getTotal() / (1e6) <<
"ms, speed: "
148 <<
myStopWatch[7].getTotal() / (1e6) <<
"ms " << std::endl;
155#ifdef DEBUG_GRPC_TIMING
159 sumo_jupedsim_api::CreateAgentRequest agentRequest;
161 agentRequest.set_agent_model_class(
myJPSModel);
162 auto& agentParams = *agentRequest.mutable_agent_model_parameters()->mutable_fields();
163 agentParams[
"journey_id"].set_number_value(
static_cast<double>(state->
getJourneyId()));
164 agentParams[
"stage_id"].set_number_value(
static_cast<double>(state->
getStageId()));
166 if (
myJPSModel !=
"GeneralizedCentrifugalForceModel") {
167 agentParams[
"radius"].set_number_value(
getRadius(type));
169 google::protobuf::ListValue* position = agentParams[
"position"].mutable_list_value();
170 position->add_values()->set_number_value(p.
x());
171 position->add_values()->set_number_value(p.
y());
174 double orientation_x = 0.;
175 double orientation_y = 0.;
176 if (fabs(angle -
M_PI / 2) < NUMERICAL_EPS) {
178 }
else if (fabs(angle +
M_PI / 2) < NUMERICAL_EPS) {
182 orientation_y = tan(angle);
184 google::protobuf::ListValue* orientation = agentParams[
"orientation"].mutable_list_value();
185 orientation->add_values()->set_number_value(orientation_x);
186 orientation->add_values()->set_number_value(orientation_y);
188 grpc::ClientContext agentContext;
189 sumo_jupedsim_api::CreateAgentResponse agentResponse;
190 const grpc::Status agentStatus =
myGrpcStub->CreateAgent(&agentContext, agentRequest, &agentResponse);
191 if (agentStatus.ok()) {
196#ifdef DEBUG_GRPC_TIMING
206 const MSLane*
const lane = std::get<1>(waypoint);
207 Position& coords = std::get<2>(waypoint);
208 double& dist = std::get<3>(waypoint);
209 sumo_jupedsim_api::AddWaypointStageRequest waypointRequest;
210 if (finalStage ==
nullptr) {
220 return centerIt->second;
226 waypointRequest.mutable_point()->set_x(coords.
x());
227 waypointRequest.mutable_point()->set_y(coords.
y());
228 waypointRequest.set_distance(dist);
229 sumo_jupedsim_api::StageResponse waypointResponse =
callGrpc(&sumo_jupedsim_api::JuPedSimService::Stub::AddWaypointStage, waypointRequest,
230 TLF(
"Error while adding waypoint for person '%': ", agentID),
true);
231 if (waypointResponse.stage_id() != 0 && finalStage ==
nullptr) {
234 return waypointResponse.stage_id();
243 const MSLane*
const departureLane = getSidewalk<MSEdge, MSLane>(stage->
getRoute().front());
244 if (departureLane ==
nullptr) {
245 const char* error =
TL(
"Person '%' could not find sidewalk on edge '%', time=%.");
258 if (tazShape ==
nullptr) {
271 const double halfDepartureLaneWidth = departureLane->
getWidth() / 2.0;
274 departureRelativePositionY = 0.0;
277 departureRelativePositionY =
RandHelper::rand(-halfDepartureLaneWidth, halfDepartureLaneWidth, &
myRNG);
282 std::vector<WaypointDesc> waypoints;
283 const MSEdge* prev =
nullptr;
285 const MSLane*
const lane = getSidewalk<MSEdge, MSLane>(e);
287 if (prev !=
nullptr) {
299 const MSEdge* wa =
nullptr;
300 for (
const MSEdge*
const ce : crossingRoute) {
301 if (ce->isCrossing()) {
302 const MSLane*
const crossing = getSidewalk<MSEdge, MSLane>(ce);
305 if (waitingStage != 0 && wa !=
nullptr) {
307 waypoints.push_back({waitingStage, wa->
getLanes()[0], {}, {}});
309 const MSLane*
const prevLane = getSidewalk<MSEdge, MSLane>(prev);
312 if (crossing->
getShape().front().distanceSquaredTo(startPos) < crossing->
getShape().back().distanceSquaredTo(startPos)) {
313 if (crossingWait->second.first == 0) {
316 waitingStage = crossingWait->second.first;
318 if (crossingWait->second.second == 0) {
319 crossingWait->second.second =
addWaitingSet(crossing,
false);
321 waitingStage = crossingWait->second.second;
324 throw ProcessError(
TLF(
"No waiting set for crossing at %.", ce->getID()));
327 if (ce->isWalkingArea()) {
333 waypoints.push_back({waitingStage, lane, {}, {}});
336 const JPS_StageId finalWait = std::get<0>(waypoints.back());
337 waypoints.pop_back();
338 if (!waypoints.empty()) {
339 waypoints.erase(waypoints.begin());
341 waypoints.push_back({finalWait, getSidewalk<MSEdge, MSLane>(stage->
getDestination()), {}, {}});
343#ifdef DEBUG_GRPC_TIMING
346 sumo_jupedsim_api::AddJourneyRequest journeyRequest;
351 journeyRequest.add_stage_ids(waiting);
357 journeyRequest.add_stage_ids(waypoint);
358 if (startingStage == 0) {
359 startingStage = waiting != 0 ? waiting : waypoint;
362 const sumo_jupedsim_api::AddJourneyResponse journeyResponse =
callGrpc(&sumo_jupedsim_api::JuPedSimService::Stub::AddJourney, journeyRequest,
363 TLF(
"Error while adding journey for agent '%': ", person->
getID()));
364 const JPS_JourneyId journeyId = journeyResponse.journey_id();
365#ifdef DEBUG_GRPC_TIMING
371 if (pstate->getPerson() == person) {
376 if (state ==
nullptr) {
377 state =
new PState(
static_cast<MSPerson*
>(person), stage, journeyId, startingStage, waypoints);
379 state->
setPosition(departurePosition.
x(), departurePosition.
y());
384 state->
reinit(stage, journeyId, startingStage, waypoints);
390 sumo_jupedsim_api::SwitchAgentJourneyRequest switchRequest;
391 switchRequest.set_agent_id(state->
getAgentId());
392 switchRequest.set_journey_id(journeyId);
393 switchRequest.set_stage_id(startingStage);
394 callGrpc(&sumo_jupedsim_api::JuPedSimService::Stub::SwitchAgentJourney, switchRequest,
395 TLF(
"Error while switching journey for agent '%': ", person->
getID()));
404 if (pstate->
getLane() !=
nullptr) {
406 peds.erase(std::find(peds.begin(), peds.end(), pstate));
409 if (pstate->
getStage() !=
nullptr) {
418#ifdef DEBUG_GRPC_TIMING
421 sumo_jupedsim_api::IterateRequest iterateRequest;
423 callGrpc(&sumo_jupedsim_api::JuPedSimService::Stub::Iterate, iterateRequest,
TL(
"JuPedSim gRPC Iterate failed: "));
424#ifdef DEBUG_GRPC_TIMING
428#ifdef DEBUG_GRPC_TIMING
431 sumo_jupedsim_api::GetCorePropertiesOfAllAgentsRequest propertiesRequest;
432 sumo_jupedsim_api::GetCorePropertiesOfAllAgentsResponse propertiesResponse =
433 callGrpc(&sumo_jupedsim_api::JuPedSimService::Stub::GetCorePropertiesOfAllAgents, propertiesRequest,
TL(
"JuPedSim gRPC GetCorePropertiesOfAllAgents failed: "));
434 const auto& properties = propertiesResponse.properties();
435#ifdef DEBUG_GRPC_TIMING
440 PState*
const state = *stateIt;
454 if (stage ==
nullptr) {
464 const auto agentIt = properties.find(state->
getAgentId());
465 if (agentIt == properties.end()) {
469 const sumo_jupedsim_api::Point& pos = agentIt->second.position();
471 const sumo_jupedsim_api::Point& orientation = agentIt->second.orientation();
472 state->
setAngle(atan2(orientation.y(), orientation.x()));
475 Position newPosition(pos.x(), pos.y());
478 const double oldLanePos = state->
getEdgePos(time);
480 double bestDistance = std::numeric_limits<double>::max();
481 MSLane* candidateLane =
nullptr;
482 double candidateLaneLongitudinalPosition = 0.0;
485 forwardRoute, 0, person->
getVClass(),
true, bestDistance, &candidateLane, candidateLaneLongitudinalPosition, routeOffset);
488 if (candidateLane != state->
getLane()) {
489 if (state->
getLane() !=
nullptr) {
491 peds.erase(std::find(peds.begin(), peds.end(), state));
501 const bool arrived = stage->
moveToNextEdge(person, time, 1,
nullptr);
507 sumo_jupedsim_api::SetDesiredSpeedRequest desiredSpeedRequest;
508 auto speeds = desiredSpeedRequest.mutable_desired_speeds();
510#ifdef DEBUG_GRPC_TIMING
513 callGrpc(&sumo_jupedsim_api::JuPedSimService::Stub::SetDesiredSpeedOfAgents, desiredSpeedRequest,
514 TLF(
"Error while setting desired speed for %: ", person->
getID()));
515#ifdef DEBUG_GRPC_TIMING
519 const double speed = person->
getSpeed();
520 for (
int offset = 0; offset < 2; offset++) {
522 if (waypoint !=
nullptr && std::get<0>(*waypoint) != 0) {
523 const JPS_StageId waitingStage = std::get<0>(*waypoint);
525 const MSLane*
const crossing = crossingState.first;
535 const double passingClearanceTime = person->
getFloatParam(
"pedestrian.timegap-crossing");
537 person->
getImpatience(), speed, 0, 0,
nullptr,
false, person);
538 if (open != crossingState.second) {
539 sumo_jupedsim_api::SetWaitingSetStateRequest waitingSetStateRequest;
540 waitingSetStateRequest.set_stage_id(waitingStage);
541 waitingSetStateRequest.set_state(open ? sumo_jupedsim_api::INACTIVE : sumo_jupedsim_api::ACTIVE);
542 callGrpc(&sumo_jupedsim_api::JuPedSimService::Stub::SetWaitingSetState, waitingSetStateRequest,
543 TLF(
"Error while setting waiting status for %:", crossing->
getID()));
544 crossingState.second = open;
551 const double slack = person->
getMaxSpeed() *
TS / 2. + POSITION_EPS;
570 for (
const auto& area :
myAreas) {
571 sumo_jupedsim_api::GetAgentsInRegionRequest agentsRequest;
572 *agentsRequest.mutable_region() = area->areaBoundary;
573 const sumo_jupedsim_api::AgentIdsResponse agentsResponse =
callGrpc(&sumo_jupedsim_api::JuPedSimService::Stub::GetAgentsInRegion,
574 agentsRequest,
TL(
"Error while retrieving agents in area: "));
575 const int numAgents = agentsResponse.agent_ids_size();
576 if (numAgents == 0) {
579 if (area->areaType ==
"vanishing_area") {
580 const SUMOTime period = area->params.count(
"period") > 0 ?
string2time(area->params.at(
"period")) : 1000;
581 const int nbrPeriodsCoveringTimestep = (int)ceil(
TS /
STEPS2TIME(period));
582 if (time - area->lastRemovalTime >= nbrPeriodsCoveringTimestep * period) {
583 for (
int k = 0; k <
MIN2(nbrPeriodsCoveringTimestep, numAgents); k++) {
584 const JPS_AgentId agentID = agentsResponse.agent_ids(k);
585 auto lambda = [agentID](
const PState *
const p) {
586 return p->getAgentId() == agentID;
590 const PState*
const state = *iterator;
595 WRITE_MESSAGEF(
TL(
"Person '%' in vanishing area '%' was removed from the simulation."), person->
getID(), area->id);
599 area->lastRemovalTime = time;
605 if (area->params.count(
"speed") == 0) {
609 sumo_jupedsim_api::SetDesiredSpeedRequest desiredSpeedRequest;
610 auto speeds = desiredSpeedRequest.mutable_desired_speeds();
611 for (
int i = 0; i < numAgents; i++) {
612 (*speeds)[agentsResponse.agent_ids(i)] = newSpeed;
614 callGrpc(&sumo_jupedsim_api::JuPedSimService::Stub::SetDesiredSpeedOfAgents, desiredSpeedRequest,
615 TL(
"Error while setting desired speed for area: "));
621 std::vector<SUMOTrafficObject::NumericalID> allStoppedTrainIDs;
622 std::vector<const MSVehicle*> allStoppedTrains;
623 for (
const auto& stop : stoppingPlaces) {
624 std::vector<const SUMOVehicle*> stoppedTrains = stop.second->getStoppedVehicles();
626 allStoppedTrainIDs.push_back(train->getNumericalID());
627 allStoppedTrains.push_back(
dynamic_cast<const MSVehicle*
>(train));
632 if (!allStoppedTrainIDs.empty()) {
633 std::vector<GEOSGeometry*> carriagePolygons;
634 std::vector<GEOSGeometry*> rampPolygons;
635 for (
const MSVehicle* train : allStoppedTrains) {
636 if (train->getLeavingPersonNumber() > 0) {
640 const std::vector<MSTrainHelper::Carriage*>& carriages = trainHelper.
getCarriages();
642 Position dir = carriage->front - carriage->back;
651 carriageShape.push_back(carriage->front + perp * p);
652 carriageShape.push_back(carriage->back + perp * p);
653 carriageShape.push_back(carriage->back - perp * p);
654 carriageShape.push_back(carriage->front - perp * p);
659 for (
const Position& door : carriage->doorPositions) {
661 rampShape.push_back(door - perp * p + dir * d);
662 rampShape.push_back(door - perp * p - dir * d);
663 rampShape.push_back(door + perp * p - dir * d);
664 rampShape.push_back(door + perp * p + dir * d);
670 if (!carriagePolygons.empty()) {
671 GEOSGeometry* carriagesCollection = GEOSGeom_createCollection(GEOS_MULTIPOLYGON, carriagePolygons.data(), (
unsigned int)carriagePolygons.size());
672 GEOSGeometry* rampsCollection = GEOSGeom_createCollection(GEOS_MULTIPOLYGON, rampPolygons.data(), (
unsigned int)rampPolygons.size());
673 GEOSGeometry* carriagesAndRampsUnion = GEOSUnion(carriagesCollection, rampsCollection);
674 if (carriagesAndRampsUnion ==
nullptr) {
678#ifdef DEBUG_GEOMETRY_GENERATION
681 int nbrComponents = 0;
682 double maxArea = 0.0;
683 double totalArea = 0.0;
684 const GEOSGeometry* pedestrianNetworkWithTrainsAndRampsLargestComponent =
getLargestComponent(pedestrianNetworkWithTrainsAndRamps, nbrComponents, maxArea, totalArea);
685 if (nbrComponents > 1) {
686 WRITE_WARNINGF(
TL(
"While generating geometry % connected components were detected, %% of total pedestrian area is covered by the largest."),
687 nbrComponents, maxArea / totalArea * 100.0,
"%");
689#ifdef DEBUG_GEOMETRY_GENERATION
693 sumo_jupedsim_api::SwitchGeometryRequest switchRequest;
695 callGrpc(&sumo_jupedsim_api::JuPedSimService::Stub::SwitchGeometry, switchRequest,
TL(
"While switching to train geometry: "),
true);
698 GEOSGeom_destroy(pedestrianNetworkWithTrainsAndRamps);
700 GEOSGeom_destroy(rampsCollection);
701 GEOSGeom_destroy(carriagesCollection);
705 sumo_jupedsim_api::SwitchGeometryRequest switchRequest;
707 callGrpc(&sumo_jupedsim_api::JuPedSimService::Stub::SwitchGeometry, switchRequest,
TL(
"While switching to default geometry: "),
true);
721 sumo_jupedsim_api::RemoveAgentsRequest removeRequest;
722 removeRequest.add_agent_ids(agentID);
723#ifdef DEBUG_GRPC_TIMING
726 callGrpc(&sumo_jupedsim_api::JuPedSimService::Stub::RemoveAgents, removeRequest,
TL(
"Error while removing agent: "));
727#ifdef DEBUG_GRPC_TIMING
742 GEOSGeometry* lineString = GEOSGeom_createLineString(coordinateSequence);
744 GEOSGeom_destroy(lineString);
745 return dilatedLineString;
752 if (shape.size() == 1) {
753 WRITE_WARNINGF(
TL(
"Polygon '%' at junction '%' will be skipped as it is just a point."), shapeID, junctionID);
757 if (shape.back() != shape.front()) {
758 shape.push_back(shape.front());
762 cleanShape.push_back(shape[0]);
764 for (
int i = 1; i < (int)shape.size(); i++) {
765 if (shape[i] != shape[i - 1]) {
766 cleanShape.push_back(shape[i]);
768 duplicates.push_back(shape[i]);
771 if (cleanShape.size() < shape.size()) {
772 WRITE_WARNINGF(
TL(
"Polygon '%' at junction '%' had some equal consecutive points removed: %"), shapeID, junctionID,
toString(duplicates, 9));
775 GEOSGeometry* linearRing = GEOSGeom_createLinearRing(coordinateSequence);
776 GEOSGeometry* polygon = GEOSGeom_createPolygon(linearRing,
nullptr, 0);
778 if (!GEOSisValid(polygon)) {
779 if (cleanShape.size() == 3) {
780 if (isInternalShape) {
781 WRITE_WARNINGF(
TL(
"Polygon '%' at junction '%' has been dilated as it is just a segment."), shapeID, junctionID);
783 WRITE_WARNINGF(
TL(
"Polygon '%' has been dilated as it is just a segment."), shapeID);
785 GEOSGeometry* lineString = GEOSGeom_createLineString(GEOSCoordSeq_clone(coordinateSequence));
786 GEOSGeom_destroy(polygon);
788 GEOSGeom_destroy(lineString);
790 if (isInternalShape) {
791 WRITE_WARNINGF(
TL(
"Polygon '%' at junction '%' has been replaced by its convex hull as it is not simple."), shapeID, junctionID);
792 GEOSGeometry* hull = GEOSConvexHull(polygon);
793 GEOSGeom_destroy(polygon);
796 WRITE_WARNINGF(
TL(
"Polygon '%' at junction '%' will be skipped as it is not simple."), shapeID, junctionID);
805 if (isInternalShape) {
818 GEOSGeom_destroy(old);
825 for (
int i = 0; i < maxIter; i++) {
826 g =
checkGeometry(g, GEOSTopologyPreserveSimplify(g, d / 2.));
830 GEOSMinimumClearance(g, &clearance);
831 if (clearance >= d) {
834 g =
checkGeometry(g, GEOSBufferWithStyle(g, -d / 2., 8, GEOSBUF_CAP_FLAT, GEOSBUF_JOIN_MITRE, 5.0));
835 g =
checkGeometry(g, GEOSBufferWithStyle(g, d / 2., 8, GEOSBUF_CAP_FLAT, GEOSBUF_JOIN_MITRE, 5.0));
843 std::vector<GEOSGeometry*> walkableAreas;
845 const MSLane*
const lane = getSidewalk<MSEdge, MSLane>(edge);
846 if (lane !=
nullptr) {
847 GEOSGeometry* dilatedLane =
nullptr;
848 if (edge->isWalkingArea()) {
850 }
else if (edge->isCrossing()) {
852 if (outlineShape !=
nullptr) {
855 if (dilatedLane !=
nullptr) {
856 walkableAreas.push_back(dilatedLane);
866 if (dilatedLane !=
nullptr) {
867 walkableAreas.push_back(dilatedLane);
872 const MSJunction*
const junction = junctionWithID.second;
873 int pedEdgeCount = 0;
874 bool hasWalkingArea =
false;
878 for (
const MSEdge*
const edge : edges) {
879 if (edge->isWalkingArea()) {
880 hasWalkingArea =
true;
883 if (getSidewalk<MSEdge, MSLane>(edge) !=
nullptr) {
887 if (hasWalkingArea) {
891 if (!hasWalkingArea && pedEdgeCount > 1) {
894 if (walkingAreaGeom !=
nullptr) {
895 walkableAreas.push_back(walkingAreaGeom);
901 std::vector<GEOSGeometry*> additionalObstacles;
903 if (polygonWithID.second->getShapeType() ==
"jupedsim.walkable_area" || polygonWithID.second->getShapeType() ==
"taz") {
904 GEOSGeometry* walkableArea =
createGeometryFromShape(polygonWithID.second->getShape(), std::string(
""), polygonWithID.first);
905 if (walkableArea !=
nullptr) {
906 walkableAreas.push_back(walkableArea);
909 }
else if (polygonWithID.second->getShapeType() ==
"jupedsim.obstacle") {
910 GEOSGeometry* additionalObstacle =
createGeometryFromShape(polygonWithID.second->getShape(), std::string(
""), polygonWithID.first);
911 if (additionalObstacle !=
nullptr) {
912 additionalObstacles.push_back(additionalObstacle);
918 GEOSGeometry* disjointWalkableAreas = GEOSGeom_createCollection(GEOS_MULTIPOLYGON, walkableAreas.data(), (
unsigned int)walkableAreas.size());
919#ifdef DEBUG_GEOMETRY_GENERATION
922 GEOSGeometry* initialWalkableAreas = GEOSUnaryUnion(disjointWalkableAreas);
923#ifdef DEBUG_GEOMETRY_GENERATION
924 dumpGeometry(initialWalkableAreas,
"initialWalkableAreas.wkt");
926 GEOSGeom_destroy(disjointWalkableAreas);
929 GEOSGeometry* disjointAdditionalObstacles = GEOSGeom_createCollection(GEOS_MULTIPOLYGON, additionalObstacles.data(), (
unsigned int)additionalObstacles.size());
930#ifdef DEBUG_GEOMETRY_GENERATION
933 GEOSGeometry* additionalObstaclesUnion = GEOSUnaryUnion(disjointAdditionalObstacles);
934#ifdef DEBUG_GEOMETRY_GENERATION
935 dumpGeometry(additionalObstaclesUnion,
"additionalObstaclesUnion.wkt");
937 GEOSGeometry* finalWalkableAreas = GEOSDifference(initialWalkableAreas, additionalObstaclesUnion);
938#ifdef DEBUG_GEOMETRY_GENERATION
939 dumpGeometry(finalWalkableAreas,
"finalWalkableAreas.wkt");
941 GEOSGeom_destroy(initialWalkableAreas);
942 GEOSGeom_destroy(additionalObstaclesUnion);
943 GEOSGeom_destroy(disjointAdditionalObstacles);
945 if (!GEOSisSimple(finalWalkableAreas)) {
946 throw ProcessError(
TL(
"Union of walkable areas minus union of obstacles is not a simple polygon."));
951 return finalWalkableAreas;
957 GEOSCoordSequence* coordinateSequence = GEOSCoordSeq_create((
unsigned int)shape.size(), 2);
958 for (
int i = 0; i < (int)shape.size(); i++) {
959 GEOSCoordSeq_setX(coordinateSequence, i, shape[i].x());
960 GEOSCoordSeq_setY(coordinateSequence, i, shape[i].y());
962 return coordinateSequence;
969 const GEOSCoordSequence* coordinateSequence = GEOSGeom_getCoordSeq(geometry);
970 unsigned int coordinateSequenceSize;
971 GEOSCoordSeq_getSize(coordinateSequence, &coordinateSequenceSize);
974 for (
unsigned int i = 0; i < coordinateSequenceSize; i++) {
975 GEOSCoordSeq_getX(coordinateSequence, i, &x);
976 GEOSCoordSeq_getY(coordinateSequence, i, &y);
977 coordinateVector.push_back(
Position(x, y));
979 return coordinateVector;
985 const GEOSCoordSequence* coordinateSequence = GEOSGeom_getCoordSeq(geometry);
986 unsigned int coordinateSequenceSize;
987 GEOSCoordSeq_getSize(coordinateSequence, &coordinateSequenceSize);
991 for (
unsigned int i = 0; i < coordinateSequenceSize - 1; i++) {
992 GEOSCoordSeq_getX(coordinateSequence, i, &x);
993 GEOSCoordSeq_getY(coordinateSequence, i, &y);
994 sumo_jupedsim_api::Point* point = into->add_points();
1004 GEOSGeometry* linearRingAsPolygon = GEOSGeom_createPolygon(GEOSGeom_clone(linearRing),
nullptr, 0);
1005 GEOSArea(linearRingAsPolygon, &area);
1006 GEOSGeom_destroy(linearRingAsPolygon);
1019 const GEOSGeometry* exterior = GEOSGetExteriorRing(polygon);
1023 std::vector<PositionVector> holes;
1024 int nbrInteriorRings = GEOSGetNumInteriorRings(polygon);
1025 if (nbrInteriorRings != -1) {
1026 for (
int k = 0; k < nbrInteriorRings; k++) {
1027 const GEOSGeometry* linearRing = GEOSGetInteriorRingN(polygon, k);
1041 nbrComponents = GEOSGetNumGeometries(polygon);
1042 const GEOSGeometry* largestComponent =
nullptr;
1045 for (
int i = 0; i < nbrComponents; i++) {
1046 const GEOSGeometry* componentPolygon = GEOSGetGeometryN(polygon, i);
1048 GEOSArea(componentPolygon, &area);
1050 if (area > maxArea) {
1052 largestComponent = componentPolygon;
1055 return largestComponent;
1061 sumo_jupedsim_api::CreateGeometryRequest geometryRequest;
1062 sumo_jupedsim_api::Polygon* boundary = geometryRequest.mutable_boundary();
1065 const GEOSGeometry* exterior = GEOSGetExteriorRing(polygon);
1069 int nbrInteriorRings = GEOSGetNumInteriorRings(polygon);
1070 if (nbrInteriorRings != -1) {
1071 for (
int k = 0; k < nbrInteriorRings; k++) {
1072 const GEOSGeometry* linearRing = GEOSGetInteriorRingN(polygon, k);
1075 sumo_jupedsim_api::Polygon* hole = geometryRequest.add_obstacles();
1080 grpc::ClientContext geometryContext;
1081 sumo_jupedsim_api::CreateGeometryResponse geometryResponse;
1082 const grpc::Status geometryStatus =
myGrpcStub->CreateGeometry(&geometryContext, geometryRequest, &geometryResponse);
1083 if (!geometryStatus.ok()) {
1084 WRITE_WARNINGF(
TL(
"JuPedSim gRPC CreateGeometry failed: %"), geometryStatus.error_message());
1088 return geometryResponse.geometry_id();
1093 GEOSGeometry* polygonGeoCoordinates =
nullptr;
1094 if (useGeoCoordinates) {
1095 const GEOSGeometry* exterior = GEOSGetExteriorRing(polygon);
1097 for (
Position& position : exteriorPoints) {
1100 const int nbrInteriorRings = GEOSGetNumInteriorRings(polygon);
1101 std::vector<GEOSGeometry*> holeRings;
1102 if (nbrInteriorRings != -1) {
1103 for (
int k = 0; k < nbrInteriorRings; k++) {
1104 const GEOSGeometry* linearRing = GEOSGetInteriorRingN(polygon, k);
1106 for (
Position& position : holePoints) {
1110 GEOSGeometry* holeRing = GEOSGeom_createLinearRing(holeRingCoords);
1111 holeRings.push_back(holeRing);
1115 GEOSGeometry* exteriorRing = GEOSGeom_createLinearRing(exteriorRingCoords);
1116 polygonGeoCoordinates = GEOSGeom_createPolygon(exteriorRing, holeRings.data(), nbrInteriorRings);
1118 std::ofstream dumpFile;
1119 dumpFile.open(filename);
1120 GEOSWKTWriter* writer = GEOSWKTWriter_create();
1122 char* wkt = GEOSWKTWriter_write(writer, polygonGeoCoordinates ==
nullptr ? polygon : polygonGeoCoordinates);
1123 dumpFile << wkt << std::endl;
1126 GEOSWKTWriter_destroy(writer);
1127 GEOSGeom_destroy(polygonGeoCoordinates);
1142 const double offset = 2 * radius + POSITION_EPS;
1143 const double lonOffset = entry ? NUMERICAL_EPS : shape.
length() - NUMERICAL_EPS;
1146 for (
double latOff = offset; latOff < crossing->
getWidth() / 2. - offset; latOff += offset) {
1154 pv.push_back(crossing->
getIncomingLanes().front().lane->getShape().getCentroid());
1156 if (!entry && crossing->
getLinkCont().size() == 1 && crossing->
getLinkCont().front()->getLane()->isWalkingArea()) {
1157 pv.push_back(crossing->
getLinkCont().front()->getLane()->getShape().getCentroid());
1160 sumo_jupedsim_api::AddWaitingSetStageRequest waitingSetRequest;
1162 GEOSCoordSequence* seq = GEOSCoordSeq_create(1, 2);
1163 GEOSCoordSeq_setX(seq, 0, p.x());
1164 GEOSCoordSeq_setY(seq, 0, p.y());
1165 GEOSGeometry* geosPoint = GEOSGeom_createPoint(seq);
1167 sumo_jupedsim_api::Point* point = waitingSetRequest.add_points();
1168 point->set_x(p.x());
1169 point->set_y(p.y());
1171 WRITE_WARNINGF(
"Waiting point %,% is not in the geometry for % on '%'.", p.x(), p.y(), entry ?
"entry" :
"exit", crossing->
getID())
1173 GEOSGeom_destroy(geosPoint);
1175#ifdef DEBUG_GRPC_TIMING
1178 auto waitingSetResponse =
callGrpc(&sumo_jupedsim_api::JuPedSimService::Stub::AddWaitingSetStage, waitingSetRequest,
1179 TLF(
"Error while adding waiting set for % on '%':", entry ?
"entry" :
"exit", crossing->
getID()));
1180#ifdef DEBUG_GRPC_TIMING
1183 JPS_StageId waitingStage = waitingSetResponse.stage_id();
1185 sumo_jupedsim_api::SetWaitingSetStateRequest waitingSetStateRequest;
1186 waitingSetStateRequest.set_stage_id(waitingStage);
1187 waitingSetStateRequest.set_state(sumo_jupedsim_api::INACTIVE);
1188 callGrpc(&sumo_jupedsim_api::JuPedSimService::Stub::SetWaitingSetState, waitingSetStateRequest,
1189 TLF(
"Error while setting waiting status for % on '%':", entry ?
"entry" :
"exit", crossing->
getID()));
1192 return waitingStage;
1198 initGEOS(
nullptr,
nullptr);
1201 int nbrComponents = 0;
1202 double maxArea = 0.0;
1203 double totalArea = 0.0;
1205 if (nbrComponents > 1) {
1206 WRITE_WARNINGF(
TL(
"While generating geometry % connected components were detected, %% of total pedestrian area is covered by the largest."),
1207 nbrComponents, maxArea / totalArea * 100.0,
"%");
1209#ifdef DEBUG_GEOMETRY_GENERATION
1212 const std::string filename = oc.
getString(
"pedestrian.jupedsim.wkt");
1213 if (!filename.empty()) {
1222 double strengthGeometryRepulsion = oc.
getFloat(
"pedestrian.jupedsim.strength-geometry-repulsion");
1223 double rangeGeometryRepulsion = oc.
getFloat(
"pedestrian.jupedsim.range-geometry-repulsion");
1225 if (oc.
isDefault(
"pedestrian.jupedsim.strength-geometry-repulsion") && oc.
isDefault(
"pedestrian.jupedsim.range-geometry-repulsion")) {
1226 WRITE_MESSAGE(
TL(
"Adapting geometry repulsion default values for jupedsim timestep of 0.02."));
1227 strengthGeometryRepulsion = 35.;
1228 rangeGeometryRepulsion = 0.019;
1231 sumo_jupedsim_api::CreateSimulationRequest simulationRequest;
1233 simulationRequest.set_model_class(
myJPSModel);
1237 auto& modelParams = *simulationRequest.mutable_model_parameters()->mutable_fields();
1238 if (
myJPSModel ==
"CollisionFreeSpeedModel") {
1239 modelParams[
"strength_neighbor_repulsion"].set_number_value(oc.
getFloat(
"pedestrian.jupedsim.strength-neighbor-repulsion"));
1240 modelParams[
"range_neighbor_repulsion"].set_number_value(oc.
getFloat(
"pedestrian.jupedsim.range-neighbor-repulsion"));
1241 modelParams[
"strength_geometry_repulsion"].set_number_value(strengthGeometryRepulsion);
1242 modelParams[
"range_geometry_repulsion"].set_number_value(rangeGeometryRepulsion);
1243 }
else if (
myJPSModel ==
"CollisionFreeSpeedModelV2") {
1245 }
else if (
myJPSModel ==
"GeneralizedCentrifugalForceModel") {
1246 if (oc.
isDefault(
"pedestrian.jupedsim.strength-neighbor-repulsion")) {
1247 modelParams[
"strength_neighbor_repulsion"].set_number_value(0.3);
1249 modelParams[
"strength_neighbor_repulsion"].set_number_value(oc.
getFloat(
"pedestrian.jupedsim.strength-neighbor-repulsion"));
1251 if (oc.
isDefault(
"pedestrian.jupedsim.strength-geometry-repulsion")) {
1252 strengthGeometryRepulsion = 0.2;
1254 modelParams[
"strength_geometry_repulsion"].set_number_value(strengthGeometryRepulsion);
1255 }
else if (
myJPSModel ==
"SocialForceModel") {
1256 modelParams[
"body_force"].set_number_value(120000.0);
1257 modelParams[
"friction"].set_number_value(240000.0);
1259 grpc::ClientContext simulationContext;
1260 sumo_jupedsim_api::CreateSimulationResponse simulationResponse;
1261 const grpc::Status simulationStatus =
myGrpcStub->CreateSimulation(&simulationContext, simulationRequest, &simulationResponse);
1262 if (simulationStatus.ok()) {
1265 throw ProcessError(
TLF(
"JuPedSim gRPC CreateSimulation failed: %", simulationStatus.error_message()));
1280 for (
auto areaIt =
myAreas.begin(); areaIt !=
myAreas.end(); ++areaIt) {
1281 if (poly->
getID() == (*areaIt)->id) {
1282 lastRemovalTime = (*areaIt)->lastRemovalTime;
1289 sumo_jupedsim_api::Polygon areaBoundary;
1291 sumo_jupedsim_api::Point* point = areaBoundary.add_points();
1292 point->set_x(p.x());
1293 point->set_y(p.y());
1311 const std::vector<WaypointDesc>& waypoints) :
1313 myJourneyId(journeyId), myStageId(stageId), myWaypoints(waypoints), myAgentId(0) {
1320 const std::vector<WaypointDesc>& waypoints) {
1321 if (myStage !=
nullptr) {
1322 myStage->setPState(
nullptr);
1325 myJourneyId = journeyId;
1326 myStageId = stageId;
1327 myWaypoints = waypoints;
1341 myRemoteXYPos.set(x, y, z);
1352 return offset < (int)myWaypoints.size() ? &myWaypoints[offset] :
nullptr;
std::vector< const MSEdge * > ConstMSEdgeVector
static GEOSGeometry * checkGeometry(GEOSGeometry *old, GEOSGeometry *g)
static GEOSGeometry * simplifyMinDist(GEOSGeometry *g, double d, int maxIter)
#define WRITE_WARNINGF(...)
#define WRITE_MESSAGEF(...)
#define WRITE_MESSAGE(msg)
#define WRITE_WARNING(msg)
#define PROGRESS_DONE_MESSAGE()
#define PROGRESS_BEGIN_MESSAGE(msg)
SUMOTime string2time(const std::string &r)
convert string to SUMOTime
std::string time2string(SUMOTime t, bool humanReadable)
convert SUMOTime to string (independently of global format setting)
const std::string DEFAULT_PEDTYPE_ID
@ RANDOM_LOCATION
The position may be chosen freely in a polygon defined by a taz.
@ SUMO_TAG_BUS_STOP
A bus stop.
const double SUMO_const_laneWidth
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
A class that stores a 2D geometrical boundary.
double ymin() const
Returns minimum y-coordinate.
double xmin() const
Returns minimum x-coordinate.
double ymax() const
Returns maximum y-coordinate.
double xmax() const
Returns maximum x-coordinate.
static const GeoConvHelper & getFinal()
the coordinate transformation for writing the location element and for tracking the original coordina...
void cartesian2geo(Position &cartesian) const
Converts the given cartesian (shifted) position to its geo (lat/long) representation.
const MSEdgeVector & getEdges() const
Returns loaded edges.
A road/street connecting two junctions.
const std::vector< MSLane * > & getLanes() const
Returns this edge's lanes.
bool isNormal() const
return whether this edge is an internal edge
const MSJunction * getToJunction() const
double getLength() const
return the length of the edge
const MSJunction * getFromJunction() const
bool isTazConnector() const
double getWidth() const
Returns the edges's width (sum over all lanes)
virtual void addEvent(Command *operation, SUMOTime execTimeStep=-1)
Adds an Event.
The base class for an intersection.
const ConstMSEdgeVector & getOutgoing() const
const PositionVector & getShape() const
Returns this junction's shape.
const ConstMSEdgeVector & getIncoming() const
Representation of a lane in the micro simulation.
const MSLink * getLinkTo(const MSLane *const) const
returns the link to the given lane or nullptr, if it is not connected
double getSpeedLimit() const
Returns the lane's maximum allowed speed.
bool isWalkingArea() const
const std::vector< IncomingLaneInfo > & getIncomingLanes() const
MSLane * getLogicalPredecessorLane() const
get the most likely predecessor lane (sorted using by_connections_to_sorter). The result is cached in...
virtual const PositionVector & getShape(bool) const
MSEdge & getEdge() const
Returns the lane's edge.
const PositionVector * getOutlineShape() const
double getWidth() const
Returns the lane's width.
const std::vector< MSLink * > & getLinkCont() const
returns the container with all links !!!
bool opened(SUMOTime arrivalTime, double arrivalSpeed, double leaveSpeed, double vehicleLength, double impatience, double decel, SUMOTime waitingTime, double posLat=0, BlockingFoes *collectFoes=nullptr, bool ignoreRed=false, const SUMOTrafficObject *ego=nullptr, double dist=-1) const
Returns the information whether the link may be passed.
const MSTrafficLightLogic * getTLLogic() const
Returns the TLS index.
The simulated network and simulation perfomer.
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
MSEventControl * getBeginOfTimestepEvents()
Returns the event control for events executed at the begin of a time step.
MSJunctionControl & getJunctionControl()
Returns the junctions control.
MSPedestrianRouter & getPedestrianRouter(int rngIndex, const Prohibitions &prohibited={}) const
SUMOTime getCurrentTimeStep() const
Returns the current simulation step.
ShapeContainer & getShapeContainer()
Returns the shapes container.
MSEdgeControl & getEdgeControl()
Returns the edge control.
const NamedObjectCont< MSStoppingPlace * > & getStoppingPlaces(SumoXMLTag category) const
ActiveLanes myActiveLanes
store of all lanes which have pedestrians on them
int myNumActivePedestrians
the total number of active pedestrians
Container for pedestrian state and individual position update function.
MSStageMoving * getStage() const
return the current stage
int myDir
the walking direction on the current lane (1 forward, -1 backward)
virtual double getAngle(const MSStageMoving &, SUMOTime) const
return the current orientation in degrees
double getEdgePos(SUMOTime) const
abstract methods inherited from MSTransportableStateAdapter
MSPerson * getPerson() const
return the represented person
bool isWaitingToEnter() const
whether the person still waits to entere the network
const MSLane * getLane() const
the current lane of the transportable
double getSpeed() const
return the current speed of the transportable, we need to be able to do this for vehicles as well,...
Holds pedestrian state and performs updates.
JPS_StageId getStageId() const
first stage of the journey
void setAngle(double angle)
void setLane(MSLane *lane)
JPS_AgentId getAgentId() const
void setStage(MSStageMoving *const stage)
void setAgentId(JPS_AgentId id)
const MSPModel_JuPedSim::WaypointDesc * getNextWaypoint(const int offset=0) const
bool advanceNextWaypoint()
void setLanePosition(double lanePosition)
const MSEdge * getNextEdge(const MSStageMoving &stage) const override
return the list of internal edges if the transportable is on an intersection
JPS_JourneyId getJourneyId() const
PState(MSPerson *person, MSStageMoving *stage, JPS_JourneyId journeyId, JPS_StageId stageId, const std::vector< WaypointDesc > &waypoints)
void reinit(MSStageMoving *stage, JPS_JourneyId journeyId, JPS_StageId stageId, const std::vector< WaypointDesc > &waypoints)
Position getPosition(const MSStageMoving &, SUMOTime) const override
return the network coordinate of the transportable
void setPosition(const double x, const double y, const double z=0.)
int64_t buildJPSGeometryFromGEOSGeometry(const GEOSGeometry *polygon)
MSTransportableStateAdapter * add(MSTransportable *person, MSStageMoving *stage, SUMOTime now) override
register the given person as a pedestrian
void removePolygonFromDrawing(const std::string &polygonId)
const GEOSGeometry * myGEOSPedestrianNetworkLargestComponent
The GEOS polygon representing the largest (by area) connected component of the pedestrian network.
void preparePolygonForDrawing(const GEOSGeometry *polygon, const std::string &polygonId, const RGBColor &color)
static const RGBColor PEDESTRIAN_NETWORK_CARRIAGES_AND_RAMPS_COLOR
MSPModel_JuPedSim(const OptionsCont &oc, MSNet *net)
static const double GEOS_MITRE_LIMIT
const double myExitTolerance
Threshold to decide if a pedestrian has ended its journey or not.
std::vector< SUMOTrafficObject::NumericalID > myAllStoppedTrainIDs
Array of stopped trains, used to detect whether to add carriages and ramps to the geometry.
void registerArrived(const JPS_AgentId agentID)
static GEOSGeometry * createGeometryFromCenterLine(PositionVector centerLine, double width, int capStyle)
static PositionVector convertToSUMOPoints(const GEOSGeometry *geometry)
static const std::string PEDESTRIAN_NETWORK_CARRIAGES_AND_RAMPS_ID
static const RGBColor PEDESTRIAN_NETWORK_COLOR
static const std::string PEDESTRIAN_NETWORK_ID
std::map< const MSLane *, JPS_StageId, ComparatorNumericalIdLess > myLaneCenters
static GEOSGeometry * createGeometryFromShape(PositionVector shape, std::string junctionID=std::string(""), std::string shapeID=std::string(""), bool isInternalShape=false)
static GEOSCoordSequence * convertToGEOSPoints(PositionVector shape)
int64_t myJPSGeometry
The JPS polygon representing the largest connected component of the pedestrian network.
GEOSGeometry * myGEOSPedestrianNetwork
The GEOS polygon containing all computed connected components of the pedestrian network.
static void convertToJPSPoints(const GEOSGeometry *geometry, sumo_jupedsim_api::Polygon *into)
static void dumpGeometry(const GEOSGeometry *polygon, const std::string &filename, bool useGeoCoordinates=false)
bool myHaveAdditionalWalkableAreas
std::map< const MSLane *, std::pair< JPS_StageId, JPS_StageId >, ComparatorNumericalIdLess > myCrossingWaits
const SUMOTime myJPSDeltaT
Timestep used in the JuPedSim simulator.
MSNet *const myNetwork
The network on which the simulation runs.
std::shared_ptr< grpc::Channel > myGrpcChannel
void polygonChanged(const SUMOPolygon *const poly, const bool added, const bool removed) override
static const double GEOS_MIN_AREA
void initialize(const OptionsCont &oc)
GEOSGeometry * buildPedestrianNetwork(MSNet *network)
void remove(MSTransportableStateAdapter *state) override
remove the specified person from the pedestrian simulation
std::vector< StopWatch< std::chrono::nanoseconds > > myStopWatch
std::vector< std::unique_ptr< AreaData > > myAreas
Array of special areas.
static double getLinearRingArea(const GEOSGeometry *linearRing)
std::unique_ptr< sumo_jupedsim_api::JuPedSimService::Stub > myGrpcStub
SumoRNG myRNG
The random number generator for fluctuations on insertion.
std::tuple< JPS_StageId, const MSLane *, Position, double > WaypointDesc
void clearState() override
Resets pedestrians when quick-loading state.
Response callGrpc(grpc::Status(sumo_jupedsim_api::JuPedSimService::Stub::*method)(grpc::ClientContext *, const Request &, Response *), Request &request, const std::string &what, const bool warnOnly=false)
ShapeContainer & myShapeContainer
The shape container used to add polygons to the rendering pipeline.
std::vector< PState * > myPedestrianStates
JPS_StageId addWaitingSet(const MSLane *const crossing, const bool entry)
int64_t myJPSGeometryWithTrainsAndRamps
The JPS polygon representing the largest connected component plus carriages and ramps.
static const int GEOS_QUADRANT_SEGMENTS
static const std::vector< MSPModel_JuPedSim::PState * > noPedestrians
static const GEOSGeometry * getLargestComponent(const GEOSGeometry *polygon, int &nbrComponents, double &maxArea, double &totalArea)
static double getRadius(const MSVehicleType &vehType)
JPS_StageId addWaypoint(const std::string &agentID, WaypointDesc &waypoint, const MSStageMoving *const finalStage)
void tryPedestrianInsertion(PState *state, const Position &p)
SUMOTime execute(SUMOTime time)
static const double GEOS_BUFFERED_SEGMENT_WIDTH
std::map< JPS_StageId, std::pair< const MSLane *, bool > > myCrossings
static const int BACKWARD
static const double RANDOM_POS_LAT
magic value to encode randomized lateral offset for persons when starting a walk
static const int UNDEFINED_DIRECTION
static const double UNSPECIFIED_POS_LAT
the default lateral offset for persons when starting a walk
double getImpatience() const
const MSEdge * getDestination() const
returns the destination edge
virtual double getArrivalPos() const
virtual const MSEdge * getEdge() const
Returns the current edge.
virtual const MSEdge * getNextRouteEdge() const =0
ConstMSEdgeVector getEdges() const
the edges of the current stage
const std::vector< const MSEdge * > & getRoute() const
void setPState(MSTransportableStateAdapter *pstate)
double getDepartPosLat() const
const MSEdge * getEdge() const
Returns the current edge.
double getDepartPos() const
const std::vector< constMSEdge * >::iterator getRouteStep() const
virtual bool moveToNextEdge(MSTransportable *transportable, SUMOTime currentTime, int prevDir, MSEdge *nextInternal=nullptr, const bool isReplay=false)=0
move forward and return whether the transportable arrived
virtual double getMaxSpeed(const MSTransportable *const transportable=nullptr) const =0
the maximum speed of the transportable
bool moveToNextEdge(MSTransportable *person, SUMOTime currentTime, int prevDir, MSEdge *nextInternal=nullptr, const bool isReplay=false)
move forward and return whether the person arrived
void activateMoveReminders(MSTransportable *person, double oldPos, double newPos, double newSpeed)
void activateEntryReminders(MSTransportable *person, const bool isDepart=false)
add the move reminders for the current lane on entry
A class that helps computing positions of a train's carriages and additional structures.
void computeDoorPositions()
compute door positions on demand and fills the carriage structures
const std::vector< Carriage * > & getCarriages() const
double getHalfWidth() const
virtual double getSpeed() const override
the current speed of the transportable
MSStage * getNextStage(int offset) const
Return the next (or previous) stage denoted by the offset.
int getNumRemainingStages() const
Return the number of remaining stages (including the current)
MSStage * getCurrentStage() const
Return the current stage.
SUMOVehicleClass getVClass() const override
Returns the object's access class.
double getMaxSpeed() const override
Returns the maximum speed (the minimum of desired and physical maximum speed)
const SUMOVTypeParameter & getVTypeParameter() const override
Returns the object's "vehicle" type parameter.
int getCurrentStageIndex() const
Return the index of the current stage.
MSStageType getCurrentStageType() const
the current stage type of the transportable
const SUMOVehicleParameter & getParameter() const override
Returns the vehicle's parameter (including departure definition)
const MSVehicleType & getVehicleType() const override
Returns the object's "vehicle" type.
const MSEdge * getEdge() const override
Returns the current edge.
abstract base class for managing callbacks to retrieve various state information from the model
Representation of a vehicle in the micro simulation.
The car-following model and parameter.
double getWidth() const
Get the width which vehicles of this class shall have when being drawn.
double getLength() const
Get vehicle's length [m].
const std::string & getID() const
Returns the id.
T get(const std::string &id) const
Retrieves an item.
A storage for options typed value containers)
bool isSet(const std::string &name, bool failOnNonExistant=true) const
Returns the information whether the named option is set.
double getFloat(const std::string &name) const
Returns the double-value of the named option (only for Option_Float)
std::string getString(const std::string &name) const
Returns the string-value of the named option (only for Option_String)
bool isDefault(const std::string &name) const
Returns the information whether the named option has still the default value.
bool getBool(const std::string &name) const
Returns the boolean-value of the named option (only for Option_Bool)
static OptionsCont & getOptions()
Retrieves the options.
double getDouble(const std::string &key, const double defaultValue) const
Returns the value for a given key converted to a double.
virtual const std::string getParameter(const std::string &key, const std::string defaultValue="") const
Returns the value for a given key.
const Parameterised::Map & getParametersMap() const
Returns the inner key/value map.
double compute(const E *from, const E *to, double departPos, double arrivalPos, double speed, SUMOTime msTime, const N *onlyNode, const SUMOVTypeParameter &pars, std::vector< const E * > &into, bool allEdges=false) const
Builds the route between the given edges using the minimum effort at the given time The definition of...
A point in 2D or 3D with translation and scaling methods.
void setx(double x)
set position x
static const Position INVALID
used to indicate that a position is valid
double distanceTo2D(const Position &p2) const
returns the euclidean distance in the x-y-plane
void norm2D()
Normalizes the given vector.
double x() const
Returns the x-position.
double length2D() const
Computes the length of the given vector neglecting the z coordinate.
void sety(double y)
set position y
double y() const
Returns the y-position.
double length() const
Returns the length.
double rotationAtOffset(double pos) const
Returns the rotation at the given length.
Position positionAtOffset(double pos, double lateralOffset=0) const
Returns the position at the given length.
void move2side(double amount, double maxExtension=100)
move position vector to side using certain amount
Boundary getBoxBoundary() const
Returns a boundary enclosing this list of lines.
Position getCentroid() const
Returns the centroid (closes the polygon if unclosed)
void extrapolate2D(const double val, const bool onlyFirst=false)
extrapolate position vector in two dimensions (Z is ignored)
bool around(const Position &p, double offset=0) const
Returns the information whether the position vector describes a polygon lying around the given point.
static double rand(SumoRNG *rng=nullptr)
Returns a random real number in [0, 1)
const PositionVector & getShape() const
Returns the shape of the polygon.
virtual void setHoles(const std::vector< PositionVector > &holes)
Sets the holes of the polygon.
double getFloatParam(const std::string ¶mName, const bool required=false, const double deflt=INVALID_DOUBLE, bool checkDist=true) const
Retrieve a floating point parameter for the traffic object.
Structure representing possible vehicle parameter.
double maxPlatformDistance
the maximum distance between platform and train
double carriageDoorWidth
the width of the carriage doors
Representation of a vehicle.
DepartPosDefinition departPosProcedure
Information how the vehicle shall choose the departure position.
void addShapeListener(ShapeListener *listener)
virtual bool removePolygon(const std::string &id, bool useLock=true)
Removes a polygon from the container.
const Polygons & getPolygons() const
Returns all polygons.
virtual bool addPolygon(const std::string &id, const std::string &type, const RGBColor &color, double layer, double angle, const std::string &imgFile, const PositionVector &shape, bool geo, bool fill, double lineWidth, bool ignorePruning=false, const std::string &name=Shape::DEFAULT_NAME)
Builds a polygon using the given values and adds it to the container.
const std::string & getShapeType() const
Returns the (abstract) type of the Shape.
std::vector< std::string > getVector()
return vector of strings
static double toDouble(const std::string &sData)
converts a string into the double value described by it by calling the char-type converter
static void initRandGlobal(SumoRNG *which=nullptr)
Reads the given random number options and initialises the random number generator in accordance.
static bool moveToXYMap_matchingRoutePosition(const Position &pos, const std::string &origID, const ConstMSEdgeVector ¤tRoute, int routeIndex, SUMOVehicleClass vClass, bool setLateralPos, double &bestDistance, MSLane **lane, double &lanePos, int &routeOffset)
static int getFreeSocketPort()
Returns an free port on the system.
#define UNUSED_PARAMETER(x)
Structure that keeps data related to vanishing areas (and other types of areas).