Hello,
you need to make yourself familiar with the format of traffic light
definitions:
http://sumo.dlr.de/wiki/Simulation/Traffic_Lights
Each intersection has its own distinct number of phases and number of
states making up a phase.
regards,
Jakob

2015-01-04 15:26 GMT+01:00 Nick Smith <[email protected]>:

> On second thought I will include the getNextLight() functon too just in
> case it's part of the problem. it seems to work, though I have to change it
> anyway since its' rather ineficcient.
>
> def getNextLight(v) :
> edge1 = traci.vehicle.getRoadID(v)
> edge2= getNextEdge(v)
> if edge2:
> lights= traci.trafficlights.getIDList()
> for tl in lights:
> tlinks= traci.trafficlights.getControlledLinks(tl)
> for link in tlinks:
> for edgelink in link :
> if ( edge1 in edgelink[0] ) & (edge2 in edgelink[1]):
> return tl
>
> Nick
>
> On Sun, Jan 4, 2015 at 2:16 PM, Nick Smith <[email protected]>
> wrote:
>
> > Hey there still a relatively new user. I am writing a program that sends
> > out an emergency vehicle to a crash site where certain driving policy
> > changes are made on the emergency vehicles' route. One of these is to set
> > al traffic lights it reaches green.
> >
> > At first I attempted to change it using the get/setPhase() methods which
> > proved unsuccessful:
> >
> > def setNextLight(ambulanceID) :
> > tral = getNextLight(ambulanceID)
> > if tral:
> > print "Next light is : ", tral
> > if traci.trafficlights.getPhase(tral)!=4 :
> > traci.trafficlights.setPhase(tral, 4) #if not green set green
> > print "traffic light set to green"
> >
> > I can't remember why I thought setting it to 4 would make it green I
> wrote
> > this in my first two weeks of using Sumo, I tried to fix it by using the
> > setRedYellowGreenState() method instead but this caused invalid phase
> > length exceptions (I assume because it interrupted a current phase to
> make
> > the change).
> >
> > So my question is how do I make this function work (getNextLight() is a
> >  function I wrote myself, it seems to work fine).
> >
> > Thank you!
> >
> > Nick
> >
>
> ------------------------------------------------------------------------------
> Dive into the World of Parallel Programming! The Go Parallel Website,
> sponsored by Intel and developed in partnership with Slashdot Media, is
> your
> hub for all things parallel software development, from weekly thought
> leadership blogs to news, videos, case studies, tutorials and more. Take a
> look and join the conversation now. http://goparallel.sourceforge.net
> _______________________________________________
> sumo-user mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/sumo-user
>
------------------------------------------------------------------------------
Dive into the World of Parallel Programming! The Go Parallel Website,
sponsored by Intel and developed in partnership with Slashdot Media, is your
hub for all things parallel software development, from weekly thought
leadership blogs to news, videos, case studies, tutorials and more. Take a
look and join the conversation now. http://goparallel.sourceforge.net
_______________________________________________
sumo-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sumo-user

Reply via email to