Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [sumo-user] Inquiry : Adding a vehicle and setting a custom route

moveTo requires an edge that  is already on the route of the vehicle. To solve this:

traci.route.add(new_route_id, custom_edge_list)
traci.vehicle.add(vehicle_id, new_route_id)
traci.vehicle.moveTo(vehicle_id, first_lane, ...)

or you could insert the vehicle on a single-edge route (corresponding to the start edge) and follow up with vehicle.setRoute).





Am Fr., 3. Mai 2019 um 14:55 Uhr schrieb Sheshadri Kalkunte Ramachandra <sheshadrik@xxxxxxxxxx>:
Namaste,

I tried giving the value which you suggested 45250008#7_0. but I still get the exception

Step #3.00Error: Answered with error to command 0xc4: Vehicle '45250008#7_0' may be set onto an edge to pass only.
(Thread-6 ) Exception on /start_ambulance [GET]
Traceback (most recent call last):
  File "/home/dreamlab/.local/lib/python2.7/site-packages/flask/app.py", line 2292, in wsgi_app
    response = self.full_dispatch_request()
  File "/home/dreamlab/.local/lib/python2.7/site-packages/flask/app.py", line 1815, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/home/dreamlab/.local/lib/python2.7/site-packages/flask_cors/extension.py", line 161, in wrapped_function
    return cors_after_request(app.make_response(f(*args, **kwargs)))
  File "/home/dreamlab/.local/lib/python2.7/site-packages/flask/app.py", line 1718, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/home/dreamlab/.local/lib/python2.7/site-packages/flask/app.py", line 1813, in full_dispatch_request
    rv = self.dispatch_request()
  File "/home/dreamlab/.local/lib/python2.7/site-packages/flask/app.py", line 1799, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/home/dreamlab/sheshadri/SumoProducer/Rest.py", line 119, in start_ambulance
    result = my_state.set_ambulance_co_ordinates(src, dest, 10) # 10 is the session id
  File "/home/dreamlab/sheshadri/SumoProducer/ProcessEdges.py", line 67, in set_ambulance_co_ordinates
    message = self.sumo_obj.add_new_vehicle(50000, [])  # the second argument is a list of short edges
  File "/home/dreamlab/sheshadri/SumoProducer/Sumo.py", line 153, in add_new_vehicle
    traci.vehicle.moveTo(str(vehicle_id), "45250008#7_0", pos=1.0)
  File "/usr/local/lib/python2.7/dist-packages/traci-1.1.0.1-py2.7.egg/traci/_vehicle.py", line 1266, in moveTo
    self._connection._sendExact()
  File "/usr/local/lib/python2.7/dist-packages/traci-1.1.0.1-py2.7.egg/traci/connection.py", line 107, in _sendExact
    raise TraCIException(err, prefix[1], _RESULTS[prefix[2]])
TraCIException: Vehicle '45250008#7_0' may be set onto an edge to pass only.


From: sumo-user-bounces@xxxxxxxxxxx <sumo-user-bounces@xxxxxxxxxxx> on behalf of Jakob Erdmann <namdre.sumo@xxxxxxxxx>
Sent: 03 May 2019 18:09
To: Sumo project User discussions
Subject: Re: [sumo-user] Inquiry : Adding a vehicle and setting a custom route
 
A lane id consistes of the edge id an underscore '_' and the numerical index of the lane.
e.g the rightmost lane on edge '45250008#7' would be '45250008#7_0'

regards,
Jakob

Am Fr., 3. Mai 2019 um 14:34 Uhr schrieb Sheshadri Kalkunte Ramachandra <sheshadrik@xxxxxxxxxx>:
Namaste,

I have the following requirement:

  1. Add a new vehicle instantly.
  2. Set its route as list of edges. (This will be a custom edge list that I would like the vehicle to follow)
  3. The custom edge list is dynamically generated and hence cannot be added to the rou.xml
I have written the following code:

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

