Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[sumo-user] Initialization of Pre-set GPS long lats
  • From: Paul Fierro <paulfierro@xxxxxxxxxx>
  • Date: Mon, 7 Sep 2020 15:58:11 +0000
  • Accept-language: en-US
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=kubbla.com; dmarc=pass action=none header.from=kubbla.com; dkim=pass header.d=kubbla.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=92Kh/aIAq9ASdvT3vU0ABX6Zp9a7PY9nJrvhJLev5ps=; b=QqLxDCwJBdBZIl6V2r6RLNmis8pVakTIr1GjvaZpLYQ8pLBjB38s+HoeoVV42s/C6rUpe0AcE2XKYW9YToM85QgcyyQvrI7wpw5DiiPMFAVWou0xAvbKe85rli4nSFgm1ItSaQRT67kIDEmPM1THeXXuDGani4uPwPSsz7OY1p7sBeu0qLANC/FEhRK+EdAJTtjHeq8UMGr5rUO5YSmcQ+01+uqFHZ/uCf72PNsLceL72caf4uT8mphgDkyb5C15GqXDLHOfdTCOHqgh+9w4oySEODt59rX/4fB7uQnM55aMMyGyo4atBxwAnS1WrcXTjtq8LY8iWB9qgOtucBBWPg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WT+R1oJkEAda3Z/MYiZR74stVNuWWJBGUCXtb5mEsaJR9veT+/50Om+BdMw5XO8NNEPSMpjnWeG2jC9dP/T1/Kq1QK4BlMjbW6N9vYXBg+7WlLrCzZ9ErfKrrIuEEpT26Bnsf1MEgqJMhWyGvG6S6ItswJ0AvIB/Y9iXwsBhLhB+XTPDI9kidt/lY1hh4EtAuvnZnzWWltILv4WtveHJ1v4gF1IFfFnU+SScoJt0SBqR6ejzVRW6uLiK1k0MZbVSRUnI8DOYIAAruhCn/C1Iow01uFkxW+rMpM9K/FgeZkhLbixDlZmCyYt6WY9cltjyHWOsTpwzoHAIS0BPKEKncg==
  • Delivered-to: sumo-user@xxxxxxxxxxx
  • List-archive: <https://www.eclipse.org/mailman/private/sumo-user>
  • List-help: <mailto:sumo-user-request@eclipse.org?subject=help>
  • List-subscribe: <https://www.eclipse.org/mailman/listinfo/sumo-user>, <mailto:sumo-user-request@eclipse.org?subject=subscribe>
  • List-unsubscribe: <https://www.eclipse.org/mailman/options/sumo-user>, <mailto:sumo-user-request@eclipse.org?subject=unsubscribe>
  • Thread-index: AQHWhS3BzvqiTliJTUiNyBXwUUMOLQ==
  • Thread-topic: Initialization of Pre-set GPS long lats

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






Back to the top