车辆值检索

命令 0xa4: 获取车辆变量#

ubyte string
变量 (Variable) 车辆ID (Vehicle ID)

请求指定车辆的某个变量的值。返回的值是上一个仿真步长内所请求变量/值的状态。如果车辆已加载但位于路网之外(由于尚未插入路网或在当前时间步内被瞬移),则返回默认的“错误”值。

以下变量值可以被检索和订阅。返回值的类型也在表中显示。无法订阅下一站 (0x73)。

**可检索车辆变量概览**

变量

值类型

描述

Python 方法

id list (0x00)

stringList

返回当前场景中所有正在运行的车辆的ID列表(给定的车辆ID被忽略)

getIDList

count (0x01)

int

返回当前场景中正在运行的车辆数量(给定的车辆ID被忽略)

getIDCount

speed (0x40)

double

返回指定车辆在上一步长内的速度 [m/s];错误值:-2^30

getSpeed

lateral speed (0x32)

double

返回指定车辆在上一步长内的横向速度 [m/s];错误值:-2^30

getLateralSpeed

acceleration (0x72)

double

返回上一时间步长内的加速度 [m/s^2]

getAcceleration

position (0x42)

position

返回指定车辆在上一步长内的位置(前保险杠中心),两个双精度浮点数 [m,m];错误值:[-2^30, -2^30]。

getPosition

position 3D (0x39)

position

返回指定车辆在上一步长内的3D位置(前保险杠中心),三个双精度浮点数 [m,m,m];错误值:[-2^30, -2^30, -2^30]。

getPosition3D

angle (0x43)

double

返回指定车辆在上一步长内的角度 [°];错误值:-2^30

getAngle

road id (0x50)

string

返回指定车辆在上一步长内所在的边的ID;错误值:""

getRoadID

lane id (0x51)

string

返回指定车辆在上一步长内所在的车道的ID;错误值:""

getLaneID

lane index (0x52)

int

返回指定车辆在上一步长内所在的车道的索引;错误值:-2^30

getLaneIndex

type id (0x4f)

string

返回指定车辆的类型ID

getTypeID

route id (0x53)

string

返回指定车辆的路径ID

getRouteID

route index (0x69)

int

返回车辆路径中当前边的索引,如果车辆尚未出发则返回-1

getRouteIndex

edges (0x54)

stringList

返回车辆路径所包含的边的ID列表

getRoute

color (0x45)

ubyte,ubyte,ubyte,ubyte

返回车辆的颜色 (RGBA)。这不返回GUI中当前可见的颜色,而是返回在XML文件中或通过TraCI设置的颜色值。

getColor

lane position (0x56)

double

车辆沿车道的位置(前保险杠到车道起点的距离)[m];错误值:-2^30

getLanePosition

distance (0x84)

double

车辆已经行驶的距离 ([m]);错误值:-2^30

getDistance

signal states (0x5b)

int

一个整数,编码车辆信号的状态,更多信息请参见 TraCI/车辆信号

getSignals

routing mode (0x89)

int

一个整数,编码 当前路径模式 (0: 默认, 1: 聚合)

getRoutingMode

TaxiFleet (0x20)

stringList

返回给定模式的所有出租车列表:(-1: 所有, 0 : 空车, 1 : 接客中, 2 : 载客中, 3: 接客+载客)。注意:处于接客+载客状态(由于拼车)的车辆在请求模式1或2时也会被返回。

getTaxiFleet

CO2 emissions
(id 0x60)

double

车辆在此时间步长内的CO2排放量(mg/s),要获得单步的值,请乘以步长;错误值:-2^30

getCO2Emission

CO emissions
(id 0x61)

double

车辆在此时间步长内的CO排放量(mg/s),要获得单步的值,请乘以步长;错误值:-2^30

getCOEmission

HC emissions
(id 0x62)

double

车辆在此时间步长内的HC排放量(mg/s),要获得单步的值,请乘以步长;错误值:-2^30

getHCEmission

PMx emissions
(id 0x63)

double

车辆在此时间步长内的PMx排放量(mg/s),要获得单步的值,请乘以步长;错误值:-2^30

getPMxEmission

NOx emissions
(id 0x64)

double

车辆在此时间步长内的NOx排放量(mg/s),要获得单步的值,请乘以步长;错误值:-2^30

getNOxEmission

fuel consumption
(id 0x65)

double

车辆在此时间步长内的燃油消耗量(mg/s),要获得单步的值,请乘以步长;错误值:-2^30

getFuelConsumption

noise emission
(id 0x66)

double

