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