仿真值检索

命令 0xab: 获取仿真变量#

ubyte string
变量 (Variable) 仿真 ID (始终未使用)

请求某个仿真变量的值。

以下变量值可以被检索和订阅。返回值的类型也在表中显示。无法订阅位置转换 (0x82)、距离请求 (0x83)、查找路径 (0x86)、查找多式联运路径 (0x87) 以及所有公交站点函数。

**可检索仿真变量概览**

变量 (Variable)

值类型 (ValueType)

描述 (Description)

Python 方法

当前仿真时间 (0x66)

double

返回当前仿真时间 (单位: s)

getTime

当前仿真时间 (0x70) (已弃用)

int

返回当前仿真时间 (单位: ms)

getCurrentTime

已加载车辆数量 (id 0x71)

int

在此时间步中加载的车辆数量。

getLoadedNumber

已加载车辆的ID (id 0x72)

stringList

在此时间步中加载的车辆ID列表。

getLoadedIDList

已出发车辆数量 (id 0x73)

int

在此时间步中出发(插入道路网络)的车辆数量。

getDepartedNumber

已出发车辆的ID (id 0x74)

stringList

在此时间步中出发(插入道路网络)的车辆ID列表。

getDepartedIDList

开始瞬移的车辆数量
(id 0x75)

int

在此时间步中开始瞬移的车辆数量。

getStartingTeleportNumber

开始瞬移的车辆ID (id 0x76)

stringList

在此时间步中开始瞬移的车辆ID列表。

getStartingTeleportIDList

结束瞬移的车辆数量
(id 0x77)

int

在此时间步中结束瞬移的车辆数量。

getEndingTeleportNumber

结束瞬移的车辆ID
(id 0x78)

stringList

在此时间步中结束瞬移的车辆ID列表。

getEndingTeleportIDList

到达车辆数量 (id 0x79)

int

在此时间步中到达(已到达目的地并从道路网络中移除)的车辆数量。

getArrivedNumber

到达车辆的ID (id 0x7a)

stringList

在此时间步中到达(已到达目的地并从道路网络中移除)的车辆ID列表。

getArrivedIDList

网络边界框 (id 0x7c)

2D polygon

仿真网络边界框的左下角和右上角。

getNetBoundary

仍预期离开网络的最小车辆数 (id 0x7d)

int

网络中的车辆数量加上仍在等待出发的车辆数量。由于路径文件解析的延迟,此数字可能小于实际仍要到达的车辆数。

getMinExpectedNumber

开始停靠的车辆数量 (id 0x68)

int

在此时间步中按计划停靠的车辆数量。

getStopStartingVehiclesNumber

开始停靠的车辆ID (id 0x69)

stringList

在此时间步中按计划停靠的车辆ID列表。

getStopStartingVehiclesIDList

结束停靠的车辆数量 (id 0x6a)

int

在此时间步中开始继续其行程、离开计划停靠点的车辆数量。

getStopEndingVehiclesNumber

结束停靠的车辆ID (id 0x6b)

stringList

在此时间步中开始继续其行程、离开计划停靠点的车辆ID列表。

getStopEndingVehiclesIDList

涉及碰撞的车辆数量 (id 0x80)

int

在此时间步中涉及碰撞的车辆数量。

getCollidingVehiclesNumber

涉及碰撞的车辆ID (id 0x81)

stringList

在此时间步中涉及碰撞的车辆ID列表。

getCollidingVehiclesIDList

开始停放的车辆数量
(id 0x6c)

int

在此时间步中进入停车位的车辆数量。

getParkingStartingVehiclesNumber

开始停放的车辆ID
(id 0x6d)

stringList

在此时间步中进入停车位的车辆ID列表。

getParkingStartingVehiclesIDList

结束停放的车辆数量
(id 0x6e)

int

在此时间步中开始继续其行程、离开计划停车位的车辆数量。

getParkingEndingVehiclesNumber

结束停放的车辆ID (id 0x6f)

stringList

在此时间步中开始继续其行程、离开计划停车位的车辆ID列表。

getParkingEndingVehiclesIDList

公交站点等待 (id 0x67)

int

获取指定公交站点的总等待人数 (已弃用, 请使用 busstop.getPersonCount)。

getBusStopWaiting

公交站点等待ID (id 0xef)

stringList

获取指定公交站点的等待人员ID (已弃用, 请使用 busstop.getPersonIDs)。

getBusStopWaitingIDList

Delta T (id 0x7b)

double

返回一个仿真步长的长度(秒)。

getDeltaT

参数 (0x7e)

string

返回给定字符串参数的值。

getParameter

缩放比例 (id 0x8e)

