Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[sumo-user] Opposite side overtaking stopped vehicles

Hi,

I am currently working on a traffic simulation project using SUMO and TraCI, and I have encountered an issue that I hope you can assist me with.

In my simulation, I want to model a scenario where a specific vehicle (with type "ego") stops on a two-way road with one laneĀ per direction of travel, and the following vehicles overtake it by using the opposite lane. I have tried to implement this behaviour using the traci.vehicle.slowDown and traci.vehicle.setSpeed commands, but the following vehicles do not overtake the stopped vehicle as desired.

I have attached the TraCI script and the corresponding .net, .rou, and .sumocfg filesĀ for your reference.

Here is a brief summary of what I have tried:

Using traci.vehicle.slowDown to gradually slow down the vehicle to a stop.
Using traci.vehicle.setSpeed to set the speed of the vehicle to zero.
In both cases, the target vehicle stops as expected, but the following vehicles do not overtake it. I have ensured that the road allows overtaking in the opposite lane and have experimented with various lane-changing parameters and models, but the issue persists.

Is there a specific configuration or approach that would allow the following vehicles to overtake a stopped vehicle? I need to do this to study the operational impact of vehicles breaking down on such roads.

Thank you in advance for your assistance. I look forward to hearing from you.

Best
Don
<?xml version="1.0" encoding="UTF-8"?>

<!-- generated on 2023-08-12 02:36:48 by Eclipse SUMO netconvert Version 1.18.0
<configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; xsi:noNamespaceSchemaLocation="http://sumo.dlr.de/xsd/netconvertConfiguration.xsd";>

    <input>
        <node-files value="fivebyfive.nod.xml"/>
        <edge-files value="fivebyfive.edg.xml"/>
    </input>

    <output>
        <output-file value="fivebyfive3.net.xml"/>
    </output>

    <processing>
        <opposites.guess value="true"/>
        <lefthand value="true"/>
    </processing>

    <junctions>
        <no-turnarounds value="true"/>
    </junctions>

</configuration>
-->

<net version="1.16" junctionCornerDetail="5" lefthand="true" limitTurnSpeed="5.50" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; xsi:noNamespaceSchemaLocation="http://sumo.dlr.de/xsd/net_file.xsd";>

    <location netOffset="0.00,-0.00" convBoundary="0.00,-0.00,800.00,-0.00" origBoundary="0.00,0.00,800.00,0.00" projParameter="!"/>

    <edge id=":n_2_0" function="internal">
        <lane id=":n_2_0_0" index="0" speed="13.89" length="0.10" shape="100.00,-1.60 100.03,-1.60">
            <neigh lane=":n_2_1_0"/>
        </lane>
    </edge>
    <edge id=":n_2_1" function="internal">
        <lane id=":n_2_1_0" index="0" speed="13.89" length="0.10" shape="100.03,1.60 100.00,1.60">
            <neigh lane=":n_2_0_0"/>
        </lane>
    </edge>
    <edge id=":n_3_0" function="internal">
        <lane id=":n_3_0_0" index="0" speed="13.89" length="0.10" shape="600.00,-1.60 600.01,-1.60">
            <neigh lane=":n_3_1_0"/>
        </lane>
    </edge>
    <edge id=":n_3_1" function="internal">
        <lane id=":n_3_1_0" index="0" speed="13.89" length="0.10" shape="600.01,1.60 600.00,1.60">
            <neigh lane=":n_3_0_0"/>
        </lane>
    </edge>

    <edge id="-e_1" from="n_2" to="n_1" priority="-1" spreadType="center" shape="100.03,-1.60 0.00,-1.60">
        <lane id="-e_1_0" index="0" speed="13.89" length="100.03" shape="100.03,-1.60 0.00,-1.60">
            <neigh lane="e_1_0"/>
        </lane>
    </edge>
    <edge id="-e_2" from="n_3" to="n_2" priority="-1" spreadType="center" shape="600.01,-1.60 100.00,-1.60">
        <lane id="-e_2_0" index="0" speed="13.89" length="500.01" shape="600.01,-1.60 100.00,-1.60">
            <neigh lane="e_2_0"/>
        </lane>
    </edge>
    <edge id="-e_3" from="n_4" to="n_3" priority="-1" spreadType="center" shape="800.01,-1.60 600.00,-1.60">
        <lane id="-e_3_0" index="0" speed="13.89" length="200.01" shape="800.01,-1.60 600.00,-1.60">
            <neigh lane="e_3_0"/>
        </lane>
    </edge>
    <edge id="e_1" from="n_1" to="n_2" priority="-1" spreadType="center" shape="0.00,1.60 100.03,1.60">
        <lane id="e_1_0" index="0" speed="13.89" length="100.03" shape="0.00,1.60 100.03,1.60">
            <neigh lane="-e_1_0"/>
        </lane>
    </edge>
    <edge id="e_2" from="n_2" to="n_3" priority="-1" spreadType="center" shape="100.00,1.60 600.01,1.60">
        <lane id="e_2_0" index="0" speed="13.89" length="500.01" shape="100.00,1.60 600.01,1.60">
            <neigh lane="-e_2_0"/>
        </lane>
    </edge>
    <edge id="e_3" from="n_3" to="n_4" priority="-1" spreadType="center" shape="600.00,1.60 800.01,1.60">
        <lane id="e_3_0" index="0" speed="13.89" length="200.01" shape="600.00,1.60 800.01,1.60">
            <neigh lane="-e_3_0"/>
        </lane>
    </edge>

    <junction id="n_1" type="dead_end" x="0.00" y="-0.00" incLanes="-e_1_0" intLanes="" shape="0.00,-0.00 0.00,-3.20 0.00,0.00"/>
    <junction id="n_2" type="priority" x="100.00" y="-0.00" incLanes="-e_2_0 e_1_0" intLanes=":n_2_0_0 :n_2_1_0" shape="100.01,-3.20 100.01,3.20 100.01,-3.20">
        <request index="0" response="00" foes="00" cont="0"/>
        <request index="1" response="00" foes="00" cont="0"/>
    </junction>
    <junction id="n_3" type="priority" x="600.00" y="-0.00" incLanes="-e_3_0 e_2_0" intLanes=":n_3_0_0 :n_3_1_0" shape="600.00,-3.20 600.00,3.20 600.00,-3.20">
        <request index="0" response="00" foes="00" cont="0"/>
        <request index="1" response="00" foes="00" cont="0"/>
    </junction>
    <junction id="n_4" type="dead_end" x="800.00" y="-0.00" incLanes="e_3_0" intLanes="" shape="800.00,0.00 800.00,3.20 800.00,-0.00"/>

    <connection from="-e_2" to="-e_1" fromLane="0" toLane="0" via=":n_2_0_0" dir="s" state="M"/>
    <connection from="-e_3" to="-e_2" fromLane="0" toLane="0" via=":n_3_0_0" dir="s" state="M"/>
    <connection from="e_1" to="e_2" fromLane="0" toLane="0" via=":n_2_1_0" dir="s" state="M"/>
    <connection from="e_2" to="e_3" fromLane="0" toLane="0" via=":n_3_1_0" dir="s" state="M"/>

    <connection from=":n_2_0" to="-e_1" fromLane="0" toLane="0" dir="s" state="M"/>
    <connection from=":n_2_1" to="e_2" fromLane="0" toLane="0" dir="s" state="M"/>
    <connection from=":n_3_0" to="-e_2" fromLane="0" toLane="0" dir="s" state="M"/>
    <connection from=":n_3_1" to="e_3" fromLane="0" toLane="0" dir="s" state="M"/>

