Skip to content

Commit

Permalink
add test example for alighting passengers ref #21 #14313
Browse files Browse the repository at this point in the history
Signed-off-by: m-kro <[email protected]>
  • Loading branch information
m-kro committed Feb 14, 2024
1 parent a6574a7 commit 7ff161c
Show file tree
Hide file tree
Showing 8 changed files with 425 additions and 0 deletions.
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>

<additional xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://sumo.dlr.de/xsd/additional_file.xsd">
<busStop id="stop_SC" lane="SC_0" startPos="-20" endPos="-10"/>
<busStop id="stop_NC" lane="NC_0" startPos="-20" endPos="-10"/>
<busStop id="stop_CS" lane="CS_0" startPos="-20" endPos="-10"/>

</additional>
15 changes: 15 additions & 0 deletions tests/complex/traci/vehicle/alightingPersons/input_routes.rou.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<routes xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://sumo.dlr.de/xsd/routes_file.xsd">
<vType id="bus" vClass="bus"/>
<route id="r1" edges="SC CN NC CS">
<stop busStop="stop_SC" until="50" duration="8"/>
<stop busStop="stop_NC" until="100" duration="8"/>
<stop busStop="stop_CS" until="150" duration="8"/>
</route>
<vehicle id="bus" type="bus" line="B7" depart="0" route="r1"/>
<personFlow id="pSC" begin="0" end="1" number="5" departPos="-15">
<ride from="SC" busStop="stop_CS" lines="bus"/>
</personFlow>
<personFlow id="pNC" begin="0" end="1" number="3" departPos="-15">
<ride from="NC" busStop="stop_CS" lines="bus"/>
</personFlow>
</routes>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
tests/complex/traci/vehicle/alightingPersons/runner.py
63 changes: 63 additions & 0 deletions tests/complex/traci/vehicle/alightingPersons/output.complex
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
time 0.0
next stop stop_SC
alighting passengers []
time 10.0
next stop stop_SC
alighting passengers []
time 20.0
next stop stop_SC
alighting passengers []
time 30.0
next stop stop_SC
alighting passengers []
time 40.0
next stop stop_SC
alighting passengers []
time 50.0
next stop stop_SC
alighting passengers []
time 60.0
next stop stop_NC
alighting passengers []
time 70.0
next stop stop_NC
alighting passengers []
time 80.0
next stop stop_NC
alighting passengers []
time 90.0
next stop stop_NC
alighting passengers []
time 100.0
next stop stop_NC
alighting passengers []
time 110.0
next stop stop_NC
alighting passengers []
time 120.0
next stop stop_NC
alighting passengers []
time 130.0
next stop stop_CS
alighting passengers ['pSC.0', 'pSC.1', 'pSC.2', 'pSC.3', 'pSC.4', 'pNC.0', 'pNC.1', 'pNC.2']
time 140.0
next stop stop_CS
alighting passengers ['pSC.0', 'pSC.1', 'pSC.2', 'pSC.3', 'pSC.4', 'pNC.0', 'pNC.1', 'pNC.2']
time 150.0
next stop stop_CS
alighting passengers ['pSC.0', 'pSC.1', 'pSC.2', 'pSC.3', 'pSC.4', 'pNC.0', 'pNC.1', 'pNC.2']
time 160.0
next stop stop_CS
alighting passengers ['pSC.0', 'pSC.1', 'pSC.2', 'pSC.3', 'pSC.4', 'pNC.0', 'pNC.1', 'pNC.2']
time 170.0
next stop stop_CS
alighting passengers ['pSC.0', 'pSC.1', 'pSC.2', 'pSC.3', 'pSC.4', 'pNC.0', 'pNC.1', 'pNC.2']
time 180.0
next stop stop_CS
alighting passengers ['pSC.0', 'pSC.1', 'pSC.2', 'pSC.3', 'pSC.4', 'pNC.0', 'pNC.1', 'pNC.2']
time 190.0
next stop stop_CS
alighting passengers ['pSC.0', 'pSC.1', 'pSC.2', 'pSC.3', 'pSC.4', 'pNC.0', 'pNC.1', 'pNC.2']
time 200.0
next stop stop_CS
alighting passengers ['pNC.2']
277 changes: 277 additions & 0 deletions tests/complex/traci/vehicle/alightingPersons/output.complex.meso

Large diffs are not rendered by default.

58 changes: 58 additions & 0 deletions tests/complex/traci/vehicle/alightingPersons/runner.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
# Copyright (C) 2008-2024 German Aerospace Center (DLR) and others.
# This program and the accompanying materials are made available under the
# terms of the Eclipse Public License 2.0 which is available at
# https://www.eclipse.org/legal/epl-2.0/
# This Source Code may also be made available under the following Secondary
# Licenses when the conditions for such availability set forth in the Eclipse
# Public License 2.0 are satisfied: GNU General Public License, version 2
# or later which is available at
# https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
# SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later

# @file runner.py
# @author Mirko Barthauer
# @date 2024-02-14

from __future__ import print_function
import os
import sys

if "SUMO_HOME" in os.environ:
sys.path.append(os.path.join(os.environ["SUMO_HOME"], "tools"))

import traci # noqa
import sumolib # noqa
import traci.constants as tc # noqa

sumoBinary = sumolib.checkBinary('sumo')
traci.start([sumoBinary,
"-n", "input_net2.net.xml",
"-a", "input_additional.add.xml",
"-r", "input_routes.rou.xml",
"--no-step-log",
] + sys.argv[1:])

vehID = "bus"

while traci.simulation.getMinExpectedNumber() > 0:
t = traci.simulation.getTime()
if t % 10 == 0:
passengerIDs = traci.vehicle.getPersonIDList(vehID)
nextStops = traci.vehicle.getStops(vehID, limit=1)
if len(nextStops) > 0:
stopID = nextStops[0].stoppingPlaceID
stopEdge = nextStops[0].lane.rsplit("_",1)[1]
alightingPassengers = []
for passengerID in passengerIDs:
nextStage = traci.person.getStage(passengerID)
if nextStage.destStop == stopID:
alightingPassengers.append(passengerID)
print("time", t)
print(" next stop", stopID)
print(" alighting passengers", str(alightingPassengers))
traci.simulationStep()

traci.close()
3 changes: 3 additions & 0 deletions tests/complex/traci/vehicle/testsuite.complex
Original file line number Diff line number Diff line change
Expand Up @@ -126,3 +126,6 @@ tripinfoRetrieval

# retrieving TLS info with multiple links
getNextTLS

# get numbr of alighting persons at the next stop
alightingPersons

0 comments on commit 7ff161c

Please sign in to comment.