更改交通信号灯状态

命令 0xc2: 更改交通信号灯状态#

ubyte string ubyte <value_type>
变量 交通信号灯 ID 值的类型 新值

更改交通信号灯的状态。由于可以更改交通信号灯的不同值,给定的值可能具有不同的类型。下表显示了可以更改的值以及应提供的值类型。

**可更改的交通信号灯变量概览**
变量 值类型 (ValueType) 描述 Python 方法
state (light/priority tuple) (0x20) string 将相位定义设置为给定值。假定给定的字符串是由 rRgGyYoO 组成的元组,分别代表红灯、绿灯、黄灯、熄灭,其中小写字母表示车流必须减速。调用此命令后,交通信号灯的程序 ID 将被设置为 "online",状态将保持不变,直到下一次调用 setRedYellowGreenState() 或通过 setProgram() 设置另一个程序为止。 setRedYellowGreenState setLinkState
phase index (0x22) integer 将交通信号灯的相位设置为给定值。给定的索引必须对当前交通信号灯程序有效,即必须在 0 和当前程序已知的相位数减 1 之间。 setPhase
program (0x23) string 将交通信号灯切换到给定程序。不使用 WAUT 算法,程序直接实例化。交通信号灯的索引保持不变。 setProgram
phase duration (0x24) double 以秒为单位设置当前相位的剩余持续时间。 setPhaseDuration
complete program definition (0x2c) compound (见下文) 插入一个全新的程序。 setProgramLogic
add constraint (0x37) compound (tripId, foeSignal, foeId, type, limit) 添加给定的约束 addConstraint
remove constraint (0x35) compound (tripId, foeSignal, foeId) 移除给定的约束 removeConstraint
update constraints (0x36) compound (vehID, tripId) 移除所有因 vehID 的路径不再经过与给定 tripId 相关的信号灯而无法满足的约束。这包括对 tripId 的约束以及 tripId 为 foeId 的约束。 updateConstraints

消息内容如下:

state (light/priority tuple) (0x20)#

string
相位定义 (light/priority tuple)

state (phase/brake/yellow) (0x21)#

string string string
绿灯位集 减速位集 黄灯位集

phase index (0x22)#

integer
相位索引

program (0x23)#

string
程序 ID

phase duration (0x24)#

integer
相位持续时间 [ms]

complete program definition (0x2c)#

byte integer byte string byte integer byte compound byte integer byte integer <phases>
值类型 compound 项目数量 值类型 string 程序 ID 值类型 integer 类型 (始终为 0) 值类型 compound 复合长度 (始终为 0!) 值类型 integer 相位索引 值类型 integer 相位数量 相位

其中 Phases (相位) 部分:

byte double byte double byte double byte string
值类型 double 持续时间 (秒) 值类型 double 未使用 值类型 double 未使用 值类型 string 状态 (light/priority-tuple)

Note

有关上述各字段应填入何种值的更多信息,请参阅 Tutorials/TraCI4Traffic_Lights#Appendix。请记住,您可以在此处查看特定值类型对应的整数值 here

设置交通信号灯参数 (0x7e)#

交通信号灯支持使用通用参数设置调用来设置附加参数。

key 值类型 (表示为字符串) 支持的 tlType 描述
cycleTime double (s) static, actuated, delay_based 默认周期时长 (对 static 类型的 tls 无效)
offset double (s) static, actuated, delay_based 相对于模拟开始时间的周期开始偏移量
coordinated bool static, actuated, delay_based 周期内的时间是否相对于模拟时间计算
max-gap double (s) actuated 放弃相位的检测器超时时间
show-detectors bool actuated 在视图中显示/隐藏检测器
inactive-threshold double (s) actuated 使用默认相位跳过逻辑运行时,切换到未服务相位的超时时间