Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [sumo-user] Traci + Sumo : Drive vehicle based on edge weight from Source to Destination

Dear Sir,

Successfully implemented following code : 

 """execute the TraCI control loop"""
    step = 0
    while traci.simulation.getMinExpectedNumber() > 0:
        traci.simulationStep()
        print("Vehicle List")
        my_vehicle_list = traci.vehicle.getIDList()
        print(my_vehicle_list)

        for vehicle_id in my_vehicle_list:
                traci.vehicle.setRoute(vehicle_id, ['ed04','ed05','ed06','ed07','ed08','ed10','ed03'])
                print (vehicle_id)
        step += 1
    traci.close()
    sys.stdout.flush()

But When I am executing following line :
                traci.vehicle.setRoute(vehicle_id, ['ed04','ed05','ed06','ed07','ed08','ed10','ed03'])

I got Error : 
traci.exceptions.TraCIException: Route replacement failed for veh1
 

My Route File is :
<routes>
    <vType accel="1.0" decel="5.0" id="Car" length="2.0" maxSpeed="100.0" sigma="0.0" />
    <route id="route0" edges="ed01 ed02 ed03 ed04 ed05 ed06 ed07 ed01"/>
    <route id="route1" edges="ed04 ed05 ed06 ed07 ed08 ed10 ed03 ed04"/>
    <vehicle depart="0" id="veh1" route="route1" type="Car" />
</routes>

Sorry sir for asking such a silly questions,But I am new to this.

On Thu, Jan 10, 2019 at 9:07 PM Jakob Erdmann <namdre.sumo@xxxxxxxxx> wrote:
your script starts with the lines:

while traci.simulation.getMinExpectedNumber() > 0:
        traci.simulationStep()

This loop runs the simulation until all vehicles are gone. Your whole code comes afterwards.
Instead put your traci code inside the loop.

Am Do., 10. Jan. 2019 um 10:29 Uhr schrieb Bijal Varia <bijal.varia88@xxxxxxxxx>:
Sorry sir i forgot to attache route file and config files:

Route File : 
<routes>
    <vType accel="1.0" decel="5.0" id="Car" length="2.0" maxSpeed="100.0" sigma="0.0" />
    <route id="route0" edges="ed01 ed02 ed03 ed04 ed05 ed06 ed07 ed01"/>
    <route id="route1" edges="ed04 ed05 ed06 ed07 ed08 ed10 ed03 ed04"/>

   <!-- <vehicle depart="0" id="veh0" route="route0" type="Car" />
    <vehicle depart="0" id="veh1" route="route1" type="Car" />
    <flow id="type1" color="1,1,0"  begin="0" end= "7200" period="900" type="Car" from="ed01" to="ed07" /> -->

</routes>
Sumo Config File :

<configuration>
    <input>
        <net-file value="traci_1.net.xml"/>       
        <route-files value="traci_1.rou.xml"/>
<additional-files value="traci_1.add.xml"/>
    </input>
    <time>
        <begin value="0"/>
        <end value="10000"/>
    </time>
</configuration>




On Thu, Jan 10, 2019 at 5:24 PM Bijal Varia <bijal.varia88@xxxxxxxxx> wrote:
Thanks sir for your reply.

I am attaching my Traci_runner.py file.

Sir, I am trying your suggestion. But I am not able to get why my_vehicle_list Prints Blank --> () ??

   my_vehicle_list = traci.vehicle.getIDList()
    print(my_vehicle_list) // Why this Prints Blank --> () ??

    for vehicle_id in my_vehicle_list:
        traci.vehicle.setRoute(vehicle_id, ['ed04','ed05','ed06','ed07','ed08','ed10','ed03','ed04'])
        print (vehicle_id)
        step += 1



On Thu, Jan 10, 2019 at 4:43 PM Jakob Erdmann <namdre.sumo@xxxxxxxxx> wrote:

Am Mi., 9. Jan. 2019 um 17:08 Uhr schrieb Bijal Varia <bijal.varia88@xxxxxxxxx>:
Thanks for reply sir.

But what about following?

How to drive vehicle based on Edge weight given Source & destination Junction using Traci?

On Wed 9 Jan, 2019, 1:04 PM Jakob Erdmann, <namdre.sumo@xxxxxxxxx> wrote:
You can set custom edge weights either for individual vehicles or for all vehicles at the same time. See:
in particular

regards,
Jakob

Am So., 6. Jan. 2019 um 14:29 Uhr schrieb Dhaval Varia <dhavalkvaria@xxxxxxxxx>:
Dear Listing,

I have implemented code for Traci to Start SUMO. [Attached Here With]
My target is to drive car using Ant colony algorithm from given Source to destination Junction.
But for now I want help to drive vehicle based on Edge weight.

So my Question is :

1. How to give weight to the edge using Traci Code?
2. How to drive vehicle based on Edge weight given Source & destination Junction?

Please advise me to resolve my query.

:)

Thanks & Best Regards.
----------------------------------------------------------------------------------------
Dhaval varia
(9924343883)
_______________________________________________
sumo-user mailing list
sumo-user@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://www.eclipse.org/mailman/listinfo/sumo-user
_______________________________________________
sumo-user mailing list
sumo-user@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://www.eclipse.org/mailman/listinfo/sumo-user
_______________________________________________
sumo-user mailing list
sumo-user@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://www.eclipse.org/mailman/listinfo/sumo-user
_______________________________________________
sumo-user mailing list
sumo-user@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://www.eclipse.org/mailman/listinfo/sumo-user
_______________________________________________
sumo-user mailing list
sumo-user@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://www.eclipse.org/mailman/listinfo/sumo-user
_______________________________________________
sumo-user mailing list
sumo-user@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://www.eclipse.org/mailman/listinfo/sumo-user

Back to the top