Skip to content

Commit

Permalink
added test refs #5255
Browse files Browse the repository at this point in the history
  • Loading branch information
namdre committed Mar 5, 2019
1 parent 4a785de commit b57dfc9
Show file tree
Hide file tree
Showing 6 changed files with 99 additions and 0 deletions.
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<routes>
</routes>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
tests/complex/traci/pythonApi/moveToXY/multi_lane_sublane/runner.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Retrying in 1 seconds
2.0 lane=SC_0 right=[], [] left=[], [] accel=0.0 nextTLS=('C', 10, 71.95, 'G') leader=None
3.0 lane=SC_0 right=[], [] left=['stay', 'strategic'], ['stay', 'strategic'] accel=10.0 nextTLS=('C', 10, 61.95, 'G') leader=None
4.0 lane=SC_0 right=[], [] left=['stay', 'strategic'], ['stay', 'strategic'] accel=0.0 nextTLS=('C', 10, 51.95, 'G') leader=None
5.0 lane=SC_1 right=[], [] left=['stay', 'strategic'], ['stay', 'strategic'] accel=7.1054273576e-15 nextTLS=('C', 10, 41.949999999999996, 'G') leader=None
6.0 lane=SC_1 right=['right', 'strategic', 'urgent'], ['right', 'strategic', 'urgent'] left=[], [] accel=-1.42108547152e-14 nextTLS=('C', 10, 31.950000000000003, 'G') leader=None
7.0 lane=SC_1 right=['right', 'strategic', 'urgent'], ['right', 'strategic', 'urgent'] left=[], [] accel=2.13162820728e-14 nextTLS=('C', 10, 21.94999999999999, 'G') leader=None
8.0 lane=SC_1 right=['right', 'strategic', 'urgent'], ['right', 'strategic', 'urgent'] left=[], [] accel=-2.84217094304e-14 nextTLS=('C', 10, 11.950000000000003, 'G') leader=None
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
# Copyright (C) 2008-2019 German Aerospace Center (DLR) and others.
# This program and the accompanying materials
# are made available under the terms of the Eclipse Public License v2.0
# which accompanies this distribution, and is available at
# http://www.eclipse.org/legal/epl-v20.html
# SPDX-License-Identifier: EPL-2.0

# @file runner.py
# @author Jakob Erdmann
# @date 2017-01-23
# @version $Id$


from __future__ import print_function
from __future__ import absolute_import
import os
import sys

if 'SUMO_HOME' in os.environ:
tools = os.path.join(os.environ['SUMO_HOME'], 'tools')
sys.path.append(tools)
else:
sys.exit("please declare environment variable 'SUMO_HOME'")

import traci # noqa
import sumolib # noqa

sumoBinary = os.environ["SUMO_BINARY"]
PORT = sumolib.miscutils.getFreeSocketPort()
cmd = [sumoBinary,
'-n', 'input_net2.net.xml',
'--lateral-resolution', '0.8',
'--no-step-log',
# '-S', '-Q',
]

ANGLE_UNDEF = traci.constants.INVALID_DOUBLE_VALUE
INVALID = traci.constants.INVALID_DOUBLE_VALUE

vehID = "v0"


def check(x, y, angle, exLane, exPos, exPosLat, comment):
traci.vehicle.moveToXY(vehID, "", angle, x, y)
traci.simulationStep()
x2, y2 = traci.vehicle.getPosition(vehID)
lane2 = traci.vehicle.getLaneID(vehID)
pos2 = traci.vehicle.getLanePosition(vehID)
posLat2 = traci.vehicle.getLateralLanePosition(vehID)
if (abs(x - x2) > 0.1 or
abs(y - y2) > 0.1 or
(exLane != lane2 and exLane is not None) or
(exPos is not None and abs(exPos - pos2) > 0.1) or
(exPosLat is not None and abs(exPosLat - posLat2) > 0.1)):
print(comment, ("failed: x=%s, x2=%s, y=%s, y2=%s, lane=%s, lane2=%s, pos=%s, pos2=%s " +
"posLat=%s posLat2=%s") % (x, x2, y, y2, exLane, lane2, exPos, pos2, exPosLat, posLat2))
else:
# (comment, "success")
pass
print(traci.simulation.getTime(),
" lane=%s" % lane2,
# " route=%s" % str(traci.vehicle.getRoute(vehID)),
" right=%s, %s" % traci.vehicle.getLaneChangeStatePretty(vehID, -1),
" left=%s, %s" % traci.vehicle.getLaneChangeStatePretty(vehID, 1),
" accel=%s" % traci.vehicle.getAcceleration(vehID),
" nextTLS=%s" % traci.vehicle.getNextTLS(vehID),
" leader=%s" % traci.vehicle.getLeader(vehID, 500),
)


traci.start(cmd)
traci.simulationStep()
traci.route.add("SE", ["SC", "CE"])
traci.vehicle.add(vehID, "SE")
check(104.95, 20, ANGLE_UNDEF, None, None, None, "correct lane")
check(104.95, 30, ANGLE_UNDEF, None, None, None, "correct lane")
check(104.95, 40, ANGLE_UNDEF, None, None, None, "correct lane")
check(101.65, 50, ANGLE_UNDEF, None, None, None, "correct lane")
check(101.65, 60, ANGLE_UNDEF, None, None, None, "correct lane")
check(101.65, 70, ANGLE_UNDEF, None, None, None, "correct lane")
check(101.65, 80, ANGLE_UNDEF, None, None, None, "correct lane")
traci.close()
3 changes: 3 additions & 0 deletions tests/complex/traci/pythonApi/moveToXY/testsuite.complex
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ keepRoute2
# tests for mapping vehicles on multi-lane road
multi_lane

# tests for mapping vehicles on multi-lane road
multi_lane_sublane

# mapping a fast vehicle onto short edges
short_edges

Expand Down

0 comments on commit b57dfc9

Please sign in to comment.