Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[sumo-user] Blocking part of lane temporarily (due to roadworks)

Hello,

I recently found out that the only way to simulate a blockage in a temporary part of the lane, (maybe due to construction activities) is by stopping a 'ghost' vehicle and setting its length to the intended area of effect. Source: https://gitanswer.com/has-sumo-a-method-to-block-part-of-the-lane-1007148310 . Please correct me if that is not the case.

How would I go about allowing the other vehicles to lane change around this 'ghost' vehicle to reach the end of a single edge with 3 lanes? Edge file:

<edges> 
<edge id="1f2" from="1" to="2" speed="30" numLanes="3" spreadType="center"/> 
</edges>

Route file:

<routes> 
<vType id="veh" length="5" maxSpeed="30" lcStrategic="0" lcCooperative="0" lcSpeedGain="0" lcKeepRight="0" lcOvertakeRight="0" lcOpposite="0" lcSpeedGainLookahead="0" lcCooperativeRoundabout="0" lcSublane="0" lcPushy="0" /><route id="r0" color="1,1,0" edges="1f2" /> 
</routes>

In TraCI (Python):

step = 0
traci.vehicle.add(vehID='ghost', routeID='', typeID='veh', depart=0, departLane=0, departSpeed='random')
traci.vehicle.setColor(vehID='ghost',color=(0,255,0))

while step < 1000:
    traci.simulationStep()
    if step % 10 == 0:
        traci.vehicle.add(vehID='agent_{}'.format(step), routeID='r0', typeID='veh', depart='now', departLane='random', departSpeed='random', arrivalLane='random')
    # traci.vehicle.moveToXY(vehID='ghost', edgeID='1f2', lane=0, x=68.0, y=-3.3, angle=90, keepRoute=1)
    traci.vehicle.setStop(vehID='ghost', edgeID='1f2', pos=1, laneIndex=0, duration=100, flags=0, startPos=0, until=120)
    step+=1
traci.close()

The moveToXY seems to stop the 'ghost' vehicle at the specified coordinates indefinitely (until simulation ends) but the setStop command doesn't seem to make any modifications. So I was wondering if a combination of these would make it ideal for my case.

Why does the vehicle completely stop after using the moveToXY command indefinitely? Could you clarify the parameters used for the setStop command, specifically pos, duration, flags, startPos and until? I'm assuming until is from the start time of the simulation (at 0). So if I set until to 300, the vehicle should stay in the stopped state till 300 simulation time. But then I am confused because duration would mean time in seconds for the stopped state?

Also, I have already tried using TraCI's lane.setDisallowed() method, but it blocks the entire lane and not just the specified part of it.

Thank you for any assistance in advance.

Sincerely,
Hriday.

Back to the top