在网上挑挑拣拣发现并没有使用Traic直接设置车辆路线和其他相关参数的demo,这里提供我自己的工程,仅留做记录。
def sumo_bus(path):
for p in range(len(path)):
# 根据每一条路线设置一辆车id
vehicle_id = "vehicle" + str(p)
# 设置其中一条路线的id
route_id = "route" + str(p)
# 提取其中一条路线
route = path[p]
# 设置路线
traci.route.add(route_id, route)
# 设置车辆
traci.vehicle.add(vehicle_id, route_id)
# 设置车辆的速度
traci.vehicle.setDecel(vehicle_id, 40/3.6)
# 设置车辆的颜色
color_red = (255, 0, 0)
traci.vehicle.setColor(vehicle_id, color_red)