Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[sumo-user] Park and resume the vehicles from the random traffic(random trips) on random times.

Hi, 
I am working on developing Parking system for autonomous vehicles. I have
generated random traffic using randomtrips.py 
I also generated parking lots as you suggested last time using
generateparking.py

Now I would like to know how can i randomly get a vehicle parked in this
generated parking and randomly resume. 

I have idea of generating the parking and resuming the vehicle at a given
time stamp. 

        
        if step == 3:
            add_vehicle(vehicles[0])
        if step == 5:
            add_vehicle(vehicles[1])
        if step == 100:
            empty_slot(1,vehicles[0])
        if step == 170: 
            empty_slot(2,vehicles[1])


with Add vehicle and empty slot being: 

        def add_vehicle(vehicle):
            global occupied, total_capacity, slot
            if occupied < total_capacity: 
                slotid= get_empty_slot()
                slot[slotid]= vehicle
                slotid= slotid+1
                print("vehicle is parked", vehicle, "slotid", slotid)
                traci.vehicle.setParkingAreaStop(vehicle, "parkingLot")
    #            traci.vehicle.setStop(vehicles, "e1", pos=38.0)
                occupied= occupied +1 
                return slotid
            else:
                print("Slots not available")
                return -1
            
            
        def empty_slot(slotid,vehicle):
            global occupied, slot
            if occupied>0 and slot[slotid-1] != -1:
                slot[slotid-1] = -1
                occupied = occupied - 1
                traci.vehicle.resume(vehicle)
                return True 
            else: 
                return False

Please let me know. 

Regards, 
Swaroop 



--
Sent from: http://sumo-user-mailing-list.90755.n8.nabble.com/


Back to the top