Path: blob/main/tests/complex/traci/bugs/ticket5561/runner.py
169708 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 sys23if "SUMO_HOME" in os.environ:24sys.path.append(os.path.join(os.environ['SUMO_HOME'], 'tools'))25import traci # noqa26import sumolib # noqa272829traci.start([sumolib.checkBinary("sumo"), '-c', 'sumo.sumocfg'])3031step = 032done = False33bus_id = "bus"3435while traci.simulation.getMinExpectedNumber() > 0:36next_stops = traci.vehicle.getStops(bus_id)37if len(next_stops) > 0:38stop = next_stops[0]39bus_stop_pos = stop.endPos40if stop.stoppingPlaceID == "busStop2" and traci.vehicle.getLaneID(bus_id) == stop.lane:41bus_pos = traci.vehicle.getLanePosition(bus_id)42if bus_stop_pos - bus_pos < 10:43traci.vehicle.setBusStop(bus_id, "busStop2", 0)44print("abort stop at busStop2 at t=%s" % traci.simulation.getTime())45traci.simulationStep()46traci.close()474849