custom_edge_id_list = ["45250008#7","-45250008#7","-45250008#6","-45250008#5","-45250008#4","-45250008#3","-45250008#2","-45250008#1","-45250008#0","45250014#0","45250533#0","45250533#1","45250533#2","45250533#3","-46951252#1","-46951252#0","-35901381#10","-35901381#9","-35901381#8","-35901381#7","-35901381#6","-35901381#5","-35901381#4","-35901381#3","-35901381#2","-35901381#1","40151526#2","-215412812","-345411282#1","-345411282#0","-404335353","383028788#12","383028788#13","379878516#0","379878516#1","383029332","392213813","383031432#0","383031432#1","-470223620","470223615#0","470223615#1","470223615#2","470223615#3","236578402","-452366265#19","-452366265#18","-452366265#17","-452366265#16","-236531497#1","-236531497#0","46918817","-42013627#7","-42013627#6","-42013627#5","46918821"] # This is the custom route which I want it to follow

traci.vehicle.add(str(vehicle_id), random_route_id)# New vehicle which I have added

traci.vehicle.moveTo(str(vehicle_id), "45250008#7", pos=1.0) # First edge in the route that I want the vehicle to be
traci.vehicle.setRoute(str(vehicle_id), custom_edge_id_list) # After the moveTo I expect the vehicle to be on the first edge of the custom edge list

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Reference: https://sumo.dlr.de/wiki/TraCI/Change_Vehicle_State



In the moveTo() api,
  • the first parameter i gave is the vehicleId of the vehicle that I added just before this
  • the second parameter is a laneId, I gave "45250008#7" as the laneId
  • I'm not clear on the value to be passed for the 3rd parameter which is pos, I gave the value to be 1.0
The value 1.0 for pos, was taken by seeing it as a default value in the setStop() api, please advise on what is the value to be used for pos

Here is the actual API : moveTo(self, vehID, laneID, pos)
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Step #5.00Error: Answered with error to command 0xc4: Unknown lane '45250008#7'.T 19278 BU
(Thread-6 ) Exception on /start_ambulance [GET]
Traceback (most recent call last):
  File "/home/dreamlab/.local/lib/python2.7/site-packages/flask/app.py", line 2292, in wsgi_app
    response = self.full_dispatch_request()
  File "/home/dreamlab/.local/lib/python2.7/site-packages/flask/app.py", line 1815, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/home/dreamlab/.local/lib/python2.7/site-packages/flask_cors/extension.py", line 161, in wrapped_function
    return cors_after_request(app.make_response(f(*args, **kwargs)))
  File "/home/dreamlab/.local/lib/python2.7/site-packages/flask/app.py", line 1718, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/home/dreamlab/.local/lib/python2.7/site-packages/flask/app.py", line 1813, in full_dispatch_request
    rv = self.dispatch_request()
  File "/home/dreamlab/.local/lib/python2.7/site-packages/flask/app.py", line 1799, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/home/dreamlab/sheshadri/SumoProducer/Rest.py", line 119, in start_ambulance
    result = my_state.set_ambulance_co_ordinates(src, dest, 10) # 10 is the session id
  File "/home/dreamlab/sheshadri/SumoProducer/ProcessEdges.py", line 67, in set_ambulance_co_ordinates
    message = self.sumo_obj.add_new_vehicle(50000, [])  # the second argument is a list of short edges
  File "/home/dreamlab/sheshadri/SumoProducer/Sumo.py", line 153, in add_new_vehicle
    traci.vehicle.moveTo(str(vehicle_id), "45250008#7", pos=1.0)
  File "/usr/local/lib/python2.7/dist-packages/traci-1.1.0.1-py2.7.egg/traci/_vehicle.py", line 1266, in moveTo
    self._connection._sendExact()
  File "/usr/local/lib/python2.7/dist-packages/traci-1.1.0.1-py2.7.egg/traci/connection.py", line 107, in _sendExact
    raise TraCIException(err, prefix[1], _RESULTS[prefix[2]])
TraCIException: Unknown lane'45250008#7'.

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

But the lane id '45250008#7' I picked up is from a valid route from the route file (.rou.xml)

Please advise on how to address the above situation


Regards,
Sheshadri K R

+91-9845213149

_______________________________________________
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