车辆产生的噪音(dBA);错误值:-2^30

getNoiseEmission

electricity consumption (id 0x71)

double

车辆在此时间步长内的电力消耗(Wh/s),要获得单步的值,请乘以步长;错误值:-2^30

getElectricityConsumption

best lanes (id 0xb2)

complex

对于当前边上的每条车道,返回将从该车道开始且不进行换道的车道序列,以及有关换道意愿的信息(见下文)。

getBestLanes

stop state (id 0xb5)

int

value = 1 * stopped + 2 * parking + 4 * triggered + 8 * containerTriggered + 16 * atBusStop + 32 * atContainerStop + 64 * atChargingStation + 128 * atParkingArea

getStopState
isAtBusStop
isAtContainerStop
isStopped
isStoppedParking
isStoppedTriggered

length (0x44)

double

返回车辆的长度 [m]

getLength

vmax (0x41)

double

返回车辆的最大速度 [m/s]

getMaxSpeed

accel (0x46)

double

返回该车辆的最大加速度可能性 [m/s^2]

getAccel

decel (0x47)

double

返回该车辆的最大减速度可能性 [m/s^2]

getDecel

tau (0x48)

double

返回该车辆驾驶员期望的时间间距 [s]

getTau

sigma (0x5d)

double

返回驾驶员的不完美度(游荡)[0,1]

getImperfection

speedFactor (0x5e)

double

返回该车辆的道路速度乘数 [double]

getSpeedFactor

speedDev (0x5f)

double

返回该车辆的speedFactor偏差 [double]

getSpeedDeviation

vClass (0x49)

string

返回该车辆的许可类别

getVehicleClass

emission_class (0x4a)

string

返回该车辆的排放类别

getEmissionClass

shape (0x4b)

string

返回该车辆的形状类别

getShapeClass

minGap (0x4c)

double

返回该车辆的偏移量(停车时与前车的间距)[m]

getMinGap

width (0x4d)

double

返回该车辆的宽度 [m]

getWidth

height (0xbc)

double

返回该车辆的高度 [m]

getHeight

person capacity (0x38)

int

返回该车辆可容纳的总人数

getPersonCapacity

waiting time (0x7a)

double

返回该车辆连续静止的时间 [s](不包括自愿停车)

getWaitingTime

accumulated waiting time (0x87)

double

返回在前一个时间间隔内(默认长度为100 s)的累积等待时间 [s]。(长度可通过向主应用程序提供选项 --waiting-time-memory 进行配置)

getAccumulatedWaitingTime

next TLS (0x70)

complex

返回即将到达的交通信号灯,以及距离和状态

getNextTLS

next stops (0x73)

complex

返回即将停靠的站点列表,每个站点为一个复合结构 (laneID, endPos, ID, flags, duration, until)。如果设置了标志1(stop reached),则duration编码剩余的持续时间。负值表示在停车后被阻止重新进入交通流。此函数已弃用,请改用 stops (0x74)。

getNextStops

person id list (0x1a)

stringList

返回人员列表,包括使用属性 'personNumber' 定义的人员以及乘坐此车辆的 <person> 对象。

getPersonIDList

speed mode (0xb3)

int bitset (见下文)

检索由 speed (0x40) 和 slowdown (0x14) 设置的值应如何处理。详情请参见 设置 speedmode 命令

getSpeedMode

lane change mode (0xb6)

int bitset (见 下文)

获取有关一般换道以及TraCI换道请求如何执行的信息。

getLaneChangeMode

slope (0x36)

double

检索当前车辆位置的坡度(以度为单位)

getSlope

allowed speed (0xb7)

double

返回当前车道上关于该车辆速度因子的最大允许速度(m/s)。

getAllowedSpeed

line (0xbd)

string

返回该车辆的线路信息。

getLine

Person Number(0x67)

int

返回总人数,包括使用属性 'personNumber' 定义的人员以及乘坐此车辆的 <person> 对象。

getPersonNumber

via edges(0xbe)

stringList

返回该车辆的经由边的ID列表。

getVia

speed without TraCI (0xb1)

double

返回如果未给出setSpeed或slowDown等速度影响命令,车辆将行驶的速度。

getSpeedWithoutTraCI

valid route (0x92)

bool

返回当前车辆路径对于给定车辆的车辆类别是否连通。

isRouteValid

lateral lane position (0xb8)

double

返回车辆在其当前车道上的横向位置,以米为单位。

getLateralLanePosition

max lateral speed (0xba)

double

返回该车辆的最大横向速度(m/s)。

getMaxSpeedLat

