Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[sumo-user] Adding a stopped vehicle outside the network and setting a route

Hi all,

I am a beginner using Sumo via libsumo/C++ and TraCI/Python for testing. I
am trying to add a stopped vehicle at a user-provided position, and later on
assign a route to a user-provided edge to that vehicle. Here is a minimal
code example:

# add a vehicle
traci.vehicle.add(vehID=vehicle_id, routeID="", typeID="veh_passenger")

# call until a route is provided:
traci.vehicle.moveToXY(vehicle_id, "", 0, initial_x, initial_y, keepRoute=0)

# once the target edge is provided:
edge = traci.vehicle.getRoadID(vehicle_id)
route = traci.simulation.findRoute(edge, target_edge)
traci.route.add(route_id, route.edges)
traci.vehicle.setRouteID(vehicle_id, route_id)

This seems to work fine when the initial position is on the road network.
When the initial position is outside the network or on a non-permitted lane,
the vehicle may get positioned on a non-permitted lane (e.g. a sidewalk).
Then when a route is set the vehicle is unable to reach the main network and
eventually gets teleported.

How would you recommend to handle this case? Is there any way to position
the vehicle initially on the nearest permitted lane? Or somehow allow it to
reach a permitted lane by driving (e.g. by crossing a sidewalk and a bike
lane)?

Thank you,
Shawn



--
Sent from: http://sumo-user-mailing-list.90755.n8.nabble.com/


Back to the top