</net>

Attachment: fivebyfive.sumocfg
Description: Binary data

import traci
import os, sys

def run_simulation_slowDown(stop_time, simulation_end_time):
    while traci.simulation.getTime() < simulation_end_time:
        traci.simulationStep()
        if traci.simulation.getTime() >= stop_time:
            for vehicle in traci.vehicle.getIDList():
                if traci.vehicle.getTypeID(vehicle) == "ego":
                    traci.vehicle.slowDown(vehicle, 0, 5)
    traci.close()

def run_simulation_setSpeed(stop_time, simulation_end_time):
    while traci.simulation.getTime() < simulation_end_time:
        traci.simulationStep()
        if traci.simulation.getTime() == stop_time:
            for vehicle in traci.vehicle.getIDList():
                if traci.vehicle.getTypeID(vehicle) == "ego":
                    # Disable all influencing factors on speed
                    # traci.vehicle.setSpeedMode(vehicle, 0)
                    # Set the speed to target_speed
                    traci.vehicle.setSpeed(vehicle, 0)
    traci.close()

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'")

# Check if we're in a virtual environment
if 'VIRTUAL_ENV' in os.environ:
    sumoBinary = os.path.join(os.environ['VIRTUAL_ENV'], 'bin', 'sumo-gui')
else:
    sumoBinary = "/home/don/.local/bin/sumo-gui" # to run sumo-gui

    if not sumoBinary:
        sys.exit("please set environment variable 'SUMO_BINARY'")

traci.start([sumoBinary, "-c", "fivebyfive.sumocfg"])

# Time at which vehicles should stop
stop_time = 50  
# Time at which simulation should end
simulation_end_time = 3600

# Run the simulation using the slowDown function or the setSpeed function. Uncomment the one 
# you want to use

# run_simulation_slowDown(stop_time, simulation_end_time)
run_simulation_setSpeed(stop_time, simulation_end_time)
<routes>
    <vType id="ego" maxSpeed="10" color="red"/>
    <vType id="car" maxSpeed="16.67" color="yellow"/>

    <route id="route0" edges="e_1 e_2 e_3"/>

    <vehicle id="0" type="ego" route="route0" depart="0"/>
    <vehicle id="1" type="ego" route="route0" depart="15"/>
    <vehicle id="2" type="car" route="route0" depart="40"/>
    <vehicle id="3" type="car" route="route0" depart="60"/>
    <vehicle id="4" type="car" route="route0" depart="80"/>
</routes>

Back to the top