double

返回交通缩放因子。

getScale

选项 (0x3f)

string

返回某个全局SUMO选项的值。

getOption

响应 0xbb: 仿真变量#

ubyte string ubyte <return_type>
变量 (Variable) <invalid> 变量的返回类型 <VARIABLE_VALUE>

"命令 获取仿真变量" 的响应。

扩展检索消息#

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

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

变量 (Variable)

请求值类型 (Request ValueType)

响应值类型 (Response ValueType)

描述 (Description)

Python 方法

位置转换 (0x82)

compound, 见下文

位置 (Position), 按需

读取位置信息并将其转换为指定的表示形式。

convert2D
convert3D
convertGeo
convertRoad

距离请求 (0x83)

compound, 见下文

double

读取两个位置和一个指示符,指示是计算直线距离还是行驶距离。返回相应的距离。

getDistanceRoad
getDistance2D

查找路径 (0x86)

compound, 见下文

compound, 见下文

读取起点和终点边以及一些车辆参数,并计算车辆当前最快的行驶路径(对于行人/乘客,请使用查找多式联运路径)。

findRoute

查找多式联运路径 (0x87)

compound, 见下文

compound, 见下文

读取起点和终点位置以及可用的出行方式和其他人员参数,并计算使用可用出行方式的当前最快路径。

findIntermodalRoute

获取碰撞 (0x23)

-

compound, 见下文

检索上一个时间步中所有碰撞事件的详细信息。默认情况下禁用碰撞检测 (**--collision.action none**)。

getCollisions

命令 0x82: 位置转换#

请求需要以下参数:

byte integer Position byte ubyte
值类型 compound 项数 (始终为 2) 要转换的位置 值类型 ubyte 要返回的位置类型

使用此命令在TraCI使用的不同位置类型之间进行转换。指定的 Position 将被转换为通过 PositionId 给出的请求格式。当从坐标转换为道路位置时,结果是找到的与给定位置最接近的匹配位置。在所有其他情况下,转换将给出精确匹配。返回值仅包含转换后的值。

为了简化位置转换,许多 traci 客户端库libsumo 提供了一些便捷函数:

  • convert2D: 将 road,laneIndex,offset 转换为 x,y 或 lon,lat
  • convert3D: 将 road,laneIndex,offset 转换为 x,y,z 或 lon,lat
  • convertGeo: 将 x,y 转换为 lon,lat 或反之亦然
  • convertRoad: 将 x,y 或 lon,lat 转换为 road,laneInex,offset

有关可用的位置格式,请参见 TraCI/Protocol#Position Representations

命令 0x83: 距离请求#

请求需要以下参数:

byte integer Position Position ubyte
值类型 compound 项数 (始终为 3) 起始位置 结束位置 距离类型

其中

  • 距离类型==0: 直线距离
  • 距离类型==1: 行驶距离

返回计算出的距离。

命令 0x86: 查找路径#

byte integer byte string byte string byte string byte double byte integer
值类型 compound 项数 (始终为 5) 值类型 string 起始边 值类型 string 目的地边 值类型 string 车辆类型 值类型 double 出发时间 (s) 值类型 integer 路径模式 (见下文)

Caution

路径模式应用于指定用于估计边行驶时间的数据源。此功能尚未实现,使用与命令 vehicle.rerouteTraveltime 相同的数据源。

返回以下响应:

type + string type + string type + stringList type + double type + double
类型 (始终为 "driving") 线路 (始终为 "") 边列表 行驶时间 (s) 行驶时间 (s)

Note

Python 和 C++ 客户端返回一个 namedtuple / struct,字段名为 stageType, line, destStop, edges, travelTime, cost

Note

看似未使用/冗余的字段是为按成本路径和多式联运路径保留的(见下文)。

命令 0x87: 查找多式联运路径#

byte integer byte string byte string byte string byte double byte integer byte double byte double byte double byte double byte double byte string byte string
值类型 compound 项数 (始终为 12) 值类型 string 起始边 值类型 string 目的地边 值类型 string 可用模式 值类型 double 出发时间 (s) 值类型 integer 路径模式 (见上文) 值类型 double 步行速度 (m/s) 值类型 double 步行因子 值类型 double 出发位置 (m) 值类型 double 到达位置 (m) 值类型 double 出发纬度位置 (m) 值类型 string 车辆的 vtype 值类型 string 行人的 vtype

可用模式是 "car"、"public"、"bicycle" 或空格分隔的组合。步行始终被认为是可能的,并且是默认模式(或在给出空字符串时使用)。当 "car" 是可用模式时,可以使用 vtype 参数指定车辆类型。如果为空,则使用默认车辆类型。