boarding duration (0x2f)

double

返回车辆的登车持续时间(s)

getBoarding

current impatience (0x26)

double

返回该车辆的当前[动态不耐烦度](../Definition_of_Vehicles%2C_Vehicle_Types%2C_and_Routes.md#impatience)。

getImpatience

lateral gap (0xbb)

double

返回该车辆在50km/h时的期望横向间距(m)。

getMinGapLat

lateral alignment (0xb9)

string

返回车辆的首选横向对齐方式。

getLateralAlignment

parameter (0x7e)

string

返回给定字符串参数的值

getParameter

action step length (0x7d)

double

返回车辆当前的动作步长(s)。

getActionStepLength

last action time (0x7f)

double

返回上一个动作步长的时间(s)。

getLastActionTime

stops (0x74)

complex

返回下一个或最后n个停靠点的列表,作为StopData对象。

getStops

timeLoss (0x8c)

double

返回车辆的累积时间损失(s)

getTimeLoss

loaded list (0x24)

stringList

返回所有已加载但尚未到达的车辆ID列表。这包括计划在未来出发的车辆。

getLoadedIDList

teleporting list (0x25)

stringList

返回所有当前正在瞬移/跳跃的车辆列表

getTeleportingIDList

next links (0x33)

complex

返回即将到达的连接器列表,每个连接器包含有关 (lane, via, priority, opened, foe, state, direction, length) 的信息

getNextLinks

actual departure time (0x3a)

double

返回实际出发时间(在可能排队等待插入之后)

getDeparture

departure delay (0x3b)

double

返回计划出发时间与实际出发时间之间的时间差

getDepartDelay

segment id (0xa1)

string

返回车辆正在行驶的路段ID(mesosim)

getSegmentID

segment index (0xa2)

int

返回车辆正在行驶的路段索引(mesosim)

getDepartSegmentIndex

mass (0xc8)

double

返回车辆的质量

getMass

响应 0xb4: 车辆变量#

ubyte string ubyte <return_type>
变量 (Variable) 车辆ID (Vehicle ID) 变量的返回类型 <VARIABLE_VALUE>

"命令 获取车辆变量" 的响应。

next stops (0x73)

byte int ...
值类型 compound 后续停靠点信息的数量 停靠点信息

每个停靠点信息为:

byte string byte double byte string byte integer byte double byte double
值类型 string lane-id 值类型 double endPos 值类型 string stoppingPlaceID 值类型 integer stopFlags (位集, 见 setStop()) 值类型 double 持续时间(秒) 值类型 double until(秒)

best lanes (0xb2)

byte int ...
值类型 compound 后续边信息的数量 边信息

每条边信息为:

byte string byte double byte double byte byte (signed) byte byte (unsigned) byte stringList
值类型 string lane-id 值类型 double length 值类型 double occupation 值类型 byte 偏移到最佳车道 值类型 ubyte 0: 车道不可用于继续行驶, 1: 可以使用 值类型 stringlist 最佳后续车道列表

扩展检索消息#

一些进一步的消息需要额外的参数。

**扩展变量检索概览**

变量

请求值类型

响应值类型

描述

Python 方法

edge travel time information (0x58)

compound (time, edgeID), 见下文

double

返回车辆内部容器中存储的给定时间的边行驶时间。如果不存在该值,则返回-1。

getAdaptedTraveltime

edge effort information (0x59)

compound (time, edgeID), 见下文

double

返回车辆内部容器中存储的给定时间的边努力值。如果不存在该值,则返回-1。

getEffort

leader (0x68)

double, 见下文

compound (string, double)

返回前导车辆的ID及其距离,如果字符串为空,则在给定范围内未找到前导车辆。仅考虑当前最佳车道列表前方的车辆(见上文)。这意味着前导车辆仅在下一次换道操作之前有效。返回的距离是从本车前保险杠 + minGap 到前导车辆后保险杠的距离。

getLeader

distance request (0x83)

compound (见 命令 0x83: 距离请求)

double, 见下文

返回当前车辆位置与指定位置之间的距离(对于给定的距离类型)

getDrivingDistance getDrivingDistance2D

change lane information (0x13)

compound , 见下文

int, int 见下文

返回车辆在上一步中是否能在指定方向换道(右:-1,左:1。当前车道内的子车道换道:0)。
返回车辆的换道状态。

getLaneChangeState couldChangeLane wantsAndCouldChangeLane

neighboring vehicles (0xbf)

byte , 见下文

stringList 见下文

返回与换道相关的相邻车辆的ID列表(>1个元素仅可能在子车道模型中出现)

getNeighbors, getLeftFollowers, getLeftLeaders, getRightFollowers, getRightLeaders

followSpeed (0x1c)

compound, 见下文

double

返回由车辆的carFollowModel计算出的跟驰速度

getFollowSpeed

secureGap (0x1e)

compound, 见下文

double

返回由车辆的carFollowModel计算出的安全间距

getSecureGap

stopSpeed (0x1e)

compound, 见下文

double

返回由车辆的carFollowModel计算出的在间距处停车的安全速度

getStopSpeed

junction foes (0x37)

complex

返回在本车一定距离内的冲突车辆列表。

getJunctionFoes

stop parameters (0x55)

string

返回指定车辆给定索引(0是下一个停靠点,-1是上一个停靠点等)的停靠点的给定名称的属性。如果customParam设置为True (1),则返回用户定义的自定义参数。

getStopParameter

请求消息内容如下:

edge travel time information (0x58)#

byte int byte double byte string
值类型 compound 元素数量 (总是=2) 值类型 double 请求的时间 (s) 值类型 string 边ID

edge effort information (0x59)#

byte int byte double byte string
值类型 compound 元素数量 (总是=2) 值类型 double 请求的时间 (s) 值类型 string 边ID

leader (0x68)#

byte double
值类型 double 最小前视距离 (m)

next TLS (0x70)#

byte int byte int byte string byte int byte double byte byte
值类型 compound 元素数量 值类型 integer 前方交通信号灯链接数量 值类型 string TLS ID 值类型 int TLS 链接索引 值类型 double 到TLS的距离 值类型 byte 链接状态

最后4项根据前方交通信号灯的数量(第2个返回值)多次出现。

change lane information (0x13)#

byte int
值类型 compound 换道方向 (-1:右, 0:当前车道内的子车道换道或 1:左)

结果由两个整数值组成。第一个值返回由换道模型计算出的状态,第二个值返回合并请求后的状态(参见 changeLane, setLaneChangeMode)。每个值都是一个位集,含义如下:

  • 2^0: 保持
  • 2^1: 向左
  • 2^2: 向右
  • 2^3: 战略性
  • 2^4: 协作性
  • 2^5: 速度增益
  • 2^6: 保持右侧
  • 2^7: TraCI
  • 2^8: 紧急
  • 2^9: 被左侧前导车阻挡
  • 2^10: 被左侧跟随车阻挡
  • 2^11: 被右侧前导车阻挡
  • 2^12: 被右侧跟随车阻挡
  • 2^13: 重叠
  • 2^14: 空间不足
  • 2^15: 子车道
  • 2^28: 速度不足
  • 2^30: 未确定

neighboring vehicles (0xbf)#

byte ubyte
值类型 ubyte 模式 (位集)

模式的位指定应返回哪些相邻车辆:

  • 2^0: 右侧邻居 (否则:左侧)
  • 2^1: 前方的邻居 (否则:后方)
  • 2^2: 仅阻挡潜在换道的邻居 (否则:所有)

返回的字符串列表包含所有相应相邻车辆的ID。

followSpeed (0x1c)#

byte int double double double double string
值类型 compound 5 speed gap leaderSpeed leaderMaxDecel leaderID

leaderID是可选的。只有少数跟驰模型(如CACC)可能需要前导车辆的身份才能返回正确的值。 返回的值是安全跟驰速度(m/s)。

secureGap (0x1e)#

byte int double double double string
值类型 compound 4 speed leaderSpeed leaderMaxDecel leaderID

leaderID是可选的。只有少数跟驰模型(如CACC)可能需要前导车辆的身份才能返回正确的值。 返回的值是跟随给定前导车辆的安全间距(m)。

stopSpeed (0x1d)#

byte int double double
值类型 compound 2 speed gap

返回的值是从给定速度制动后在间距处停车的安全速度(m/s)。

junction foes (0x37)#

byte double
值类型 double 前视距离 (m)

返回的值是从给定速度制动后在间距处停车的安全速度(m/s)。

stopParameter (0x55)#

byte int int string byte
值类型 compound 3 stopIndex param customParam

stopIndex 必须在范围 [-numberOfPassedStops, numberORemaingStops - 1] 内。 customParam 被解释为布尔值,确定是返回属性值还是用户定义的参数。

设备和换道模型参数检索 0x7e#

车辆支持使用通用参数检索调用检索设备参数。

支持的设备参数#

  • device.battery.energyConsumed
  • device.battery.energyCharged
  • device.battery.chargeLevel
  • device.battery.capacity
  • device.battery.chargingStationId
  • device.battery.totalEnergyConsumed
  • device.battery.totalEnergyRegenerated
  • device.battery.maximumChargeRate
  • device.person.IDList
  • device.container.IDList
  • device.rerouting.period (返回单个重路由周期,单位为秒)
  • device.rerouting.edge:EDGE_ID (返回用于重路由的假定行驶时间,其中EDGE_ID是网络边的ID)
  • device.driverstate.awareness
  • device.driverstate.errorState
  • device.driverstate.errorTimeScale
  • device.driverstate.errorNoiseIntensity
  • device.driverstate.minAwareness
  • device.driverstate.initialAwareness
  • device.driverstate.errorTimeScaleCoefficient
  • device.driverstate.errorNoiseIntensityCoefficient
  • device.driverstate.speedDifferenceErrorCoefficient
  • device.driverstate.headwayErrorCoefficient
  • device.driverstate.speedDifferenceChangePerceptionThreshold
  • device.driverstate.headwayChangePerceptionThreshold
  • device.driverstate.maximalReactionTime
  • device.driverstate.originalReactionTime
  • device.driverstate.actionStepLength
  • device.stationfinder.chargingStation
  • device.stationfinder.batteryNeed
  • device.stationfinder.needToChargeLevel
  • device.stationfinder.saturatedChargeLevel
  • device.stationfinder.waitForCharge
  • device.stationfinder.repeat
  • device.stationfinder.radius
  • device.stationfinder.reserveFactor
  • device.taxi.state
  • device.taxi.customers
  • device.taxi.occupiedTime
  • device.taxi.occupiedDistance
  • device.taxi.currentCustomers
  • device.tripinfo.waitingTime (总等待时间)
  • device.tripinfo.waitingCount
  • device.tripinfo.stopTime (总停止时间)
  • device.tripinfo.arrivalTime (仅在到达后使用选项 --keep-after-arrival TIME 可检索)
  • device.tripinfo.arrivalLane (仅在到达后使用选项 --keep-after-arrival TIME 可检索)
  • device.tripinfo.arrivalPos (仅在到达后使用选项 --keep-after-arrival TIME 可检索)
  • device.tripinfo.arrivalPosLat (仅在到达后使用选项 --keep-after-arrival TIME 可检索)
  • device.tripinfo.arrivalSpeed (仅在到达后使用选项 --keep-after-arrival TIME 可检索)
  • device.toc.state
  • device.toc.holder
  • device.toc.hasDynamicToC
  • device.toc.manualType
  • device.toc.automatedType
  • device.toc.initialAwareness
  • device.toc.lcAbstinence
  • device.toc.currentAwareness
  • device.toc.dynamicToCThreshold
  • device.toc.dynamicMRMProbability
  • device.toc.mrmKeepRight
  • device.toc.mrmSafeSpot
  • device.toc.mrmSafeSpotDuration
  • device.toc.maxPreparationAccel
  • device.toc.ogNewTimeHeadway
  • device.toc.ogNewSpaceHeadway
  • device.toc.ogChangeRate
  • device.toc.ogMaxDecel
  • device.example.customValue1 (返回选项 --device.example.parameter 的值)
  • device.example.customValue2 (返回车辆参数 example 的值)
  • device.example.meaningOfLife (返回 42)
  • has.DEVICENAME.device (根据是否配备了名为DEVICENAME的设备返回 "true" 或 "false")

Caution

如果车辆未携带相应的设备,在检索带有 device. 前缀的参数时会返回错误。当为从未载过任何人员的车辆请求 device.person.IDList 时会发生这种情况。要么检查是否存在,要么处理错误(例如在python客户端中捕获TraCIException)。

支持的换道模型参数#

  • laneChangeModel.<ATTRNAME> (其中 <ATTRNAME> 是车辆换道模型支持的参数之一,例如 lcStrategic)。

支持的跟驰模型参数#

一些跟驰模型允许访问更多车辆特定的参数。

支持的路口模型参数#

支持的进一步参数#

  • parking.rerouteCount: 车辆在当前搜索期间重路由到另一个停车区的次数
  • parking.memory.IDList: 迄今为止考虑的所有停车区
  • parking.memory.score: 所考虑停车区列表的最新得分(越小越好)
  • parking.memory.blockedAtTime: 所考虑停车区列表的时间,表示最后一次发现该区域被阻塞的时间(可能通过远程信息)
  • parking.memory.blockedAtTimeLocal: 所考虑停车区列表的时间,表示最后一次发现该区域被阻塞的时间(在物理访问该区域时)