SUMO - Simulation of Urban MObility
MSSOTLE2Sensors.h
Go to the documentation of this file.
1 /****************************************************************************/
8 // The class for SOTL sensors of "E2" type
9 // XXX: Not tested with MSMultiLaneE2Collector (Generalization of MSE2Collector). If this is to be used in the future and you run into problems,
10 // start taking a look at the getEstimateQueueLength() method of the collector.
11 /****************************************************************************/
12 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
13 // Copyright (C) 2010-2017 DLR (http://www.dlr.de/) and contributors
14 /****************************************************************************/
15 //
16 // This file is part of SUMO.
17 // SUMO is free software: you can redistribute it and/or modify
18 // it under the terms of the GNU General Public License as published by
19 // the Free Software Foundation, either version 3 of the License, or
20 // (at your option) any later version.
21 //
22 /****************************************************************************/
23 #ifndef MSSOTLE2Sensors_h
24 #define MSSOTLE2Sensors_h
25 
26 
27 #define SWARM_DEBUG
29 #include "MSSOTLSensors.h"
30 #include "MSSOTLDefinitions.h"
31 #include <math.h>
32 #include <map>
33 #include <utility>
35 
37 protected :
39  void buildSensorForLane(MSLane* lane, NLDetectorBuilder& nb, double sensorLength);
40  void buildContinueSensior(MSLane* lane, NLDetectorBuilder& nb, double sensorLength, MSLane* continueOnLane, double usedLength);
42  void buildSensorForOutLane(MSLane* lane, NLDetectorBuilder& nb, double sensorLength);
43 
46 
47 public:
48  /*
49  * @brief This sensor logic contructor
50  */
51  MSSOTLE2Sensors(std::string tlLogicID, const MSTrafficLightLogic::Phases* phases);
52 
53  /*
54  * @brief This sensor logic destructor
55  */
56  ~MSSOTLE2Sensors(void);
57 
59  void buildSensors(MSTrafficLightLogic::LaneVectorVector controlledLanes, NLDetectorBuilder& nb, double sensorLength);
61  void buildOutSensors(MSTrafficLightLogic::LaneVectorVector controlledLanes, NLDetectorBuilder& nb, double sensorLength);
64 
65  /*
66  * Returns the number of vehicles that have passed the sensor.
67  * Vehicles are effectively counted or guessed in the space from the sensor to the junction.
68  * @param[in] laneId The ID of the lane of which you want to count vehicles.
69  * @param[in] out boolean that indicate if the lane is an incoming or an outgoing one (@todo review)
70  */
71  int getPassedVeh(std::string laneId, bool out);
72 
73  /*
74  * Sets the number of vehicles that have passed the sensor.
75  * @param[in] laneId The ID of the lane of which you want to set vehicles.
76  * @param[in] passed int indicating the number of vehicles to subtract.
77  */
78  void subtractPassedVeh(std::string laneId, int passed);
79 
80  void setSpeedThresholdParam(double newThreshold) {
81  speedThresholdParam = newThreshold;
82  }
83 
84  /*
85  * Returns the number of vehicles currently approaching the
86  * junction for the given lane.
87  * Vehicles are effectively counted or guessed in the space from the sensor to the junction.
88  * @param[in] lane The lane to count vehicles
89  */
90  int countVehicles(MSLane* lane);
91 
92  /*
93  * Returns the number of vehicles currently approaching the
94  * junction for the given lane.
95  * Vehicles are effectively counted or guessed in the space from the sensor to the junction.
96  * @param[in] lane The lane to count vehicles given by ID
97  */
98  int countVehicles(std::string laneId);
99 
100  int estimateVehicles(std::string laneId);
101 
102  double getEstimateQueueLength(std::string laneId);
103  /*
104  * @param[in] The lane given by Id
105  * @return The maximum speed allowed for the given laneId
106  */
107  virtual double getMaxSpeed(std::string laneId);
108 
109  /*
110  * Returns the average speed of vehicles currently approaching or leaving the
111  * junction for the given lane.
112  * Vehicles speed is effectively sensed or guessed in the space from the sensor.
113  * @param[in] lane The lane to count vehicles
114  */
115  virtual double meanVehiclesSpeed(MSLane* lane);
116 
117  /*
118  * Returns the average speed of vehicles currently approaching or leaving the
119  * junction for the given lane.
120  * Vehicles speed is effectively sensed or guessed in the space from the sensor.
121  * @param[in] laneID The lane to count vehicles by ID
122  */
123  virtual double meanVehiclesSpeed(std::string laneId);
124 
125  /*
126  * Set the weight of the vehicle types to be used by countVehicles
127  * @param[in] the value of the param VEHICLE_TYPES_WEIGHTS. Format type1=value1; type2=value2 etc..
128  */
129  virtual void setVehicleWeigths(const std::string& weightString);
130 
131 protected:
132  int count(MSE2Collector* sensor);
133  template<typename Method, typename ValueType>
134  bool getVelueFromSensor(std::string laneId, Method function, ValueType& value) {
135  if (m_sensorMap.find(laneId) != m_sensorMap.end()) {
136  value = (m_sensorMap[laneId]->*function)();
137  return true;
138  }
139  return false;
140  }
141 
142 // MSLane_MSE2CollectorMap m_sensorMap;
145 
146 // MSLane_MSE2CollectorMap mySensorsMap_OutLanes;
147 // MSLaneID_MSE2CollectorMap mySensorsIDMap_OutLanes;
148 // MSLaneID_MaxSpeedMap myMaxSpeedMap_OutLanes;
149 
151  std::map<std::string, std::vector<std::string> > m_continueSensorOnLanes;
152  std::map<const std::string, int> m_typeWeightMap;
153 
154 };
155 
156 #endif
157 /****************************************************************************/
Builds detectors for microsim.
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:87
std::map< const std::string, int > m_typeWeightMap
MSLaneID_MSE2CollectorMap m_sensorMap
void buildContinueSensior(MSLane *lane, NLDetectorBuilder &nb, double sensorLength, MSLane *continueOnLane, double usedLength)
MSSOTLE2Sensors(std::string tlLogicID, const MSTrafficLightLogic::Phases *phases)
void buildCountOutSensors(MSTrafficLightLogic::LaneVectorVector controlledLanes, NLDetectorBuilder &nb)
virtual double meanVehiclesSpeed(MSLane *lane)
void setSpeedThresholdParam(double newThreshold)
std::map< std::string, std::vector< std::string > > m_continueSensorOnLanes
std::map< std::string, double > MSLaneID_MaxSpeedMap
int estimateVehicles(std::string laneId)
void buildCountSensors(MSTrafficLightLogic::LaneVectorVector controlledLanes, NLDetectorBuilder &nb)
int getPassedVeh(std::string laneId, bool out)
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...
double getEstimateQueueLength(std::string laneId)
bool getVelueFromSensor(std::string laneId, Method function, ValueType &value)
std::map< std::string, MSE2Collector * > MSLaneID_MSE2CollectorMap
MSLaneID_MaxSpeedMap m_maxSpeedMap
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 void setVehicleWeigths(const std::string &weightString)
std::vector< MSPhaseDefinition * > Phases
Definition of a list of phases, being the junction logic.
double speedThresholdParam
std::vector< LaneVector > LaneVectorVector
Definition of a list that holds lists of lanes that do have the same attribute.
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 buildCountSensorForLane(MSLane *lane, NLDetectorBuilder &nb)
void subtractPassedVeh(std::string laneId, int passed)
std::string tlLogicID
Definition: MSSOTLSensors.h:43
Representation of a lane in the micro simulation.
Definition: MSLane.h:79
int count(MSE2Collector *sensor)