traci._edge
1# -*- coding: utf-8 -*- 2# Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo 3# Copyright (C) 2011-2026 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 14# @file _edge.py 15# @author Michael Behrisch 16# @author Jakob Erdmann 17# @date 2011-03-17 18 19from __future__ import absolute_import 20from . import constants as tc 21from .domain import Domain 22from .exceptions import TraCIException 23 24 25class EdgeDomain(Domain): 26 27 def __init__(self): 28 Domain.__init__(self, "edge", tc.CMD_GET_EDGE_VARIABLE, tc.CMD_SET_EDGE_VARIABLE, 29 tc.CMD_SUBSCRIBE_EDGE_VARIABLE, tc.RESPONSE_SUBSCRIBE_EDGE_VARIABLE, 30 tc.CMD_SUBSCRIBE_EDGE_CONTEXT, tc.RESPONSE_SUBSCRIBE_EDGE_CONTEXT, 31 subscriptionDefault=(tc.LAST_STEP_VEHICLE_NUMBER,)) 32 33 def getAdaptedTraveltime(self, edgeID, time): 34 """getAdaptedTraveltime(string, double) -> double 35 36 Returns the travel time value (in s) used for (re-)routing 37 which is valid on the edge at the given time. 38 """ 39 return self._getUniversal(tc.VAR_EDGE_TRAVELTIME, edgeID, "d", time) 40 41 def getWaitingTime(self, edgeID): 42 """getWaitingTime(string) -> double 43 Returns the sum of the waiting time of all vehicles currently on 44 that edge (see traci.vehicle.getWaitingTime). 45 """ 46 return self._getUniversal(tc.VAR_WAITING_TIME, edgeID) 47 48 def getEffort(self, edgeID, time): 49 """getEffort(string, double) -> double 50 51 Returns the effort value used for (re-)routing 52 which is valid on the edge at the given time. 53 """ 54 return self._getUniversal(tc.VAR_EDGE_EFFORT, edgeID, "d", time) 55 56 def getCO2Emission(self, edgeID): 57 """getCO2Emission(string) -> double 58 59 Returns the CO2 emission in mg for the last time step on the given edge. 60 """ 61 return self._getUniversal(tc.VAR_CO2EMISSION, edgeID) 62 63 def getCOEmission(self, edgeID): 64 """getCOEmission(string) -> double 65 66 Returns the CO emission in mg for the last time step on the given edge. 67 """ 68 return self._getUniversal(tc.VAR_COEMISSION, edgeID) 69 70 def getHCEmission(self, edgeID): 71 """getHCEmission(string) -> double 72 73 Returns the HC emission in mg for the last time step on the given edge. 74 """ 75 return self._getUniversal(tc.VAR_HCEMISSION, edgeID) 76 77 def getPMxEmission(self, edgeID): 78 """getPMxEmission(string) -> double 79 80 Returns the particular matter emission in mg for the last time step on the given edge. 81 """ 82 return self._getUniversal(tc.VAR_PMXEMISSION, edgeID) 83 84 def getNOxEmission(self, edgeID): 85 """getNOxEmission(string) -> double 86 87 Returns the NOx emission in mg for the last time step on the given edge. 88 """ 89 return self._getUniversal(tc.VAR_NOXEMISSION, edgeID) 90 91 def getFuelConsumption(self, edgeID): 92 """getFuelConsumption(string) -> double 93 94 Returns the fuel consumption in ml for the last time step on the given edge. 95 """ 96 return self._getUniversal(tc.VAR_FUELCONSUMPTION, edgeID) 97 98 def getNoiseEmission(self, edgeID): 99 """getNoiseEmission(string) -> double 100 101 Returns the noise emission in db for the last time step on the given edge. 102 """ 103 return self._getUniversal(tc.VAR_NOISEEMISSION, edgeID) 104 105 def getElectricityConsumption(self, edgeID): 106 """getElectricityConsumption(string) -> double 107 108 Returns the electricity consumption in ml for the last time step. 109 """ 110 return self._getUniversal(tc.VAR_ELECTRICITYCONSUMPTION, edgeID) 111 112 def getLastStepMeanSpeed(self, edgeID): 113 """getLastStepMeanSpeed(string) -> double 114 115 Returns the average speed in m/s for the last time step on the given edge. 116 """ 117 return self._getUniversal(tc.LAST_STEP_MEAN_SPEED, edgeID) 118 119 def getMeanFriction(self, edgeID): 120 """getMeanFriction(string) -> double 121 122 Returns the average friction [0..1] for the last time step over all lanes on the given edge. 123 """ 124 return self._getUniversal(tc.VAR_FRICTION, edgeID) 125 126 def getMaxSpeed(self, edgeID): 127 """getMaxSpeed(string) -> double 128 129 Returns the maximum speed (in m/s) of the first lane of the edge. 130 """ 131 return self._getUniversal(tc.VAR_MAXSPEED, edgeID) 132 133 def getLastStepOccupancy(self, edgeID): 134 """getLastStepOccupancy(string) -> double 135 136 Returns the net occupancy (excluding inter-vehicle gaps) in % for the last time step on the given edge. 137 """ 138 return self._getUniversal(tc.LAST_STEP_OCCUPANCY, edgeID) 139 140 def getLastStepLength(self, edgeID): 141 """getLastStepLength(string) -> double 142 143 Returns the mean vehicle length in m for the last time step on the given edge. 144 """ 145 return self._getUniversal(tc.LAST_STEP_LENGTH, edgeID) 146 147 def getLaneNumber(self, edgeID): 148 """getLaneNumber(string) -> int 149 150 Returns the number of lanes of this edge 151 """ 152 return self._getUniversal(tc.VAR_LANE_INDEX, edgeID) 153 154 def getStreetName(self, edgeID): 155 """getStreetName(string) -> string 156 157 Returns the street name of this edge 158 """ 159 return self._getUniversal(tc.VAR_NAME, edgeID) 160 161 def getTraveltime(self, edgeID): 162 """getTraveltime(string) -> double 163 164 Returns the estimated travel time in s for the last time step on the given edge. 165 """ 166 return self._getUniversal(tc.VAR_CURRENT_TRAVELTIME, edgeID) 167 168 def getLastStepVehicleNumber(self, edgeID): 169 """getLastStepVehicleNumber(string) -> integer 170 171 Returns the total number of vehicles for the last time step on the given edge. 172 """ 173 return self._getUniversal(tc.LAST_STEP_VEHICLE_NUMBER, edgeID) 174 175 def getLastStepHaltingNumber(self, edgeID): 176 """getLastStepHaltingNumber(string) -> integer 177 178 Returns the total number of halting vehicles for the last time step on the given edge. 179 A speed of less than 0.1 m/s is considered a halt. 180 """ 181 return self._getUniversal(tc.LAST_STEP_VEHICLE_HALTING_NUMBER, edgeID) 182 183 def getLastStepVehicleIDs(self, edgeID): 184 """getLastStepVehicleIDs(string) -> tuple(string) 185 186 Returns the ids of the vehicles for the last time step on the given edge. 187 """ 188 return self._getUniversal(tc.LAST_STEP_VEHICLE_ID_LIST, edgeID) 189 190 def getLastStepPersonIDs(self, edgeID): 191 """getLastStepPersonIDs(string) -> tuple(string) 192 193 Returns the ids of the persons on the given edge during the last time step. 194 """ 195 return self._getUniversal(tc.LAST_STEP_PERSON_ID_LIST, edgeID) 196 197 def getPendingVehicles(self, edgeID): 198 """getPendingVehicles(string) -> tuple(string) 199 Returns a tuple of all vehicle ids waiting for insertion on this edge (with depart delay) 200 """ 201 return self._getUniversal(tc.VAR_PENDING_VEHICLES, edgeID) 202 203 def getAngle(self, edgeID, relativePosition=tc.INVALID_DOUBLE_VALUE): 204 """getAngle(string, double) -> double 205 Returns the heading of the straight line segment formed by the first lane of the edge at the given position. 206 If the given position equals TraCI constant INVALID_DOUBLE_VALUE, it returns the total angle 207 formed by the edge, from its start point to its end point. If the edge doesn't have any lanes, 208 then INVALID_DOUBLE_VALUE is returned. 209 """ 210 return self._getUniversal(tc.VAR_ANGLE, edgeID, "d", relativePosition) 211 212 def getFromJunction(self, edgeID): 213 """getFromJunction(string) -> string 214 215 Returns the id of the junction at the start of this edge 216 """ 217 return self._getUniversal(tc.FROM_JUNCTION, edgeID) 218 219 def getToJunction(self, edgeID): 220 """getToJunction(string) -> string 221 222 Returns the id of the junction at the end of this edge 223 """ 224 return self._getUniversal(tc.TO_JUNCTION, edgeID) 225 226 def getBidiEdge(self, edgeID): 227 """getBidiEdge(string) -> string 228 229 Returns the id of the bidi edge or "" 230 """ 231 return self._getUniversal(tc.VAR_BIDI, edgeID) 232 233 def adaptTraveltime(self, edgeID, time, begin=None, end=None): 234 """adaptTraveltime(string, double, double, double) -> None 235 236 Adapt the travel time value (in s) used for (re-)routing for the given edge. 237 238 When setting begin time and end time (in seconds), the changes only 239 apply to that time range. Otherwise they apply all the time. 240 Setting time to INVALID_DOUBLE_VALUE removes all stored travel time 241 information for the edge. 242 """ 243 if begin is None and end is None: 244 self._setCmd(tc.VAR_EDGE_TRAVELTIME, edgeID, "td", 1, time) 245 elif begin is not None and end is not None: 246 self._setCmd(tc.VAR_EDGE_TRAVELTIME, edgeID, "tddd", 3, begin, end, time) 247 else: 248 raise TraCIException("Both, begin time and end time must be specified") 249 250 def setEffort(self, edgeID, effort, begin=None, end=None): 251 """setEffort(string, double, double, double) -> None 252 253 Adapt the effort value used for (re-)routing for the given edge. 254 255 When setting begin time and end time (in seconds), the changes only 256 apply to that time range. Otherwise they apply all the time. 257 """ 258 if begin is None and end is None: 259 self._setCmd(tc.VAR_EDGE_EFFORT, edgeID, "td", 1, effort) 260 elif begin is not None and end is not None: 261 self._setCmd(tc.VAR_EDGE_EFFORT, edgeID, "tddd", 3, begin, end, effort) 262 else: 263 raise TraCIException("Both, begin time and end time must be specified") 264 265 def setAllowed(self, edgeID, allowedClasses): 266 """setAllowed(string, list) -> None 267 268 Sets a list of allowed vehicle classes. Setting an empty list means all vehicles are allowed. 269 """ 270 if isinstance(allowedClasses, str): 271 allowedClasses = [allowedClasses] 272 self._setCmd(tc.LANE_ALLOWED, edgeID, "l", allowedClasses) 273 274 def setDisallowed(self, edgeID, disallowedClasses): 275 """setDisallowed(string, list) -> None 276 277 Sets a list of disallowed vehicle classes. 278 """ 279 if isinstance(disallowedClasses, str): 280 disallowedClasses = [disallowedClasses] 281 self._setCmd(tc.LANE_DISALLOWED, edgeID, "l", disallowedClasses) 282 283 def setMaxSpeed(self, edgeID, speed): 284 """setMaxSpeed(string, double) -> None 285 286 Set a new maximum speed (in m/s) for all lanes of the edge. 287 """ 288 self._setCmd(tc.VAR_MAXSPEED, edgeID, "d", speed) 289 290 def setFriction(self, edgeID, friction): 291 """setFriction(string, double) -> None 292 293 Set a new friction value [0..1] for all lanes of the edge. 294 """ 295 self._setCmd(tc.VAR_FRICTION, edgeID, "d", friction)
26class EdgeDomain(Domain): 27 28 def __init__(self): 29 Domain.__init__(self, "edge", tc.CMD_GET_EDGE_VARIABLE, tc.CMD_SET_EDGE_VARIABLE, 30 tc.CMD_SUBSCRIBE_EDGE_VARIABLE, tc.RESPONSE_SUBSCRIBE_EDGE_VARIABLE, 31 tc.CMD_SUBSCRIBE_EDGE_CONTEXT, tc.RESPONSE_SUBSCRIBE_EDGE_CONTEXT, 32 subscriptionDefault=(tc.LAST_STEP_VEHICLE_NUMBER,)) 33 34 def getAdaptedTraveltime(self, edgeID, time): 35 """getAdaptedTraveltime(string, double) -> double 36 37 Returns the travel time value (in s) used for (re-)routing 38 which is valid on the edge at the given time. 39 """ 40 return self._getUniversal(tc.VAR_EDGE_TRAVELTIME, edgeID, "d", time) 41 42 def getWaitingTime(self, edgeID): 43 """getWaitingTime(string) -> double 44 Returns the sum of the waiting time of all vehicles currently on 45 that edge (see traci.vehicle.getWaitingTime). 46 """ 47 return self._getUniversal(tc.VAR_WAITING_TIME, edgeID) 48 49 def getEffort(self, edgeID, time): 50 """getEffort(string, double) -> double 51 52 Returns the effort value used for (re-)routing 53 which is valid on the edge at the given time. 54 """ 55 return self._getUniversal(tc.VAR_EDGE_EFFORT, edgeID, "d", time) 56 57 def getCO2Emission(self, edgeID): 58 """getCO2Emission(string) -> double 59 60 Returns the CO2 emission in mg for the last time step on the given edge. 61 """ 62 return self._getUniversal(tc.VAR_CO2EMISSION, edgeID) 63 64 def getCOEmission(self, edgeID): 65 """getCOEmission(string) -> double 66 67 Returns the CO emission in mg for the last time step on the given edge. 68 """ 69 return self._getUniversal(tc.VAR_COEMISSION, edgeID) 70 71 def getHCEmission(self, edgeID): 72 """getHCEmission(string) -> double 73 74 Returns the HC emission in mg for the last time step on the given edge. 75 """ 76 return self._getUniversal(tc.VAR_HCEMISSION, edgeID) 77 78 def getPMxEmission(self, edgeID): 79 """getPMxEmission(string) -> double 80 81 Returns the particular matter emission in mg for the last time step on the given edge. 82 """ 83 return self._getUniversal(tc.VAR_PMXEMISSION, edgeID) 84 85 def getNOxEmission(self, edgeID): 86 """getNOxEmission(string) -> double 87 88 Returns the NOx emission in mg for the last time step on the given edge. 89 """ 90 return self._getUniversal(tc.VAR_NOXEMISSION, edgeID) 91 92 def getFuelConsumption(self, edgeID): 93 """getFuelConsumption(string) -> double 94 95 Returns the fuel consumption in ml for the last time step on the given edge. 96 """ 97 return self._getUniversal(tc.VAR_FUELCONSUMPTION, edgeID) 98 99 def getNoiseEmission(self, edgeID): 100 """getNoiseEmission(string) -> double 101 102 Returns the noise emission in db for the last time step on the given edge. 103 """ 104 return self._getUniversal(tc.VAR_NOISEEMISSION, edgeID) 105 106 def getElectricityConsumption(self, edgeID): 107 """getElectricityConsumption(string) -> double 108 109 Returns the electricity consumption in ml for the last time step. 110 """ 111 return self._getUniversal(tc.VAR_ELECTRICITYCONSUMPTION, edgeID) 112 113 def getLastStepMeanSpeed(self, edgeID): 114 """getLastStepMeanSpeed(string) -> double 115 116 Returns the average speed in m/s for the last time step on the given edge. 117 """ 118 return self._getUniversal(tc.LAST_STEP_MEAN_SPEED, edgeID) 119 120 def getMeanFriction(self, edgeID): 121 """getMeanFriction(string) -> double 122 123 Returns the average friction [0..1] for the last time step over all lanes on the given edge. 124 """ 125 return self._getUniversal(tc.VAR_FRICTION, edgeID) 126 127 def getMaxSpeed(self, edgeID): 128 """getMaxSpeed(string) -> double 129 130 Returns the maximum speed (in m/s) of the first lane of the edge. 131 """ 132 return self._getUniversal(tc.VAR_MAXSPEED, edgeID) 133 134 def getLastStepOccupancy(self, edgeID): 135 """getLastStepOccupancy(string) -> double 136 137 Returns the net occupancy (excluding inter-vehicle gaps) in % for the last time step on the given edge. 138 """ 139 return self._getUniversal(tc.LAST_STEP_OCCUPANCY, edgeID) 140 141 def getLastStepLength(self, edgeID): 142 """getLastStepLength(string) -> double 143 144 Returns the mean vehicle length in m for the last time step on the given edge. 145 """ 146 return self._getUniversal(tc.LAST_STEP_LENGTH, edgeID) 147 148 def getLaneNumber(self, edgeID): 149 """getLaneNumber(string) -> int 150 151 Returns the number of lanes of this edge 152 """ 153 return self._getUniversal(tc.VAR_LANE_INDEX, edgeID) 154 155 def getStreetName(self, edgeID): 156 """getStreetName(string) -> string 157 158 Returns the street name of this edge 159 """ 160 return self._getUniversal(tc.VAR_NAME, edgeID) 161 162 def getTraveltime(self, edgeID): 163 """getTraveltime(string) -> double 164 165 Returns the estimated travel time in s for the last time step on the given edge. 166 """ 167 return self._getUniversal(tc.VAR_CURRENT_TRAVELTIME, edgeID) 168 169 def getLastStepVehicleNumber(self, edgeID): 170 """getLastStepVehicleNumber(string) -> integer 171 172 Returns the total number of vehicles for the last time step on the given edge. 173 """ 174 return self._getUniversal(tc.LAST_STEP_VEHICLE_NUMBER, edgeID) 175 176 def getLastStepHaltingNumber(self, edgeID): 177 """getLastStepHaltingNumber(string) -> integer 178 179 Returns the total number of halting vehicles for the last time step on the given edge. 180 A speed of less than 0.1 m/s is considered a halt. 181 """ 182 return self._getUniversal(tc.LAST_STEP_VEHICLE_HALTING_NUMBER, edgeID) 183 184 def getLastStepVehicleIDs(self, edgeID): 185 """getLastStepVehicleIDs(string) -> tuple(string) 186 187 Returns the ids of the vehicles for the last time step on the given edge. 188 """ 189 return self._getUniversal(tc.LAST_STEP_VEHICLE_ID_LIST, edgeID) 190 191 def getLastStepPersonIDs(self, edgeID): 192 """getLastStepPersonIDs(string) -> tuple(string) 193 194 Returns the ids of the persons on the given edge during the last time step. 195 """ 196 return self._getUniversal(tc.LAST_STEP_PERSON_ID_LIST, edgeID) 197 198 def getPendingVehicles(self, edgeID): 199 """getPendingVehicles(string) -> tuple(string) 200 Returns a tuple of all vehicle ids waiting for insertion on this edge (with depart delay) 201 """ 202 return self._getUniversal(tc.VAR_PENDING_VEHICLES, edgeID) 203 204 def getAngle(self, edgeID, relativePosition=tc.INVALID_DOUBLE_VALUE): 205 """getAngle(string, double) -> double 206 Returns the heading of the straight line segment formed by the first lane of the edge at the given position. 207 If the given position equals TraCI constant INVALID_DOUBLE_VALUE, it returns the total angle 208 formed by the edge, from its start point to its end point. If the edge doesn't have any lanes, 209 then INVALID_DOUBLE_VALUE is returned. 210 """ 211 return self._getUniversal(tc.VAR_ANGLE, edgeID, "d", relativePosition) 212 213 def getFromJunction(self, edgeID): 214 """getFromJunction(string) -> string 215 216 Returns the id of the junction at the start of this edge 217 """ 218 return self._getUniversal(tc.FROM_JUNCTION, edgeID) 219 220 def getToJunction(self, edgeID): 221 """getToJunction(string) -> string 222 223 Returns the id of the junction at the end of this edge 224 """ 225 return self._getUniversal(tc.TO_JUNCTION, edgeID) 226 227 def getBidiEdge(self, edgeID): 228 """getBidiEdge(string) -> string 229 230 Returns the id of the bidi edge or "" 231 """ 232 return self._getUniversal(tc.VAR_BIDI, edgeID) 233 234 def adaptTraveltime(self, edgeID, time, begin=None, end=None): 235 """adaptTraveltime(string, double, double, double) -> None 236 237 Adapt the travel time value (in s) used for (re-)routing for the given edge. 238 239 When setting begin time and end time (in seconds), the changes only 240 apply to that time range. Otherwise they apply all the time. 241 Setting time to INVALID_DOUBLE_VALUE removes all stored travel time 242 information for the edge. 243 """ 244 if begin is None and end is None: 245 self._setCmd(tc.VAR_EDGE_TRAVELTIME, edgeID, "td", 1, time) 246 elif begin is not None and end is not None: 247 self._setCmd(tc.VAR_EDGE_TRAVELTIME, edgeID, "tddd", 3, begin, end, time) 248 else: 249 raise TraCIException("Both, begin time and end time must be specified") 250 251 def setEffort(self, edgeID, effort, begin=None, end=None): 252 """setEffort(string, double, double, double) -> None 253 254 Adapt the effort value used for (re-)routing for the given edge. 255 256 When setting begin time and end time (in seconds), the changes only 257 apply to that time range. Otherwise they apply all the time. 258 """ 259 if begin is None and end is None: 260 self._setCmd(tc.VAR_EDGE_EFFORT, edgeID, "td", 1, effort) 261 elif begin is not None and end is not None: 262 self._setCmd(tc.VAR_EDGE_EFFORT, edgeID, "tddd", 3, begin, end, effort) 263 else: 264 raise TraCIException("Both, begin time and end time must be specified") 265 266 def setAllowed(self, edgeID, allowedClasses): 267 """setAllowed(string, list) -> None 268 269 Sets a list of allowed vehicle classes. Setting an empty list means all vehicles are allowed. 270 """ 271 if isinstance(allowedClasses, str): 272 allowedClasses = [allowedClasses] 273 self._setCmd(tc.LANE_ALLOWED, edgeID, "l", allowedClasses) 274 275 def setDisallowed(self, edgeID, disallowedClasses): 276 """setDisallowed(string, list) -> None 277 278 Sets a list of disallowed vehicle classes. 279 """ 280 if isinstance(disallowedClasses, str): 281 disallowedClasses = [disallowedClasses] 282 self._setCmd(tc.LANE_DISALLOWED, edgeID, "l", disallowedClasses) 283 284 def setMaxSpeed(self, edgeID, speed): 285 """setMaxSpeed(string, double) -> None 286 287 Set a new maximum speed (in m/s) for all lanes of the edge. 288 """ 289 self._setCmd(tc.VAR_MAXSPEED, edgeID, "d", speed) 290 291 def setFriction(self, edgeID, friction): 292 """setFriction(string, double) -> None 293 294 Set a new friction value [0..1] for all lanes of the edge. 295 """ 296 self._setCmd(tc.VAR_FRICTION, edgeID, "d", friction)
34 def getAdaptedTraveltime(self, edgeID, time): 35 """getAdaptedTraveltime(string, double) -> double 36 37 Returns the travel time value (in s) used for (re-)routing 38 which is valid on the edge at the given time. 39 """ 40 return self._getUniversal(tc.VAR_EDGE_TRAVELTIME, edgeID, "d", time)
getAdaptedTraveltime(string, double) -> double
Returns the travel time value (in s) used for (re-)routing which is valid on the edge at the given time.
42 def getWaitingTime(self, edgeID): 43 """getWaitingTime(string) -> double 44 Returns the sum of the waiting time of all vehicles currently on 45 that edge (see traci.vehicle.getWaitingTime). 46 """ 47 return self._getUniversal(tc.VAR_WAITING_TIME, edgeID)
getWaitingTime(string) -> double Returns the sum of the waiting time of all vehicles currently on that edge (see traci.vehicle.getWaitingTime).
49 def getEffort(self, edgeID, time): 50 """getEffort(string, double) -> double 51 52 Returns the effort value used for (re-)routing 53 which is valid on the edge at the given time. 54 """ 55 return self._getUniversal(tc.VAR_EDGE_EFFORT, edgeID, "d", time)
getEffort(string, double) -> double
Returns the effort value used for (re-)routing which is valid on the edge at the given time.
57 def getCO2Emission(self, edgeID): 58 """getCO2Emission(string) -> double 59 60 Returns the CO2 emission in mg for the last time step on the given edge. 61 """ 62 return self._getUniversal(tc.VAR_CO2EMISSION, edgeID)
getCO2Emission(string) -> double
Returns the CO2 emission in mg for the last time step on the given edge.
64 def getCOEmission(self, edgeID): 65 """getCOEmission(string) -> double 66 67 Returns the CO emission in mg for the last time step on the given edge. 68 """ 69 return self._getUniversal(tc.VAR_COEMISSION, edgeID)
getCOEmission(string) -> double
Returns the CO emission in mg for the last time step on the given edge.
71 def getHCEmission(self, edgeID): 72 """getHCEmission(string) -> double 73 74 Returns the HC emission in mg for the last time step on the given edge. 75 """ 76 return self._getUniversal(tc.VAR_HCEMISSION, edgeID)
getHCEmission(string) -> double
Returns the HC emission in mg for the last time step on the given edge.
78 def getPMxEmission(self, edgeID): 79 """getPMxEmission(string) -> double 80 81 Returns the particular matter emission in mg for the last time step on the given edge. 82 """ 83 return self._getUniversal(tc.VAR_PMXEMISSION, edgeID)
getPMxEmission(string) -> double
Returns the particular matter emission in mg for the last time step on the given edge.
85 def getNOxEmission(self, edgeID): 86 """getNOxEmission(string) -> double 87 88 Returns the NOx emission in mg for the last time step on the given edge. 89 """ 90 return self._getUniversal(tc.VAR_NOXEMISSION, edgeID)
getNOxEmission(string) -> double
Returns the NOx emission in mg for the last time step on the given edge.
92 def getFuelConsumption(self, edgeID): 93 """getFuelConsumption(string) -> double 94 95 Returns the fuel consumption in ml for the last time step on the given edge. 96 """ 97 return self._getUniversal(tc.VAR_FUELCONSUMPTION, edgeID)
getFuelConsumption(string) -> double
Returns the fuel consumption in ml for the last time step on the given edge.
99 def getNoiseEmission(self, edgeID): 100 """getNoiseEmission(string) -> double 101 102 Returns the noise emission in db for the last time step on the given edge. 103 """ 104 return self._getUniversal(tc.VAR_NOISEEMISSION, edgeID)
getNoiseEmission(string) -> double
Returns the noise emission in db for the last time step on the given edge.
106 def getElectricityConsumption(self, edgeID): 107 """getElectricityConsumption(string) -> double 108 109 Returns the electricity consumption in ml for the last time step. 110 """ 111 return self._getUniversal(tc.VAR_ELECTRICITYCONSUMPTION, edgeID)
getElectricityConsumption(string) -> double
Returns the electricity consumption in ml for the last time step.
113 def getLastStepMeanSpeed(self, edgeID): 114 """getLastStepMeanSpeed(string) -> double 115 116 Returns the average speed in m/s for the last time step on the given edge. 117 """ 118 return self._getUniversal(tc.LAST_STEP_MEAN_SPEED, edgeID)
getLastStepMeanSpeed(string) -> double
Returns the average speed in m/s for the last time step on the given edge.
120 def getMeanFriction(self, edgeID): 121 """getMeanFriction(string) -> double 122 123 Returns the average friction [0..1] for the last time step over all lanes on the given edge. 124 """ 125 return self._getUniversal(tc.VAR_FRICTION, edgeID)
getMeanFriction(string) -> double
Returns the average friction [0..1] for the last time step over all lanes on the given edge.
127 def getMaxSpeed(self, edgeID): 128 """getMaxSpeed(string) -> double 129 130 Returns the maximum speed (in m/s) of the first lane of the edge. 131 """ 132 return self._getUniversal(tc.VAR_MAXSPEED, edgeID)
getMaxSpeed(string) -> double
Returns the maximum speed (in m/s) of the first lane of the edge.
134 def getLastStepOccupancy(self, edgeID): 135 """getLastStepOccupancy(string) -> double 136 137 Returns the net occupancy (excluding inter-vehicle gaps) in % for the last time step on the given edge. 138 """ 139 return self._getUniversal(tc.LAST_STEP_OCCUPANCY, edgeID)
getLastStepOccupancy(string) -> double
Returns the net occupancy (excluding inter-vehicle gaps) in % for the last time step on the given edge.
141 def getLastStepLength(self, edgeID): 142 """getLastStepLength(string) -> double 143 144 Returns the mean vehicle length in m for the last time step on the given edge. 145 """ 146 return self._getUniversal(tc.LAST_STEP_LENGTH, edgeID)
getLastStepLength(string) -> double
Returns the mean vehicle length in m for the last time step on the given edge.
148 def getLaneNumber(self, edgeID): 149 """getLaneNumber(string) -> int 150 151 Returns the number of lanes of this edge 152 """ 153 return self._getUniversal(tc.VAR_LANE_INDEX, edgeID)
getLaneNumber(string) -> int
Returns the number of lanes of this edge
155 def getStreetName(self, edgeID): 156 """getStreetName(string) -> string 157 158 Returns the street name of this edge 159 """ 160 return self._getUniversal(tc.VAR_NAME, edgeID)
getStreetName(string) -> string
Returns the street name of this edge
162 def getTraveltime(self, edgeID): 163 """getTraveltime(string) -> double 164 165 Returns the estimated travel time in s for the last time step on the given edge. 166 """ 167 return self._getUniversal(tc.VAR_CURRENT_TRAVELTIME, edgeID)
getTraveltime(string) -> double
Returns the estimated travel time in s for the last time step on the given edge.
169 def getLastStepVehicleNumber(self, edgeID): 170 """getLastStepVehicleNumber(string) -> integer 171 172 Returns the total number of vehicles for the last time step on the given edge. 173 """ 174 return self._getUniversal(tc.LAST_STEP_VEHICLE_NUMBER, edgeID)
getLastStepVehicleNumber(string) -> integer
Returns the total number of vehicles for the last time step on the given edge.
176 def getLastStepHaltingNumber(self, edgeID): 177 """getLastStepHaltingNumber(string) -> integer 178 179 Returns the total number of halting vehicles for the last time step on the given edge. 180 A speed of less than 0.1 m/s is considered a halt. 181 """ 182 return self._getUniversal(tc.LAST_STEP_VEHICLE_HALTING_NUMBER, edgeID)
getLastStepHaltingNumber(string) -> integer
Returns the total number of halting vehicles for the last time step on the given edge. A speed of less than 0.1 m/s is considered a halt.
184 def getLastStepVehicleIDs(self, edgeID): 185 """getLastStepVehicleIDs(string) -> tuple(string) 186 187 Returns the ids of the vehicles for the last time step on the given edge. 188 """ 189 return self._getUniversal(tc.LAST_STEP_VEHICLE_ID_LIST, edgeID)
getLastStepVehicleIDs(string) -> tuple(string)
Returns the ids of the vehicles for the last time step on the given edge.
191 def getLastStepPersonIDs(self, edgeID): 192 """getLastStepPersonIDs(string) -> tuple(string) 193 194 Returns the ids of the persons on the given edge during the last time step. 195 """ 196 return self._getUniversal(tc.LAST_STEP_PERSON_ID_LIST, edgeID)
getLastStepPersonIDs(string) -> tuple(string)
Returns the ids of the persons on the given edge during the last time step.
198 def getPendingVehicles(self, edgeID): 199 """getPendingVehicles(string) -> tuple(string) 200 Returns a tuple of all vehicle ids waiting for insertion on this edge (with depart delay) 201 """ 202 return self._getUniversal(tc.VAR_PENDING_VEHICLES, edgeID)
getPendingVehicles(string) -> tuple(string) Returns a tuple of all vehicle ids waiting for insertion on this edge (with depart delay)
204 def getAngle(self, edgeID, relativePosition=tc.INVALID_DOUBLE_VALUE): 205 """getAngle(string, double) -> double 206 Returns the heading of the straight line segment formed by the first lane of the edge at the given position. 207 If the given position equals TraCI constant INVALID_DOUBLE_VALUE, it returns the total angle 208 formed by the edge, from its start point to its end point. If the edge doesn't have any lanes, 209 then INVALID_DOUBLE_VALUE is returned. 210 """ 211 return self._getUniversal(tc.VAR_ANGLE, edgeID, "d", relativePosition)
getAngle(string, double) -> double Returns the heading of the straight line segment formed by the first lane of the edge at the given position. If the given position equals TraCI constant INVALID_DOUBLE_VALUE, it returns the total angle formed by the edge, from its start point to its end point. If the edge doesn't have any lanes, then INVALID_DOUBLE_VALUE is returned.
213 def getFromJunction(self, edgeID): 214 """getFromJunction(string) -> string 215 216 Returns the id of the junction at the start of this edge 217 """ 218 return self._getUniversal(tc.FROM_JUNCTION, edgeID)
getFromJunction(string) -> string
Returns the id of the junction at the start of this edge
220 def getToJunction(self, edgeID): 221 """getToJunction(string) -> string 222 223 Returns the id of the junction at the end of this edge 224 """ 225 return self._getUniversal(tc.TO_JUNCTION, edgeID)
getToJunction(string) -> string
Returns the id of the junction at the end of this edge
227 def getBidiEdge(self, edgeID): 228 """getBidiEdge(string) -> string 229 230 Returns the id of the bidi edge or "" 231 """ 232 return self._getUniversal(tc.VAR_BIDI, edgeID)
getBidiEdge(string) -> string
Returns the id of the bidi edge or ""
234 def adaptTraveltime(self, edgeID, time, begin=None, end=None): 235 """adaptTraveltime(string, double, double, double) -> None 236 237 Adapt the travel time value (in s) used for (re-)routing for the given edge. 238 239 When setting begin time and end time (in seconds), the changes only 240 apply to that time range. Otherwise they apply all the time. 241 Setting time to INVALID_DOUBLE_VALUE removes all stored travel time 242 information for the edge. 243 """ 244 if begin is None and end is None: 245 self._setCmd(tc.VAR_EDGE_TRAVELTIME, edgeID, "td", 1, time) 246 elif begin is not None and end is not None: 247 self._setCmd(tc.VAR_EDGE_TRAVELTIME, edgeID, "tddd", 3, begin, end, time) 248 else: 249 raise TraCIException("Both, begin time and end time must be specified")
adaptTraveltime(string, double, double, double) -> None
Adapt the travel time value (in s) used for (re-)routing for the given edge.
When setting begin time and end time (in seconds), the changes only apply to that time range. Otherwise they apply all the time. Setting time to INVALID_DOUBLE_VALUE removes all stored travel time information for the edge.
251 def setEffort(self, edgeID, effort, begin=None, end=None): 252 """setEffort(string, double, double, double) -> None 253 254 Adapt the effort value used for (re-)routing for the given edge. 255 256 When setting begin time and end time (in seconds), the changes only 257 apply to that time range. Otherwise they apply all the time. 258 """ 259 if begin is None and end is None: 260 self._setCmd(tc.VAR_EDGE_EFFORT, edgeID, "td", 1, effort) 261 elif begin is not None and end is not None: 262 self._setCmd(tc.VAR_EDGE_EFFORT, edgeID, "tddd", 3, begin, end, effort) 263 else: 264 raise TraCIException("Both, begin time and end time must be specified")
setEffort(string, double, double, double) -> None
Adapt the effort value used for (re-)routing for the given edge.
When setting begin time and end time (in seconds), the changes only apply to that time range. Otherwise they apply all the time.
266 def setAllowed(self, edgeID, allowedClasses): 267 """setAllowed(string, list) -> None 268 269 Sets a list of allowed vehicle classes. Setting an empty list means all vehicles are allowed. 270 """ 271 if isinstance(allowedClasses, str): 272 allowedClasses = [allowedClasses] 273 self._setCmd(tc.LANE_ALLOWED, edgeID, "l", allowedClasses)
setAllowed(string, list) -> None
Sets a list of allowed vehicle classes. Setting an empty list means all vehicles are allowed.
275 def setDisallowed(self, edgeID, disallowedClasses): 276 """setDisallowed(string, list) -> None 277 278 Sets a list of disallowed vehicle classes. 279 """ 280 if isinstance(disallowedClasses, str): 281 disallowedClasses = [disallowedClasses] 282 self._setCmd(tc.LANE_DISALLOWED, edgeID, "l", disallowedClasses)
setDisallowed(string, list) -> None
Sets a list of disallowed vehicle classes.
284 def setMaxSpeed(self, edgeID, speed): 285 """setMaxSpeed(string, double) -> None 286 287 Set a new maximum speed (in m/s) for all lanes of the edge. 288 """ 289 self._setCmd(tc.VAR_MAXSPEED, edgeID, "d", speed)
setMaxSpeed(string, double) -> None
Set a new maximum speed (in m/s) for all lanes of the edge.
291 def setFriction(self, edgeID, friction): 292 """setFriction(string, double) -> None 293 294 Set a new friction value [0..1] for all lanes of the edge. 295 """ 296 self._setCmd(tc.VAR_FRICTION, edgeID, "d", friction)
setFriction(string, double) -> None
Set a new friction value [0..1] for all lanes of the edge.
Inherited Members
- traci.domain.Domain
- DOMAIN_ID
- getIDList
- getIDCount
- domainID
- subscribe
- unsubscribe
- getSubscriptionResults
- getAllSubscriptionResults
- subscribeContext
- unsubscribeContext
- getContextSubscriptionResults
- getAllContextSubscriptionResults
- getParameter
- getParameterWithKey
- subscribeParameterWithKey
- setParameter