Hey there, a bit new at SUMO and TraCI and I need some help adding vehicles
randomly, basically my program detects if a vehicle is "crashed" i.e. had
to wait more than 60 seconds and when it detects it it sends out and
ambulance, I'm trying to add the ambulance at a random route but it really
isn't working for me.

def run () :
step=0
traci.init(PORT)
ambulancecount=0
while traci.simulation.getMinExpectedNumber() > 0:
traci.simulationStep()
vehicles=traci.vehicle.getIDList()
for v in vehicles:
if (traci.vehicle.getWaitingTime(v) > 60) & (v not in crashedvehicles):
crashedvehicles.append(v)
ambulanceID = "a" ,str(ambulancecount)
ambulancecount=ambulancecount+1
routes=traci.route.getIDList()
route= random.choice(routes) #choose route at random to enter the ambulance
on
traci.vehicle.add(vehID=ambulanceID, routeID=route)
traci.vehicle.changeTarget("a", traci.vehicle.getRoadID(v)) #reroute
ambulance to the crashed vehicle
print "Ambulance set to",traci.vehicle.getRoute(ambulanceID),"\n"
step=step+1
traci.close()




Thats the code, the error comes from the line:
traci.vehicle.add(vehID=ambulanceID, routeID=route)

I have also tried traci.vehicle.add(ambulanceID, route)




The error is:
Traceback (most recent call last):
  File "esrgrid.py", line 46, in <module>
    run()
  File "esrgrid.py", line 34, in run
    traci.vehicle.add(vehID=ambulanceID, routeID=route)
  File "C:\SUMO\sumo-0.21.0\bin\..\tools\traci\vehicle.py", line 710, in add
    1+4 + 1+4+len(typeID) + 1+4+len(routeID) + 1+4 + 1+8 + 1+8 + 1+1)
  File "C:\SUMO\sumo-0.21.0\bin\..\tools\traci\__init__.py", line 266, in
_begin
Message
    cmdID, varID, len(objID)) + objID
TypeError: cannot concatenate 'str' and 'tuple' objects


Help appreciated.

Nick
------------------------------------------------------------------------------
Comprehensive Server Monitoring with Site24x7.
Monitor 10 servers for $9/Month.
Get alerted through email, SMS, voice calls or mobile push notifications.
Take corrective actions from your mobile device.
http://p.sf.net/sfu/Zoho
_______________________________________________
sumo-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sumo-user

Reply via email to