Path: blob/main/tests/complex/traci/vehicle/replaceStop/first_parameter_only/runner.py
169727 views
#!/usr/bin/env python1# -*- coding: utf-8 -*-2# Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo3# Copyright (C) 2008-2025 German Aerospace Center (DLR) and others.4# This program and the accompanying materials are made available under the5# terms of the Eclipse Public License 2.0 which is available at6# https://www.eclipse.org/legal/epl-2.0/7# This Source Code may also be made available under the following Secondary8# Licenses when the conditions for such availability set forth in the Eclipse9# Public License 2.0 are satisfied: GNU General Public License, version 210# or later which is available at11# https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html12# SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later1314# @file runner.py15# @author Jakob Erdmann16# @date 2017-01-23171819from __future__ import print_function20from __future__ import absolute_import21import os22import sys2324if "SUMO_HOME" in os.environ:25sys.path.append(os.path.join(os.environ["SUMO_HOME"], "tools"))2627import traci # noqa28import sumolib # noqa29import traci.constants as tc # noqa303132def getParams(vehID, index):33print("stop parameters for index %s at time %s:" % (34index, traci.simulation.getTime()))3536for p in [37"index",38"edge",39"lane",40"startPos",41"endPos",42"posLat",43"arrival",44"duration",45"until",46"extension",47"parking",48"triggered",49"permitted",50"expected",51"actType",52"tripId",53"split",54"join",55"line",56"speed",57"started",58"ended",59]:60print(p, traci.vehicle.getStopParameter(vehID, index, p))616263sumoBinary = sumolib.checkBinary('sumo')64traci.start([sumoBinary,65"-n", "input_net4.net.xml",66"-a", "input_additional4.add.xml",67"-r", "input_routes.rou.xml",68"--stop-output", "stopinfos.xml",69"--no-step-log",70"--vehroute-output", "vehroutes.xml",71] + sys.argv[1:])7273vehID = "ego"7475while traci.simulation.getMinExpectedNumber() > 0:76if traci.simulation.getTime() == 5:77traci.vehicle.setStopParameter(vehID, 0, "lane", "0")78traci.vehicle.setStopParameter(vehID, 0, "startPos", "5")79traci.vehicle.setStopParameter(vehID, 0, "endPos", "50")80traci.vehicle.setStopParameter(vehID, 0, "posLat", "-0.5")81traci.vehicle.setStopParameter(vehID, 0, "arrival", "42")82traci.vehicle.setStopParameter(vehID, 0, "duration", "30")83traci.vehicle.setStopParameter(vehID, 1, "duration", "100")84traci.vehicle.setStopParameter(vehID, 0, "until", "0:1:40")85traci.vehicle.setStopParameter(vehID, 0, "extension", "10")86traci.vehicle.setStopParameter(vehID, 0, "parking", "false")87traci.vehicle.setStopParameter(vehID, 0, "triggered", "join")88traci.vehicle.setStopParameter(vehID, 0, "permitted", "p0 p1 p2")89traci.vehicle.setStopParameter(vehID, 0, "expected", "p0 p1")90traci.vehicle.setStopParameter(vehID, 0, "actType", "test action")91traci.vehicle.setStopParameter(vehID, 0, "tripId", "fancyID")92traci.vehicle.setStopParameter(vehID, 0, "split", "train0")93traci.vehicle.setStopParameter(vehID, 0, "join", "train1")94traci.vehicle.setStopParameter(vehID, 0, "line", "S42")95try:96traci.vehicle.setStopParameter(vehID, 0, "speed", "3")97except traci.TraCIException:98pass99traci.vehicle.setStopParameter(vehID, 0, "started", "0:1:23")100traci.vehicle.setStopParameter(vehID, 0, "ended", "0:1:42")101traci.vehicle.setStopParameter(vehID, 2, "onDemand", "true")102if traci.simulation.getTime() == 6:103getParams(vehID, 0)104if traci.simulation.getTime() == 150:105getParams(vehID, -1)106traci.simulationStep()107traci.close()108109110