响应是一个阶段列表,类似于 findRoute 返回的列表。

命令 0x23: 获取碰撞#

响应是一个碰撞对象列表:

type + string type + string type + string type + string type + double type + double type + string type + string type + double
碰撞方 ID 受害方 ID 碰撞方类型 受害方类型 碰撞方速度 受害方速度 碰撞类型 车道 ID 车道上的位置

通用参数检索 0x7e#

仿真支持使用 通用参数检索调用 检索其他对象参数。

停止点信息#

getParameterobject id 指的是对象(即 chargingStation)的 ID。支持以下参数:

  • chargingStation.totalEnergyCharged
  • chargingStation.name
  • chargingStation.lane
  • parkingArea.capacity
  • parkingArea.occupancy
  • parkingArea.name
  • parkingArea.lane
  • busStop.name
  • busStop.lane

Note

从版本 1.7.0 开始,这些值和其他值可以通过新的域(即 traci.busstop)检索。

设备参数检索#

可以检索以下参数。它们不是针对特定的设备持有者,而是全局度量。object id 必须为空字符串 ""。

  • device.tripinfo.count
  • device.tripinfo.routeLength
  • device.tripinfo.speed
  • device.tripinfo.duration
  • device.tripinfo.waitingTime
  • device.tripinfo.timeLoss
  • device.tripinfo.departDelay
  • device.tripinfo.departDelayWaiting
  • device.tripinfo.totalTravelTime
  • device.tripinfo.totalDepartDelay
  • device.tripinfo.vehicleTripStatistics.count
  • device.tripinfo.vehicleTripStatistics.routeLength
  • device.tripinfo.vehicleTripStatistics.speed
  • device.tripinfo.vehicleTripStatistics.duration
  • device.tripinfo.vehicleTripStatistics.waitingTime
  • device.tripinfo.vehicleTripStatistics.timeLoss
  • device.tripinfo.vehicleTripStatistics.departDelay
  • device.tripinfo.vehicleTripStatistics.departDelayWaiting
  • device.tripinfo.vehicleTripStatistics.totalTravelTime
  • device.tripinfo.vehicleTripStatistics.totalDepartDelay
  • device.tripinfo.bikeTripStatistics.count
  • device.tripinfo.bikeTripStatistics.routeLength
  • device.tripinfo.bikeTripStatistics.speed
  • device.tripinfo.bikeTripStatistics.duration
  • device.tripinfo.bikeTripStatistics.waitingTime
  • device.tripinfo.bikeTripStatistics.timeLoss
  • device.tripinfo.bikeTripStatistics.totalTravelTime
  • device.tripinfo.pedestrianStatistics.count
  • device.tripinfo.pedestrianStatistics.number
  • device.tripinfo.pedestrianStatistics.routeLength
  • device.tripinfo.pedestrianStatistics.duration
  • device.tripinfo.pedestrianStatistics.timeLoss
  • device.tripinfo.rideStatistics.count
  • device.tripinfo.rideStatistics.number
  • device.tripinfo.rideStatistics.waitingTime
  • device.tripinfo.rideStatistics.routeLength
  • device.tripinfo.rideStatistics.duration
  • device.tripinfo.rideStatistics.bus
  • device.tripinfo.rideStatistics.train
  • device.tripinfo.rideStatistics.taxi
  • device.tripinfo.rideStatistics.bike
  • device.tripinfo.rideStatistics.aborted
  • device.tripinfo.transportStatistics.count
  • device.tripinfo.transportStatistics.number
  • device.tripinfo.transportStatistics.waitingTime
  • device.tripinfo.transportStatistics.routeLength
  • device.tripinfo.transportStatistics.duration
  • device.tripinfo.transportStatistics.bus
  • device.tripinfo.transportStatistics.train
  • device.tripinfo.transportStatistics.taxi
  • device.tripinfo.transportStatistics.bike
  • device.tripinfo.transportStatistics.aborted

统计参数检索#

可检索的值是 statistic-output 中描述的、适用于当前仿真时间的值。

  • stats.vehicles.loaded
  • stats.vehicles.inserted
  • stats.vehicles.running
  • stats.vehicles.waiting
  • stats.teleports.total
  • stats.teleports.jam
  • stats.teleports.yield
  • stats.teleports.wrongLane
  • stats.safety.collisions
  • stats.safety.emergencyStops
  • stats.safety.emergencyBraking
  • stats.persons.loaded
  • stats.persons.running
  • stats.persons.jammed
  • stats.personTeleports.total
  • stats.personTeleports.abortWait
  • stats.personTeleports.wrongDest