Hello,

I have been trying to place approximately 200 people at varying locations at 
the start of the simulation and then I just want them to wait there until 
another vehicle arrives to picck them up.

Once that vehicle gets close and stops then the initialization person/vehicle 
can disappear and essentially take 1 of the capacity of the arriving vehicle 
like a bus picking someone up.  I have read all the Long, Lats into a data 
frame, and converted it to X,Y cartesian with no issues.  I then move using 
moveToXY( ....., with keepRoute=2) as this is the only method that seems to not 
get the 100-meter road nearby error.

I initially created a simple route as launching pad where I then moved to the 
other more important initialization point read into the data frame, but what 
happens is although vehicle WIP count on gui is correct they are not available 
to the simulation, as they seem to be teleporting.

I then decided to load 194 random trips just to get them going into the model 
moving, and then move them to the initialization point.  I am using vehicles to 
do this as it was the only object that had movetoXY function, but I do see 
persons or pedestrians' object.  I was wondering if someone could give some 
guidance of how best to move appropriate objects to allocation waiting for 
later bus to come pick them up.  I am still working through trial and error and 
will look back here to see if any code example exits to do this rudimentary 
item at initialization.


    tsp_file = "..\qa194.tsp"
    problem = somTsp.read_tsp_oat(tsp_file)
    ids = problem['id'].values
    problem['Lng'] = problem['x'].apply( lambda x: (x*.001) )
    problem['Lat'] = problem['y'].apply( lambda x: (x*.001) )
    problem['x'] = problem['x'].apply( lambda x: (x*.001)*11000 )
    problem['y'] = problem['y'].apply( lambda x: (x*.001)*11000 )
    problemXYvals = problem[['x', 'y']].values
    problemLatLngvals = problem[['Lat', 'Lng']].values

    stid = traci.route.add("startRoute", startRoute )
    for inx, pt in enumerate(problemXYvals):
        x = pt[0]
        y = pt[1]
        iLng = problemLatLngvals[inx][0]
        iLat = problemLatLngvals[inx][1]
        XYconv = traci.simulation.convertGeo( iLng, iLat, fromGeo=True )
        Xcnv = round(XYconv[0], 10)
        Ycnv = round(XYconv[1], 10)
        veh_ids = ids[inx]
        #traci.vehicle.add(veh_ids, "startRoute" )
        #speed = traci.vehicle.getSpeed(veh_ids)
        vehicleState, chgDfni = GetVehcileState(saveVehicleState, veh_ids)
        saveVehicleState.update( { veh_ids: vehicleState } )
        vehicleState[23] = Xcnv
        vehicleState[24] = Ycnv
        print ( "veh_id:", veh_ids, " Store Vehilce starting location Xcnv:", 
Xcnv," Ycnv:", Ycnv )
        # if inx == 2:
        #     break

    StartSimulationEndSeconds = 3600*10
    cstsecs = 0
    step            = 0
    targMPH         = 35 # 22.352 m/s = 50 MPH
    targMPS         =   targMPH * 0.44704

    # parse the net - temporary comment out
    #net = sumolib.net.readNet('./Qatar.net.xml')
    # trafficLightRoutes, nonTrafficLightRoutes = InitSumoTrafficLightArrays()
    while traci.simulation.getMinExpectedNumber() > 0 or cstsecs < 
StartSimulationEndSeconds:
        amtCount = traci.vehicle.getIDCount()
        print(" amt_count:", amtCount )
        if amtCount == 194:
            print(" WIP TARGET MADE:", amt_count)

        for veh_ids in traci.vehicle.getIDList():
            veh_id = int(veh_ids)
            position = traci.vehicle.getPosition(veh_ids)
            xv = tuple(position)[0]
            yv = tuple(position)[1]
            geo = traci.simulation.convertGeo(xv, yv, fromGeo=False)
            lngv = round(geo[0], 10)
            latv = round(geo[1], 10)

            vehicleState, chgDfni = GetVehcileState( saveVehicleState, veh_ids )
            Xcnv = vehicleState[23]
            Ycnv = vehicleState[24]
            route_id = traci.vehicle.getRouteID( veh_ids )
            edge_id = traci.vehicle.getRoadID( veh_ids )
            lane_index = traci.vehicle.getLaneIndex( veh_ids )
            angle = traci.vehicle.getAngle( veh_ids )
            speed = traci.vehicle.getSpeed( veh_ids )
            if speed > 0.0:
               traci.vehicle.slowDown( veh_ids, 0.0, 1.0 )

            if not (Xcnv == xv and Ycnv == yv):
                edge_id = ""
                lane_index = -1
                traci.vehicle.moveToXY( veh_ids, edge_id, lane_index, Xcnv, 
Ycnv, angle, keepRoute=2 )
                traci.vehicle.moveToXY( veh_ids, edge_id, lane_index, Xcnv, 
Ycnv, angle, keepRoute=2 )
                print( "veh_id:", veh_ids, " Moved Vehilce to Xcnv:", Xcnv, " 
Ycnv:", Ycnv, " speed:", speed, edge_id, lane_index, angle )
            else:
                print( "veh_id:", veh_ids, " Arrived at stop! speed:", speed, 
edge_id, lane_index, angle  )


        for veh_ids in traci.simulation.getArrivedIDList():
            print("veh_id:", veh_ids, " Restarting Route Why?" )
            traci.vehicle.add(veh_ids, "startRoute")
            vehicleState, chgDfni = GetVehcileState(saveVehicleState, veh_ids)
            XcnvOld = vehicleState[23]
            YcnvOld = vehicleState[24]
            rndvX = 1.0 + ((random.random() - .5) * 2.0) * .05
            rndvY = 1.0 + ((random.random() - .5) * 2.0) * .05
            Xcnv = XcnvOld * rndvX
            Ycnv = YcnvOld * rndvY
            vehicleState[23]  = Xcnv
            vehicleState[24]  = Ycnv
            print ( "veh_id:", veh_ids, " ADJUSTING Vehilce starting location 
Xcnv:", Xcnv," Ycnv:", Ycnv )
            saveVehicleState.update( { veh_ids: vehicleState } )

        traci.simulationStep()
        step += 1





_______________________________________________
sumo-user mailing list
[email protected]
To unsubscribe from this list, visit 
https://www.eclipse.org/mailman/listinfo/sumo-user

Reply via email to