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