Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[sumo-user] Unexplainable behaviour for lane change mode

Hello,

As per my understanding, the "duration" argument in the change lane command would keep attempting to change lane to the target lane until the end of that duration or if another TraCI change lane command overrides it. If I set my Lane change mode to 0 (all safety checks and any control by SUMO is gone), then I would expect the below code to get all the vehicles to the end (with collisions).

I have attached a short video to show the behaviour that is observed. Not sure why the vehicles closest to the blockage do not turn to the free lane? (even though their indicator is yellow and shows that they want to change lane?)

My TraCI code:

step = 0
GHOST_POS = 750.0
END = 86400.0
BLOCK_LENGTH = 300

traci.vehicle.add(vehID='ghost', routeID='r0', typeID='veh', depart=0, departLane=0, departPos=GHOST_POS, departSpeed='random', arrivalLane='current', arrivalPos=GHOST_POS)
traci.vehicle.setColor(vehID='ghost',color=(255,0,0))
traci.vehicle.setLength(vehID='ghost',length=BLOCK_LENGTH)

traci.vehicle.setStop(vehID='ghost', edgeID='1f2', pos=GHOST_POS, duration=10, until=END)# flags=0, startPos=0, until=120)

# duration - min duration for stopping
# until - timestep at which the route continues

lane_ids = list(traci.lane.getIDList())

BLOCKED_LANE = 0
FREE_LANE = 1
LC_MODE = 0 # 512 # 1621 # 0 # 512 # 256 # 1109 #
S_MODE = 0
NUMBER_OF_VEH = 100
LC_MAX_DURATION = END

def take_step(step=1):

    lane_info = dict()
    for li in lane_ids:

        lane_info[li] = {
            'mean_speed' : traci.lane.getLastStepMeanSpeed(laneID=li),
            'vehicle_ids' : traci.lane.getLastStepVehicleIDs(laneID=li),
        }

    for vh in lane_info['1f2_1']['vehicle_ids']: # free lane
        if vh == 'ghost':
            continue
        traci.vehicle.setLaneChangeMode(vehID=vh, lcm=LC_MODE)

        traci.vehicle.changeLane(vehID=vh, laneIndex=BLOCKED_LANE, duration=LC_MAX_DURATION)
        print('Vehicle {} will try to move to BLOCKED lane'.format(vh))
 

    for vh in lane_info['1f2_0']['vehicle_ids']: # blocked lane
        if vh == 'ghost':
            continue
       
        traci.vehicle.setLaneChangeMode(vehID=vh, lcm=LC_MODE)
        traci.vehicle.changeLane(vehID=vh, laneIndex=FREE_LANE, duration=LC_MAX_DURATION)
        print('Vehicle {} will try to move to FREE lane'.format(vh))
 

arrived = 0
while arrived < NUMBER_OF_VEH:

    print('################ SIM TIME: {} ##################'.format(traci.simulation.getTime()))
    print('################ SIM STEP COUNT: {} ################'.format(step))
    step+=1
    print('\n')

    take_step(step)
   
    print('Arrived: {}'.format(arrived))
    traci.simulationStep()
 
traci.close()

Thank you.

Sincerely,
Hriday

Attachment: weird blockage.mp4
Description: video/mp4


Back to the top