Skip to main content

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

Jakob,
Thanks again for the quick response.

I am looking into the suggested workaround, so far with the following code
for initialization:

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

# Set initial position
(edge_id, pos, lane_index) = traci.simulation.convertRoad(initial_x,
initial_y, vClass="passenger")
lane_id = edge_id + '_' + str(lane_index)
traci.vehicle.setRoute(vehicle_id, [edge_id]) # to avoid moveTo error "may
be set onto an edge to pass only"
traci.vehicle.moveTo(vehID=vehicle_id, laneID=lane_id, pos=pos)
x, y = traci.vehicle.getPosition(vehID=VEH_ID)

# call until a route is provided:
traci.vehicle.moveToXY(VEH_ID, edge_id, laneIndex, x, y, keepRoute=0)

It seems to work fine in most cases, but it looks like if convertRoad
returns an "internal" edge, Sumo crashes on the next simulation step. This
could happen for example if the initial x, y values are inside junction.

I uploaded a code and network example to: https://we.tl/t-rWckA3XYbp

Is there any function call I am missing?

Thanks!
Shawn



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


Back to the top