Eclipse SUMO - Simulation of Urban MObility
MSSOTLE2Sensors.cpp
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2010-2019 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials
5 // are made available under the terms of the Eclipse Public License v2.0
6 // which accompanies this distribution, and is available at
7 // http://www.eclipse.org/legal/epl-v20.html
8 // SPDX-License-Identifier: EPL-2.0
9 /****************************************************************************/
16 // The class for SOTL sensors of "E2" type
17 /****************************************************************************/
18 
21 #include <microsim/MSEdge.h>
22 #include <microsim/MSVehicleType.h>
23 #include "MSSOTLE2Sensors.h"
24 
25 #define INVALID_POSITION std::numeric_limits<double>::max()
26 
27 MSSOTLE2Sensors::MSSOTLE2Sensors(std::string tlLogicID,
28  const MSTrafficLightLogic::Phases* phases) :
29  MSSOTLSensors(tlLogicID, phases) {
30 }
31 
33  //Deleting sensors takes place in the detector control
34 }
35 
38  NLDetectorBuilder& nb) {
39  buildSensors(controlledLanes, nb, INPUT_SENSOR_LENGTH);
40 }
41 
44  NLDetectorBuilder& nb, double sensorLength) {
45  //for each lane build an appropriate sensor on it
46  MSLane* currentLane = nullptr;
47 
48  //input and ouput lanes
49  for (MSTrafficLightLogic::LaneVectorVector::const_iterator laneVector =
50  controlledLanes.begin(); laneVector != controlledLanes.end();
51  laneVector++) {
52  for (MSTrafficLightLogic::LaneVector::const_iterator lane =
53  laneVector->begin(); lane != laneVector->end(); lane++) {
54  currentLane = (*lane);
55  buildSensorForLane(currentLane, nb, sensorLength);
56  }
57  }
58 }
59 /****************************************************************************/
60 /*
61  * Count Sensors. Should be refactor to make a new class.
62  */
65  NLDetectorBuilder& nb) {
66  //for each lane build an appropriate sensor on it
67  MSLane* currentLane = nullptr;
68  //input and ouput lanes
69  for (MSTrafficLightLogic::LaneVectorVector::const_iterator laneVector =
70  controlledLanes.begin(); laneVector != controlledLanes.end();
71  laneVector++) {
72  for (MSTrafficLightLogic::LaneVector::const_iterator lane =
73  laneVector->begin(); lane != laneVector->end(); lane++) {
74  currentLane = (*lane);
75  buildCountSensorForLane(currentLane, nb);
76  }
77  }
78 }
79 
82  NLDetectorBuilder& nb) {
83  //for each lane build an appropriate sensor on it
84  MSLane* currentLane = nullptr;
85 
86  //input and ouput lanes
87  for (MSTrafficLightLogic::LaneVectorVector::const_iterator laneVector =
88  controlledLanes.begin(); laneVector != controlledLanes.end();
89  laneVector++) {
90  for (MSTrafficLightLogic::LaneVector::const_iterator lane =
91  laneVector->begin(); lane != laneVector->end(); lane++) {
92  currentLane = (*lane);
93  buildCountSensorForOutLane(currentLane, nb);
94  }
95  }
96 }
97 
100  NLDetectorBuilder& nb) {
101  buildOutSensors(controlledLanes, nb, OUTPUT_SENSOR_LENGTH);
102 }
105  NLDetectorBuilder& nb, double sensorLength) {
106  //for each lane build an appropriate sensor on it
107  MSLane* currentLane = nullptr;
108 
109  //input and ouput lanes
110  for (MSTrafficLightLogic::LaneVectorVector::const_iterator laneVector =
111  controlledLanes.begin(); laneVector != controlledLanes.end();
112  laneVector++) {
113  for (MSTrafficLightLogic::LaneVector::const_iterator lane =
114  laneVector->begin(); lane != laneVector->end(); lane++) {
115  currentLane = (*lane);
116  buildSensorForOutLane(currentLane, nb, sensorLength);
117  }
118  }
119 }
120 
122  double sensorPos;
123  double lensorLength;
124  MSE2Collector* newSensor = nullptr;
125  //Check not to have more than a sensor for lane
126  if (m_sensorMap.find(lane->getID()) == m_sensorMap.end()) {
127 
128  //Check and set zero if the lane is not long enough for the specified sensor start
129  sensorPos = COUNT_SENSOR_START <= lane->getLength() ? COUNT_SENSOR_START : 0;
130 
131  //Original:
132  double sensorLength = INPUT_COUNT_SENSOR_LENGTH;
133 
134  //Check and trim if the lane is not long enough for the specified sensor length
135  lensorLength = sensorLength <= (lane->getLength() - sensorPos) ? sensorLength : (lane->getLength() - sensorPos);
136 
137  //TODO check this lengths
138 // DBG(
139 // std::ostringstream phero_str;
140 // phero_str << " lane " << lane->getID() << " sensorPos= " << sensorPos
141 // << " ,SENSOR_START " << SENSOR_START << "; lane->getLength = "
142 // << lane->getLength() << " ,lensorLength= " << lensorLength
143 // << " ,SENSOR_LENGTH= " << INPUT_SENSOR_LENGTH;
144 // WRITE_MESSAGE(
145 // "MSSOTLE2Sensors::buildSensorForLane::" + phero_str.str());
146 // )
147 
148  //Create sensor for lane and insert it into the map<MSLane*, MSE2Collector*>
149  newSensor = nb.createE2Detector(
150  "SOTL_E2_lane:" + lane->getID() + "_tl:" + tlLogicID,
151  DU_TL_CONTROL, lane,
152  (lane->getLength() - sensorPos - lensorLength), INVALID_POSITION, lensorLength,
154 
156  SUMO_TAG_LANE_AREA_DETECTOR, newSensor);
157 
158  m_sensorMap.insert(MSLaneID_MSE2Collector(lane->getID(), newSensor));
159  m_maxSpeedMap.insert(MSLaneID_MaxSpeed(lane->getID(), lane->getSpeedLimit()));
160  }
161 }
162 
164  double sensorPos;
165  double lensorLength;
166  MSE2Collector* newSensor = nullptr;
167  //Check not to have more than a sensor for lane
168  if (m_sensorMap.find(lane->getID()) == m_sensorMap.end()) {
169 
170  //Original:
171  double sensorLength = OUTPUT_COUNT_SENSOR_LENGTH;
172  //Check and set zero if the lane is not long enough for the specified sensor start
173  sensorPos = (lane->getLength() - sensorLength)
174  - (SENSOR_START <= lane->getLength() ? SENSOR_START : 0);
175 
176  //Check and trim if the lane is not long enough for the specified sensor length
177  lensorLength =
178  sensorLength <= (lane->getLength() - sensorPos) ?
179  sensorLength : (lane->getLength() - sensorPos);
180 
181  //TODO check this lengths
182 // DBG(
183 // std::ostringstream phero_str;
184 // phero_str << " lane " << lane->getID() << " sensorPos= " << sensorPos
185 // << " ,SENSOR_START " << SENSOR_START << "; lane->getLength = "
186 // << lane->getLength() << " ,lensorLength= " << lensorLength
187 // << " ,SENSOR_LENGTH= " << INPUT_SENSOR_LENGTH;
188 // WRITE_MESSAGE(
189 // "MSSOTLE2Sensors::buildSensorForLane::" + phero_str.str());
190 // )
191 
192  //Create sensor for lane and insert it into the map<MSLane*, MSE2Collector*>
193  newSensor = nb.createE2Detector(
194  "SOTL_E2_lane:" + lane->getID() + "_tl:" + tlLogicID,
195  DU_TL_CONTROL, lane,
196  (lane->getLength() - sensorPos - lensorLength), INVALID_POSITION, lensorLength,
198 
200  SUMO_TAG_LANE_AREA_DETECTOR, newSensor);
201 
202  m_sensorMap.insert(MSLaneID_MSE2Collector(lane->getID(), newSensor));
203  m_maxSpeedMap.insert(MSLaneID_MaxSpeed(lane->getID(), lane->getSpeedLimit()));
204  }
205 }
206 
207 int MSSOTLE2Sensors::getPassedVeh(std::string laneId, bool /* out */) {
208  MSLaneID_MSE2CollectorMap::const_iterator sensorsIterator;
209  sensorsIterator = m_sensorMap.find(laneId);
210  if (sensorsIterator == m_sensorMap.end()) {
211  assert(0);
212  return 0;
213  } else {
214  int additional = 0;
215  if (m_continueSensorOnLanes.find(laneId) != m_continueSensorOnLanes.end())
216  for (std::vector<std::string>::iterator it = m_continueSensorOnLanes[laneId].begin(); it != m_continueSensorOnLanes[laneId].end(); ++ it) {
217  int tmp = 0;
219  additional += tmp;
220  }
221  }
222  return sensorsIterator->second->getPassedVeh() + additional;
223  }
224 }
225 
226 void
227 MSSOTLE2Sensors::subtractPassedVeh(std::string laneId, int passed) {
228  //TODO Ivan: ciclare tutti i sensori di count e resettare passedVeh
229  MSLaneID_MSE2CollectorMap::const_iterator sensorsIterator;
230 
231  sensorsIterator = m_sensorMap.find(laneId);
232  if (sensorsIterator != m_sensorMap.end()) {
233  sensorsIterator->second->subtractPassedVeh(passed);
234  }
235 }
236 
237 /*******************************************************************************/
238 
241 }
242 
243 
244 
245 void MSSOTLE2Sensors::buildSensorForLane(MSLane* lane, NLDetectorBuilder& nb, double sensorLength) {
246  const MSEdge* edge = &lane->getEdge();
247  if (edge->isInternal() || edge->isWalkingArea() || edge->isCrossing()) {
248  return;
249  }
250  double sensorPos;
251  double lensorLength;
252  MSE2Collector* newSensor = nullptr;
253  //Check not to have more than a sensor for lane
254  if (m_sensorMap.find(lane->getID()) == m_sensorMap.end()) {
255 
256  //Check and set zero if the lane is not long enough for the specified sensor start
257  sensorPos = SENSOR_START <= lane->getLength() ? SENSOR_START : 0;
258  //Check and trim if the lane is not long enough for the specified sensor length
259  lensorLength = sensorLength <= (lane->getLength() - sensorPos) ? sensorLength : (lane->getLength() - sensorPos);
260  //TODO check this lengths
261 // DBG(
262 // std::ostringstream phero_str;
263 // phero_str << " lane " << lane->getID() << " sensorPos= " << sensorPos
264 // << " ,SENSOR_START " << SENSOR_START << "; lane->getLength = "
265 // << lane->getLength() << " ,lensorLength= " << lensorLength
266 // << " ,SENSOR_LENGTH= " << INPUT_SENSOR_LENGTH;
267 // WRITE_MESSAGE(
268 // "MSSOTLE2Sensors::buildSensorForLane::" + phero_str.str());
269 // )
270 
271  //Create sensor for lane and insert it into the map<MSLane*, MSE2Collector*>
272  newSensor = nb.createE2Detector(
273  "SOTL_E2_lane:" + lane->getID() + "_tl:" + tlLogicID,
274  DU_TL_CONTROL, lane,
275  (lane->getLength() - sensorPos - lensorLength), INVALID_POSITION, lensorLength,
277 
279 
280  m_sensorMap.insert(MSLaneID_MSE2Collector(lane->getID(), newSensor));
281  m_maxSpeedMap.insert(MSLaneID_MaxSpeed(lane->getID(), lane->getSpeedLimit()));
282  //Avoid creating really small sensors. Only add a further sensors if the one created is less than 90% the requested length
283  if (lensorLength < sensorLength * 0.9) {
284  std::ostringstream oss;
285  oss << "Sensor on lane " << lane->getID() << " is long " << lensorLength << ", while it should be " << sensorLength << ". Continuing it on the other lanes if possible";
286  WRITE_MESSAGE(oss.str())
287  for (std::vector<MSLane::IncomingLaneInfo>::const_iterator it = lane->getIncomingLanes().begin(); it != lane->getIncomingLanes().end(); ++it) {
288  const MSEdge* edge = &it->lane->getEdge();
289  if (!edge->isInternal() && !edge->isWalkingArea() && !edge->isCrossing()) {
290  buildContinueSensior(lane, nb, sensorLength, it->lane, lensorLength);
291  }
292  }
293  }
294  }
295 }
296 
297 void MSSOTLE2Sensors::buildContinueSensior(MSLane* lane, NLDetectorBuilder& nb, double sensorLength, MSLane* continueOnLane, double usedLength) {
298  double availableLength = sensorLength - usedLength;
299  if (m_sensorMap.find(continueOnLane->getID()) == m_sensorMap.end()) {
300  double length = availableLength <= continueOnLane->getLength() ? availableLength : continueOnLane->getLength();
301  MSE2Collector* newSensor = nb.createE2Detector(
302  "SOTL_E2_lane:" + continueOnLane->getID() + "_tl:" + tlLogicID,
303  DU_TL_CONTROL, continueOnLane,
304  (continueOnLane->getLength() - length), INVALID_POSITION, length,
307  m_sensorMap.insert(MSLaneID_MSE2Collector(continueOnLane->getID(), newSensor));
308  m_continueSensorOnLanes[lane->getID()].push_back(continueOnLane->getID());
309  std::ostringstream oss;
310  oss << "Continue sensor on lane " << continueOnLane->getID() << ". Current length " << (length + usedLength);
311  WRITE_MESSAGE(oss.str())
312  //Continue other line if needed.
313  if (length + usedLength < sensorLength * 0.9) {
314  for (std::vector<MSLane::IncomingLaneInfo>::const_iterator it = continueOnLane->getIncomingLanes().begin(); it != continueOnLane->getIncomingLanes().end(); ++it) {
315  const MSEdge* edge = &it->lane->getEdge();
316  if (!edge->isInternal() && !edge->isWalkingArea() && !edge->isCrossing()) {
317  buildContinueSensior(lane, nb, sensorLength, it->lane, length + usedLength);
318  }
319  }
320  }
321  }
322 }
323 
325  NLDetectorBuilder& nb) {
327 }
328 
330  NLDetectorBuilder& nb, double sensorLength) {
331  double sensorPos;
332  double lensorLength;
333  MSE2Collector* newSensor = nullptr;
334  //Check not to have more than a sensor for lane
335  if (m_sensorMap.find(lane->getID()) == m_sensorMap.end()) {
336 
337  //Original:
338  //double sensorLength = OUTPUT_SENSOR_LENGTH;
339  //Check and set zero if the lane is not long enough for the specified sensor start
340  sensorPos = (lane->getLength() - sensorLength)
341  - (SENSOR_START <= lane->getLength() ? SENSOR_START : 0);
342 
343  //Check and trim if the lane is not long enough for the specified sensor length
344  lensorLength =
345  sensorLength <= (lane->getLength() - sensorPos) ?
346  sensorLength : (lane->getLength() - sensorPos);
347 
348  //TODO check this lengths
349 // DBG(
350 // std::ostringstream phero_str;
351 // phero_str << " lane " << lane->getID() << " sensorPos= " << sensorPos
352 // << " ,SENSOR_START " << SENSOR_START << "; lane->getLength = "
353 // << lane->getLength() << " ,lensorLength= " << lensorLength
354 // << " ,SENSOR_LENGTH= " << INPUT_SENSOR_LENGTH;
355 // WRITE_MESSAGE(
356 // "MSSOTLE2Sensors::buildSensorForLane::" + phero_str.str());
357 // )
358 
359  //Create sensor for lane and insert it into the map<MSLane*, MSE2Collector*>
360  newSensor = nb.createE2Detector(
361  "SOTL_E2_lane:" + lane->getID() + "_tl:" + tlLogicID,
362  DU_TL_CONTROL, lane,
363  (lane->getLength() - sensorPos - lensorLength), INVALID_POSITION, lensorLength,
365 
367  SUMO_TAG_LANE_AREA_DETECTOR, newSensor);
368 
369  m_sensorMap.insert(MSLaneID_MSE2Collector(lane->getID(), newSensor));
370  m_maxSpeedMap.insert(MSLaneID_MaxSpeed(lane->getID(), lane->getSpeedLimit()));
371  }
372 }
373 
375  return countVehicles(lane->getID());
376 }
377 
378 /*
379  * Estimate queue length according to the distance of the last vehicles
380  */
381 
382 double MSSOTLE2Sensors::getEstimateQueueLength(std::string laneId) {
383  MSLaneID_MSE2CollectorMap::const_iterator sensorsIterator = m_sensorMap.find(laneId);
384  if (sensorsIterator == m_sensorMap.end()) {
385  assert(0);
386  return 0;
387  } else {
388  double estQL = sensorsIterator->second->getEstimateQueueLength();
389  if (estQL == -1) {
390  return 0;
391  } else
392 // DBG(
393 // std::ostringstream str;
394 // str << "MSSOTLE2Sensors::getEstimateQueueLength lane " << sensorsIterator->second->getLane()->getID()
395 // << " laneLength " << sensorsIterator->second->getLane()->getLength() << " estimateQueueLength " << estQL;
396 // WRITE_MESSAGE(str.str());
397 // )
398  {
399  return estQL;
400  }
401  }
402 }
403 
404 /*
405  * Estimate queue length according to the distance of the last vehicles that exceed a threshold
406  */
407 
408 int MSSOTLE2Sensors::estimateVehicles(std::string laneId) {
409  MSLaneID_MSE2CollectorMap::const_iterator sensorsIterator = m_sensorMap.find(laneId);
410  if (sensorsIterator == m_sensorMap.end()) {
411  assert(0);
412  return 0;
413  }
414  int additional = 0;
415  if (m_continueSensorOnLanes.find(laneId) != m_continueSensorOnLanes.end())
416  for (std::vector<std::string>::iterator it = m_continueSensorOnLanes[laneId].begin(); it != m_continueSensorOnLanes[laneId].end(); ++ it) {
417  if (m_sensorMap.find(*it) != m_sensorMap.end()) {
418  additional += m_sensorMap[*it]->getEstimatedCurrentVehicleNumber(speedThresholdParam);
419  }
420  }
421  return sensorsIterator->second->getEstimatedCurrentVehicleNumber(speedThresholdParam) + additional;
422 }
423 
424 int MSSOTLE2Sensors::countVehicles(std::string laneId) {
425  MSLaneID_MSE2CollectorMap::const_iterator sensorsIterator = m_sensorMap.find(laneId);
426  if (sensorsIterator == m_sensorMap.end()) {
427  assert(0);
428  return 0;
429  }
430  int additional = 0;
431  if (m_continueSensorOnLanes.find(laneId) != m_continueSensorOnLanes.end()) {
432  for (std::vector<std::string>::iterator it = m_continueSensorOnLanes[laneId].begin(); it != m_continueSensorOnLanes[laneId].end(); ++ it) {
433  if (m_sensorMap.find(*it) != m_sensorMap.end()) {
434  additional += count(m_sensorMap[*it]);
435  }
436  }
437  }
438  return count(sensorsIterator->second) + additional;
439 }
440 
441 double MSSOTLE2Sensors::getMaxSpeed(std::string laneId) {
442  MSLaneID_MaxSpeedMap::const_iterator sensorsIteratorIn = m_maxSpeedMap.find(laneId);
443  if (sensorsIteratorIn == m_maxSpeedMap.end()) {
444  assert(0);
445  WRITE_ERROR("MSSOTLE2Sensors::meanVehiclesSpeed:: No lane found " + laneId);
446  return 0;
447  }
448  return sensorsIteratorIn->second;
449 }
450 
452  return meanVehiclesSpeed(lane->getID());
453 }
454 
455 double MSSOTLE2Sensors::meanVehiclesSpeed(std::string laneId) {
456  MSLaneID_MSE2CollectorMap::const_iterator sensorsIteratorOut = m_sensorMap.find(laneId);
457  if (sensorsIteratorOut == m_sensorMap.end()) {
458  assert(0);
459  WRITE_ERROR("MSSOTLE2Sensors::meanVehiclesSpeed:: No lane found " + laneId);
460  return 0;
461  }
462  double meanSpeedAcc = 0;
463  int totalCarNumer = 0;
464  if (m_continueSensorOnLanes.find(laneId) != m_continueSensorOnLanes.end())
465  for (std::vector<std::string>::iterator it = m_continueSensorOnLanes[laneId].begin(); it != m_continueSensorOnLanes[laneId].end(); ++ it) {
466  int number = 0;
467  double mean = -1;
469  continue;
470  }
471  totalCarNumer += number;
473  meanSpeedAcc += mean * (double) number;
474  }
475  int number = sensorsIteratorOut->second->getCurrentVehicleNumber();
476  totalCarNumer += number;
477  double mean = sensorsIteratorOut->second->getCurrentMeanSpeed();
478  meanSpeedAcc += mean * (double) number;
479  return totalCarNumer == 0 ? -1 : meanSpeedAcc / (double) totalCarNumer;
480 }
481 
482 std::string trim(std::string& str) {
483  int first = (int)str.find_first_not_of(' ');
484  int last = (int)str.find_last_not_of(' ');
485  return str.substr(first, (last - first + 1));
486 }
487 
488 std::vector<std::string>& split(const std::string& s, char delim, std::vector<std::string>& elems) {
489  std::stringstream ss(s);
490  std::string item;
491  while (std::getline(ss, item, delim)) {
492  if (!item.empty()) {
493  elems.push_back(item);
494  }
495  }
496  return elems;
497 }
498 
499 void MSSOTLE2Sensors::setVehicleWeigths(const std::string& weightString) {
500  std::vector<std::string> types;
501  split(weightString, ';', types);
502  std::ostringstream logstr;
503  logstr << "[MSSOTLE2Sensors::setVehicleWeigths] ";
504  for (std::vector<std::string>::iterator typesIt = types.begin(); typesIt != types.end(); ++typesIt) {
505  std::vector<std::string> typeWeight;
506  split(*typesIt, '=', typeWeight);
507  if (typeWeight.size() == 2) {
508  std::string type = trim(typeWeight[0]);
509  int value = StringUtils::toInt(typeWeight[1]);
510  logstr << type << "=" << value << " ";
511  m_typeWeightMap[type] = value;
512  }
513  }
514  WRITE_MESSAGE(logstr.str());
515 }
516 
518  int totCars = sensor->getCurrentVehicleNumber();
519  if (m_typeWeightMap.size() == 0) {
520  return totCars;
521  }
522  int number = 0;
523  const std::vector<MSE2Collector::VehicleInfo*> vehicles = sensor->getCurrentVehicles();
524  std::ostringstream logstr;
525  logstr << "[MSSOTLE2Sensors::count]";
526  for (std::vector<MSE2Collector::VehicleInfo*>::const_iterator vit = vehicles.begin(); vit != vehicles.end(); ++vit) {
527  if ((*vit)->onDetector) {
528  const std::string vtype = (*vit)->type;
529  if (m_typeWeightMap.find(vtype) != m_typeWeightMap.end()) {
530  number += m_typeWeightMap[vtype];
531 // DBG(logstr << " Added " << m_typeWeightMap[vtype] << " for vtype " << vtype;)
532  } else {
533  ++number;
534  }
535  }
536  }
537 // DBG(if (totCars != number) {
538 // logstr << ". Real number " << totCars << "; weighted " << number;
539 // WRITE_MESSAGE(logstr.str());
540 // })
541  return number;
542 }
NLDetectorBuilder::createE2Detector
virtual MSE2Collector * createE2Detector(const std::string &id, DetectorUsage usage, MSLane *lane, double pos, double endPos, double length, SUMOTime haltingTimeThreshold, double haltingSpeedThreshold, double jamDistThreshold, const std::string &vTypes, bool showDetector=true)
Creates a MSE2Collector instance, overridden by GUIE2Collector::createE2Detector()
Definition: NLDetectorBuilder.cpp:397
MSSOTLE2Sensors::buildCountSensors
void buildCountSensors(MSTrafficLightLogic::LaneVectorVector controlledLanes, NLDetectorBuilder &nb)
Definition: MSSOTLE2Sensors.cpp:63
MSSOTLE2Sensors::getVelueFromSensor
bool getVelueFromSensor(std::string laneId, Method function, ValueType &value)
Definition: MSSOTLE2Sensors.h:130
MSNet::getDetectorControl
MSDetectorControl & getDetectorControl()
Returns the detector control.
Definition: MSNet.h:399
MSLane
Representation of a lane in the micro simulation.
Definition: MSLane.h:82
MSDetectorControl.h
MSSOTLE2Sensors::m_maxSpeedMap
MSLaneID_MaxSpeedMap m_maxSpeedMap
Definition: MSSOTLE2Sensors.h:140
MSSOTLE2Sensors::buildSensors
void buildSensors(MSTrafficLightLogic::LaneVectorVector controlledLanes, NLDetectorBuilder &nb)
This function member has to be extended to properly build sensors for the input lanes Sensors has to ...
Definition: MSSOTLE2Sensors.cpp:36
MSSOTLE2Sensors::getPassedVeh
int getPassedVeh(std::string laneId, bool out)
Definition: MSSOTLE2Sensors.cpp:207
MSTrafficLightLogic::Phases
std::vector< MSPhaseDefinition * > Phases
Definition of a list of phases, being the junction logic.
Definition: MSTrafficLightLogic.h:61
SUMO_TAG_LANE_AREA_DETECTOR
@ SUMO_TAG_LANE_AREA_DETECTOR
alternative tag for e2 detector
Definition: SUMOXMLDefinitions.h:71
INPUT_SENSOR_LENGTH
#define INPUT_SENSOR_LENGTH
Definition: MSSOTLDefinitions.h:24
MSSOTLE2Sensors::buildSensorForLane
void buildSensorForLane(MSLane *lane, NLDetectorBuilder &nb)
This function member has to be extended to properly build a sensor for a specific input lane Sensors ...
Definition: MSSOTLE2Sensors.cpp:239
MSSOTLE2Sensors::subtractPassedVeh
void subtractPassedVeh(std::string laneId, int passed)
Definition: MSSOTLE2Sensors.cpp:227
MSSOTLE2Sensors::getEstimateQueueLength
double getEstimateQueueLength(std::string laneId)
Definition: MSSOTLE2Sensors.cpp:382
MSE2Collector
An areal detector corresponding to a sequence of consecutive lanes.
Definition: MSE2Collector.h:81
MSE2Collector::getCurrentVehicles
std::vector< VehicleInfo * > getCurrentVehicles() const
Returns the VehicleInfos for the vehicles currently on the detector.
Definition: MSE2Collector.cpp:1425
MSEdge.h
MSSOTLE2Sensors::count
int count(MSE2Collector *sensor)
Definition: MSSOTLE2Sensors.cpp:517
DIST_THRS
#define DIST_THRS
Definition: MSSOTLDefinitions.h:37
SENSOR_START
#define SENSOR_START
For MSSOTLSensors.
Definition: MSSOTLDefinitions.h:22
MSSOTLE2Sensors::setVehicleWeigths
virtual void setVehicleWeigths(const std::string &weightString)
Definition: MSSOTLE2Sensors.cpp:499
MSLane::getIncomingLanes
const std::vector< IncomingLaneInfo > & getIncomingLanes() const
Definition: MSLane.h:818
MSVehicleType.h
MSSOTLE2Sensors::speedThresholdParam
double speedThresholdParam
Definition: MSSOTLE2Sensors.h:146
MSEdge::isInternal
bool isInternal() const
return whether this edge is an internal edge
Definition: MSEdge.h:235
MSE2Collector::getCurrentMeanSpeed
double getCurrentMeanSpeed() const
Returns the mean vehicle speed of vehicles currently on the detector.
Definition: MSE2Collector.h:425
MSSOTLE2Sensors::~MSSOTLE2Sensors
~MSSOTLE2Sensors(void)
Definition: MSSOTLE2Sensors.cpp:32
MSEdge::isCrossing
bool isCrossing() const
return whether this edge is a pedestrian crossing
Definition: MSEdge.h:240
MSSOTLE2Sensors::buildCountSensorForLane
void buildCountSensorForLane(MSLane *lane, NLDetectorBuilder &nb)
Definition: MSSOTLE2Sensors.cpp:121
MSSOTLE2Sensors::countVehicles
int countVehicles(MSLane *lane)
Definition: MSSOTLE2Sensors.cpp:374
MSSOTLE2Sensors::buildCountSensorForOutLane
void buildCountSensorForOutLane(MSLane *lane, NLDetectorBuilder &nb)
Definition: MSSOTLE2Sensors.cpp:163
MSSOTLE2Sensors::buildOutSensors
void buildOutSensors(MSTrafficLightLogic::LaneVectorVector controlledLanes, NLDetectorBuilder &nb)
This function member has to be extended to properly build sensors for the output lanes Sensors has to...
Definition: MSSOTLE2Sensors.cpp:98
MSLaneID_MSE2Collector
std::pair< std::string, MSE2Collector * > MSLaneID_MSE2Collector
Definition: MSSOTLDefinitions.h:55
MSSOTLE2Sensors::m_typeWeightMap
std::map< const std::string, int > m_typeWeightMap
Definition: MSSOTLE2Sensors.h:148
MSLane::getLength
double getLength() const
Returns the lane's length.
Definition: MSLane.h:540
MSSOTLSensors::tlLogicID
std::string tlLogicID
Definition: MSSOTLSensors.h:35
INPUT_COUNT_SENSOR_LENGTH
#define INPUT_COUNT_SENSOR_LENGTH
Definition: MSSOTLDefinitions.h:28
MSEdge
A road/street connecting two junctions.
Definition: MSEdge.h:78
COUNT_SENSOR_START
#define COUNT_SENSOR_START
Definition: MSSOTLDefinitions.h:30
MSLaneID_MaxSpeed
std::pair< std::string, double > MSLaneID_MaxSpeed
Definition: MSSOTLDefinitions.h:59
HALTING_TIME_THRS
#define HALTING_TIME_THRS
Definition: MSSOTLDefinitions.h:33
trim
std::string trim(std::string &str)
Definition: MSSOTLE2Sensors.cpp:482
OUTPUT_SENSOR_LENGTH
#define OUTPUT_SENSOR_LENGTH
Definition: MSSOTLDefinitions.h:25
DU_TL_CONTROL
@ DU_TL_CONTROL
Definition: MSDetectorFileOutput.h:53
split
std::vector< std::string > & split(const std::string &s, char delim, std::vector< std::string > &elems)
Definition: MSSOTLE2Sensors.cpp:488
MSSOTLE2Sensors.h
MSLane::getEdge
MSEdge & getEdge() const
Returns the lane's edge.
Definition: MSLane.h:669
MSEdge::isWalkingArea
bool isWalkingArea() const
return whether this edge is walking area
Definition: MSEdge.h:254
StringUtils.h
StringUtils::toInt
static int toInt(const std::string &sData)
converts a string into the integer value described by it by calling the char-type converter,...
Definition: StringUtils.cpp:278
MSNet::getInstance
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
Definition: MSNet.cpp:167
MSSOTLE2Sensors::m_sensorMap
MSLaneID_MSE2CollectorMap m_sensorMap
Definition: MSSOTLE2Sensors.h:139
MSSOTLE2Sensors::MSSOTLE2Sensors
MSSOTLE2Sensors(std::string tlLogicID, const MSTrafficLightLogic::Phases *phases)
Definition: MSSOTLE2Sensors.cpp:27
INVALID_POSITION
#define INVALID_POSITION
Definition: MSSOTLE2Sensors.cpp:25
MSTrafficLightLogic::LaneVectorVector
std::vector< LaneVector > LaneVectorVector
Definition of a list that holds lists of lanes that do have the same attribute.
Definition: MSTrafficLightLogic.h:73
MSSOTLSensors
Definition: MSSOTLSensors.h:32
MSE2Collector::getPassedVeh
int getPassedVeh()
Returns the number of vehicles passed over the sensor (i.e. entered the sensor)
Definition: MSE2Collector.h:488
MSDetectorControl::add
void add(SumoXMLTag type, MSDetectorFileOutput *d, const std::string &device, SUMOTime splInterval, SUMOTime begin=-1)
Adds a detector/output combination into the containers.
Definition: MSDetectorControl.cpp:63
OUTPUT_COUNT_SENSOR_LENGTH
#define OUTPUT_COUNT_SENSOR_LENGTH
Definition: MSSOTLDefinitions.h:29
MSSOTLE2Sensors::estimateVehicles
int estimateVehicles(std::string laneId)
Definition: MSSOTLE2Sensors.cpp:408
MSE2Collector::getCurrentVehicleNumber
int getCurrentVehicleNumber() const
Returns the number of vehicles currently on the detector.
Definition: MSE2Collector.cpp:1399
MSSOTLE2Sensors::buildSensorForOutLane
void buildSensorForOutLane(MSLane *lane, NLDetectorBuilder &nb)
This function member has to be extended to properly build a sensor for a specific output lane Sensors...
Definition: MSSOTLE2Sensors.cpp:324
HALTING_SPEED_THRS
#define HALTING_SPEED_THRS
Definition: MSSOTLDefinitions.h:35
Named::getID
const std::string & getID() const
Returns the id.
Definition: Named.h:76
MSSOTLE2Sensors::buildContinueSensior
void buildContinueSensior(MSLane *lane, NLDetectorBuilder &nb, double sensorLength, MSLane *continueOnLane, double usedLength)
Definition: MSSOTLE2Sensors.cpp:297
WRITE_ERROR
#define WRITE_ERROR(msg)
Definition: MsgHandler.h:283
WRITE_MESSAGE
#define WRITE_MESSAGE(msg)
Definition: MsgHandler.h:277
NLDetectorBuilder
Builds detectors for microsim.
Definition: NLDetectorBuilder.h:55
MSSOTLE2Sensors::m_continueSensorOnLanes
std::map< std::string, std::vector< std::string > > m_continueSensorOnLanes
Definition: MSSOTLE2Sensors.h:147
MSSOTLE2Sensors::buildCountOutSensors
void buildCountOutSensors(MSTrafficLightLogic::LaneVectorVector controlledLanes, NLDetectorBuilder &nb)
Definition: MSSOTLE2Sensors.cpp:80
MSSOTLE2Sensors::meanVehiclesSpeed
virtual double meanVehiclesSpeed(MSLane *lane)
Definition: MSSOTLE2Sensors.cpp:451
MSSOTLE2Sensors::getMaxSpeed
virtual double getMaxSpeed(std::string laneId)
Definition: MSSOTLE2Sensors.cpp:441