Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [sumo-dev] Regrading Retrieval of vtype parameter using traci

you can use edge.getLastStepVehicleIDs to loop over all vehicles on an edge where the type must be changed.

Am Sa., 8. Mai 2021 um 18:50 Uhr schrieb SHANTANU PHANSE via sumo-dev <sumo-dev@xxxxxxxxxxx>:
Thank you for your kind response.

1. I have implemented the first option successfully for different vtypes.

2. By Traci I used the following code. It is working successfully for a single vehicle and will work for multiple vehicles.

If the number of vehicles increases and we want to check for each vehicle, then this code will have a lot of redundancy.
Can you suggest me some changes so that I will be able to improve the code?

def run():
   
    # intialisation of variable
    steps = 0
    edge_id ="e0"
   
    while steps < 3000:
       
        traci.simulationStep()
       
        #to get the edge id
        edge_id0 = traci.vehicle.getRoadID("0") 
       
        edge_id1 = traci.vehicle.getRoadID("1")  
           
        #if the edge id is e1 then change vtype to d
        if(edge_id0 == "e1"):
            traci.vehicle.setType("0", "d")       
           
        if(edge_id1 == "e1"):
            traci.vehicle.setType("0", "d")  
           
        #if the edge id is e1 then change vtype to c
        if(edge_id0 == "e2"):
             traci.vehicle.setType("0", "c")
        if(edge_id1 == "e2"):
             traci.vehicle.setType("0", "c")  
             
        steps+=1
       
    traci.close()



Thanks and Regards
Shantanu Phanse
DA-IICT, India    






On Sat, May 8, 2021 at 12:10 AM Jakob Erdmann <namdre.sumo@xxxxxxxxx> wrote:
There are several options for changing parameters based on location:
- exchange the vehicle type with another vehicle type based on pre-defined xml input: https://sumo.dlr.de/docs/Simulation/Calibrator.html#calibrating_vehicle_types
- monitor the vehicle location with traci and then use traci functions to change the type based on the current vehicle edge
- define custom parameters for the edges (i.e. in netedit) and then use those parameters within your custom car following model to modify its own parameters based on the current edge

regards,
Jakob

Am Fr., 7. Mai 2021 um 14:52 Uhr schrieb SHANTANU PHANSE via sumo-dev <sumo-dev@xxxxxxxxxxx>:
Thank you for your kind response.

I had one more doubt. Can we have different values of the user-defined car following model parameters "I", "d" for different edges of a road network?

eg. We have a road network of edges (e1---e2---e3) and say edge 1 has value i = 2, d = 10, and edge 2 has value i = 5, d = 40 in the same road network.

Thanks and regards
Shantanu Phanse
DA-IICT, India

On Thu, Apr 22, 2021 at 2:03 PM Jakob Erdmann <namdre.sumo@xxxxxxxxx> wrote:

Am Do., 22. Apr. 2021 um 10:13 Uhr schrieb SHANTANU PHANSE via sumo-dev <sumo-dev@xxxxxxxxxxx>:
Thank you for your kind response.
I there any other way I can manipulate my user-defined parameters 'i' and 'd' while the simulator is running.

On Thu, Apr 1, 2021 at 4:51 PM <Maria.Armellini@xxxxxx> wrote:

Hi Shantanu,

 

I have tried it myself and saw that when you use .setParameter a new parameter is created. For example, when you call traci.vehicletype.setParameter("c", "maxSpeed", '4.00'), you don’t change the maximum speed parameter, but a new parameter “param:maxSpeed” is created with that value (see picture). If you want to change the maximum speed, you can use .setMaxSpeed(). See VehicleType_Value_Retrieval and  VehicleType_State.

As for the “i” and “d” parameters of your CF model, I think this is still under development, see GitHub-Issue.

 

Regards,

Giuliana

 

Von: sumo-dev <sumo-dev-bounces@xxxxxxxxxxx> Im Auftrag von SHANTANU PHANSE via sumo-dev
Gesendet: Mittwoch, 31. März 2021 15:49
An: sumo-dev@xxxxxxxxxxx
Cc: SHANTANU PHANSE <201911048@xxxxxxxxxxxx>
Betreff: [sumo-dev] Regrading Retrieval of vtype parameter using traci

 

Hello,

 

I have created a new car-following model in SUMO for practice.

 

rou.xml has vtype attribute as follows

 

<vType id = "c" departLane = "best" maxSpeed = "16.67" carFollowModel="W" d = "30" i = "12"/>

------------------------------------------------------------------------------------------------

I aim to change the vtype parameters of maxSpeed, i, d using traci. 

 

The snippet of the code I am using is as follows

 

def run():
 
    steps = 0
   
    while steps < 1000:
        traci.simulationStep()
        steps+=1

 

      #get the parameters 

     if(steps == 5):
           print(traci.vehicletype.getParameterWithKey("c", "d"))
           print(traci.vehicletype.getParameterWithKey("c", "i"))
           print(traci.vehicletype.getParameterWithKey("c", "maxSpeed"))  
       

      #set the parameters at step 1 
        if(steps == 10):
            traci.vehicletype.setParameter('c', 'depth', '0')
            traci.vehicletype.setParameter('c', 'intensity', '0')
            traci.vehicletype.setParameter("c", "maxSpeed", '4.00')
       
 
Print statements Output is as follows:

      ('depth', '')         #parameter name with empty string as value

      ('intensity', '')
       ('maxSpeed', '')

    -------------------------------------------------------------------------------------------------------   

Note: There is no change reflected in the sumo-GUI.

 

Thanks and Regards 

Shantanu Phanse

 

 

 

 

_______________________________________________
sumo-dev mailing list
sumo-dev@xxxxxxxxxxx
To unsubscribe from this list, visit https://www.eclipse.org/mailman/listinfo/sumo-dev
_______________________________________________
sumo-dev mailing list
sumo-dev@xxxxxxxxxxx
To unsubscribe from this list, visit https://www.eclipse.org/mailman/listinfo/sumo-dev
_______________________________________________
sumo-dev mailing list
sumo-dev@xxxxxxxxxxx
To unsubscribe from this list, visit https://www.eclipse.org/mailman/listinfo/sumo-dev
_______________________________________________
sumo-dev mailing list
sumo-dev@xxxxxxxxxxx
To unsubscribe from this list, visit https://www.eclipse.org/mailman/listinfo/sumo-dev
_______________________________________________
sumo-dev mailing list
sumo-dev@xxxxxxxxxxx
To unsubscribe from this list, visit https://www.eclipse.org/mailman/listinfo/sumo-dev
_______________________________________________
sumo-dev mailing list
sumo-dev@xxxxxxxxxxx
To unsubscribe from this list, visit https://www.eclipse.org/mailman/listinfo/sumo-dev

Back to the top