Dear Vaibah Rungta,

to identify if a specific vehicles is on the network you may use:

if not veh_id in traci.vehicle.getIDList():
     do_something_special()

With best regards
Marek Heinrich
simoserv GmbH

Am 02.11.2016 um 01:55 schrieb Vaibhav Rungta:
> Hello,
> I am trying to make some simple applications using TraCI.
>
> *usingtraci1.py*
> This code executes correctly and vehicle with vehicle ID v1 is stops
> whenever the traffic light is red irrespective of it's position.
>
> traci.simulationStep()
>      if traci.trafficlights.getPhase("B2") == 0:      #signal at B2 in state
> GGrr
>          traci.vehicle.setSpeed("v1", 0)
>      else:
>          traci.vehicle.setSpeed("v1", 20)
>      step = step + 1
>
> But the problem once the vehicle v1 leaves the network the execution stops
> and an error is generated because v1 is no longer in network. Please help
> understand how may I avoid it.
>
> *My approach to avoid this error*:
> I thought of capturing vehicle ID and writing that to txt file. I'll
> re-structure the if statement and only if v1 is in the network then the
> previous command will be executed.
>
> However I am getting an in file *usingtraci3.py*
>
> *Error: tcpip::Socket::recvAndCheck @ recv: Socket reset by peer*
> *Quitting (on error).*
>
> I think it's for the wrong usage of command:
> get_id = traci.vehicle.getId()
> Please help me identify the correct command.
>
> Next, I plan write all the values to text file:
> with open ("vid.txt", "w") as vehicle_id:
>          get_id = traci.vehicle.getLastStepVehicleIDs()
>          vehicle_id.write (str(get_id) + '\n')
>
> Is there a standard syntax for using commands retrieving vehicle ID?
> How can we use these values in run time?
>
> For eg:
> if (traci.vehicle.getId() == 'A1')
>   traci.trafficlights.setPhase("traffic_light_index", phase_index)
>
>
> Thank you.
>
> Regards,
> Vaibhav Rungta
> Graduate Student - Industrial and Systems Engineering
> Graduate Assistant - Toyota Production Systems Lab
> Research Assistant - University Transport Research Center
> 585-754-7133
>
>
> ------------------------------------------------------------------------------
> Developer Access Program for Intel Xeon Phi Processors
> Access to Intel Xeon Phi processor-based developer platforms.
> With one year of Intel Parallel Studio XE.
> Training and support from Colfax.
> Order your platform today. http://sdm.link/xeonphi
>
>
> _______________________________________________
> sumo-user mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/sumo-user

------------------------------------------------------------------------------
Developer Access Program for Intel Xeon Phi Processors
Access to Intel Xeon Phi processor-based developer platforms.
With one year of Intel Parallel Studio XE.
Training and support from Colfax.
Order your platform today. http://sdm.link/xeonphi
_______________________________________________
sumo-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sumo-user

Reply via email to