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