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

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
from __future__ import absolute_import
from __future__ import print_function

import os
import sys
import optparse
import random

# we need to import python modules from the $SUMO_HOME/tools directory
if 'SUMO_HOME' in os.environ:
    tools = os.path.join(os.environ['SUMO_HOME'], 'tools')
    sys.path.append(tools)
else:
    sys.exit("please declare environment variable 'SUMO_HOME'")

from sumolib import checkBinary  # noqa
import traci  # noqa


def run():
    """execute the TraCI control loop"""
    step = 0
	#ed04 ed05 ed06 ed07 ed08 ed10 ed03 ed04
#ed04 ed05 ed06 ed07 ed08 ed10 ed03 ed04
   


    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','ed04'])
        print (vehicle_id)
        step += 1

    traci.close()
    sys.stdout.flush()


def get_options():
    optParser = optparse.OptionParser()
    optParser.add_option("--nogui", action="store_true",
                         default=False, help="run the commandline version of sumo")
    options, args = optParser.parse_args()
    return options


# this is the main entry point of this script
if __name__ == "__main__":
    options = get_options()

    # this script has been called from the command line. It will start sumo as a
    # server, then connect and run
    if options.nogui:
        sumoBinary = checkBinary('sumo')
    else:
        sumoBinary = checkBinary('sumo-gui')

    # this is the normal way of using traci. sumo is started as a
    # subprocess and then the python script connects and runs
    traci.start([sumoBinary, "-c", "traci_1.sumo.cfg",
                             "--tripinfo-output", "tripinfo.xml"])
    run()

Back to the top