Exemple #1
0
        frame=[320, 180],
        throttle=True,
        brake=True,
        steering=True,
        speed=True,
        acceleration=True,
        yaw=True,
        yawRate=True,
        isCollide=True,
        location=True,
        drivingModeMsg=True
    )  # lidar=[3, True, 100.0, 1000, 60.0, 300.0, 20, 85.0, 115.0], , vehicles=True, peds=True
    # Automatic driving scenario
    scenario = Scenario(weather='EXTRASUNNY',vehicle='blista', time=[12,0], drivingMode=[-2, 3, 25.0, 1.0, 1.0],
        route=[	\
      -1989.000000, -468.250000, 10.562500,
      1171.351563, -1925.791748, 36.220097
      ])

    client.sendMessage(Start(scenario=scenario,
                             dataset=dataset))  # Start request
    count = 0
    tripNum = 0
    old_location = [0, 0, 0]
    while True:  # Main loop
        try:
            # Message recieved as a Python dictionary
            message = client.recvMessage()

            if (count % 500) == 0:
                print(count)
Exemple #2
0
    dataset = Dataset(rate=30,
                      frame=[320, 160],
                      throttle=True,
                      brake=True,
                      steering=True,
                      vehicles=True,
                      peds=True,
                      reward=[15.0, 0.0],
                      direction=None,
                      speed=True,
                      yawRate=True,
                      location=True,
                      time=True)
    # Send the Start request to DeepGTAV.
    scenario = Scenario(
        drivingMode=[786603, 15.0]
    )  # Driving style is set to normal, with a speed of 15.0 mph. All other scenario options are random.
    client.sendMessage(Start(dataset=dataset, scenario=scenario))

    # Start listening for messages coming from DeepGTAV. We do it for 80 hours
    stoptime = time.time() + 80 * 3600
    while time.time() < stoptime:
        try:
            # We receive a message as a Python dictionary
            message = client.recvMessage()

            # The frame is a numpy array and can be displayed using OpenCV or similar
            # image = frame2numpy(message['frame'], (320,160))
            # cv2.imshow('img',image)
            # cv2.waitKey(-1)
        except KeyboardInterrupt:
Exemple #3
0
            vehicles=args.vehicles,
            trafficSigns=args.trafficSigns,
            peds=args.peds,
            reward=args.reward,
            speed=args.speed,
            yawRate=args.yawRate,
            location=args.if_location,
            time=args.dataset_time,
            roadinfo=args.roadinfo,
            direction=args.des
        )

        if args.auto_drive:
            scenario = Scenario(
                drivingMode=args.driving_mode,
                vehicle=args.vehicle,
                weather=weather,
                time=args.time,
                location=args.location)
        else:
            scenario = Scenario(
                vehicle=args.vehicle,
                weather=weather,
                time=args.time,
                location=args.location)
        client.sendMessage(Start(dataset=dataset, scenario=scenario))
        time.sleep(5)  # wait for the scene to be ready

        # Setup multi-threading for receiving messages
        queue = Queue()
        manager = Manager()
        infosaver = save_game_info(img_dir=info_full_path)
Exemple #4
0
'''
if input("Continue?") == "y": # Wait until you load GTA V to continue, else can't connect to DeepGTAV
    print("Conintuing...")
'''
# Loads into a consistent starting setting
print("Loading Scenario...")
client = Client(ip='localhost', port=8000)  # Default interface
dataset = Dataset(rate=60,
                  frame=[800, 600],
                  throttle=True,
                  brake=True,
                  steering=True,
                  location=True,
                  drivingMode=True)
scenario = Scenario(
    weathers='EXTRASUNNY', vehicle='blista', times=[12, 0], drivingMode=-1
)  #, location=[-2573.13916015625, 3292.256103515625, 13.241103172302246])
client.sendMessage(Start(scenario=scenario))

count = 0
print("Starting Loop...")
while True:
    try:
        lasttime = time.time()
        # Collect and preprocess image
        message = client.recvMessage()
        image = message['frame']
        image = grab_screen(region=(0, 0, 800, 600))
        image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)

        # image = frame2numpy(image, (800, 600))
Exemple #5
0
                        default='localhost',
                        help='The IP where DeepGTAV is running')
    parser.add_argument('-p',
                        '--port',
                        default=8000,
                        help='The port where DeepGTAV is running')
    args = parser.parse_args()

    # Creates a new connection to DeepGTAV using the specified ip and port.
    # If desired, a dataset path and compression level can be set to store in memory all the data received in a gziped pickle file.
    # We don't want to save a dataset in this case
    client = Client(ip=args.host, port=args.port)

    # We set the scenario to be in manual driving, and everything else random (time, weather and location).
    # See deepgtav/messages.py to see what options are supported
    scenario = Scenario(drivingMode=-1)  #manual driving

    # Send the Start request to DeepGTAV. Dataset is set as default, we only receive frames at 10Hz (320, 160)
    client.sendMessage(Start(scenario=scenario))

    # Dummy agent
    model = Model()

    # Start listening for messages coming from DeepGTAV. We do it for 80 hours
    stoptime = time.time() + 80 * 3600
    while time.time() < stoptime:
        try:
            # We receive a message as a Python dictionary
            message = client.recvMessage()

            # The frame is a numpy array that can we pass through a CNN for example
Exemple #6
0
                        '--port',
                        default=8000,
                        help='The port where DeepGTAV is running')
    args = parser.parse_args()

    # Creates a new connection to DeepGTAV using the specified ip and port.
    # If desired, a dataset path and compression level can be set to store in memory all the data received in a gziped pickle file.
    # We don't want to save a dataset in this case
    client = Client(ip=args.host, port=args.port)

    # We set the scenario to be in manual driving, and everything else random (time, weather and location).
    # See deepgtav/messages.py to see what options are supported
    #scenario = Scenario(drivingMode=-1)
    scenario = Scenario(weather='EXTRASUNNY',
                        vehicle='Vader',
                        time=[12, 0],
                        drivingMode=[786603, 25.0],
                        location=[201.8704, -51.1309, 0])

    # Send the Start request to DeepGTAV. Dataset is set as default, we only receive frames at 10Hz (320, 160)
    client.sendMessage(Start(scenario=scenario))

    # Dummy agent
    model = Model()

    # Start listening for messages coming from DeepGTAV. We do it for 80 hours
    stoptime = time.time() + 80 * 3600
    while time.time() < stoptime:
        try:
            # We receive a message as a Python dictionary
            message = client.recvMessage()
        pass

    # Creates a new connection to DeepGTAV using the specified ip and port
    client = Client(ip=args.host,
                    port=args.port,
                    datasetPath=args.dataset_path,
                    compressionLevel=9)
    # Dataset options
    dataset = Dataset(rate=60,
                      frame=[1920, 1080],
                      vehicles=True,
                      location=True)
    # Automatic driving scenario
    scenario = Scenario(
        weather='EXTRASUNNY',
        vehicle='packer',
        time=[9, 0],
        drivingMode=[786603, 20.0]
    )  #, location=[-661.9974975585938, -1932.245849609375, 27.170656204223633])
    client.sendMessage(Start(scenario=scenario,
                             dataset=dataset))  # Start request

    count = 0
    old_location = [0, 0, 0]

    # Main loop stops when dataset.size < N GB
    while os.path.getsize(dataset_path) < (100e+9):
        try:
            # Message recieved as a Python dictionary
            message = client.recvMessage()
            # Checks if car is stuck, resets position if it is
            if (count % 250) == 0:
#Boolean to choose if lidar
lidar_bool = true;

class Model:
    def run(self,frame):
        return [0.0, 0.0, 0.0] # throttle, brake, steering
        
if __name__ == '__main__':
    parser = argparse.ArgumentParser(description=None)
    parser.add_argument('-l', '--host', default='localhost', help='The IP where DeepGTAV is running')
    parser.add_argument('-p', '--port', default=8000, help='The port where DeepGTAV is running')
    args = parser.parse_args()

    client = Client(ip=args.host, port=args.port)
    
    scenario = Scenario(weather=scen_weather,vehicle=scen_vehicle,time=[12,0],drivingMode=[scen_drivingmode,1.0],location=[-619.2719, -179.77854, 0])

    
    client.sendMessage(Start(scenario=scenario))
    
    model = Model()

    stoptime = time.time() + 80*3600
    count = 0
    lidarcfg = "LiDAR GTA V Configuration File\r\nHorizontal_FOV_Min = 0.0\r\nHorizontal_FOV_Max = 360.0\r\nVertical_FOV_Min = -20.0\r\nVertical_FOV_Max = 10.0\r\nHorizontal_Step = 5\r\nVertical_Step = .25\r\nRange = 50\r\nFilename = LiDAR_PointCloud"
    while time.time() < stoptime:
        try:
            message = client.recvMessage()  
                
            image = frame2numpy(message['frame'], (320,160))
            #commands = model.run(image)
Exemple #9
0
 def __init_scenairo(self):
     self.__scenario = Scenario(drivingMode=self.__driving_mode, vehicle=self.__driving_vehicle,
                                time=self.__starting_time, weather=self.__starting_weather, location=self.__starting_location)
Exemple #10
0
                      frame=args.frame_resolution,
                      throttle=args.throttle,
                      brake=args.brake,
                      steering=args.steering,
                      vehicles=args.vehicles,
                      trafficSigns=args.trafficSigns,
                      peds=args.peds,
                      reward=args.reward,
                      speed=args.speed,
                      yawRate=args.yawRate,
                      location=args.if_location,
                      time=args.dataset_time,
                      roadinfo=args.roadinfo,
                      direction=args.des)
    scenario = Scenario(vehicle=args.vehicle,
                        weather=weather,
                        time=args.time,
                        location=args.location)
    client.sendMessage(Start(dataset=dataset, scenario=scenario))
    time.sleep(5)  # wait for the scene to be ready
    # Setup multi-threading for receiving messages
    queue = Queue(maxsize=1)
    manager = Manager()
    c = BufferClient(('localhost', 8766))
    capture_gta_to_queue_only_final(c, queue)

    while True:
        imgtime, img = queue.get()
        imgtime = int(time)
        speed, angle = model(Variable(torch.Tensor(img)))
        throttle, brake, steering = pid(speed, angle)
        client.sendMessage(
Exemple #11
0
def main():

    global client, scenario
    client = Client(ip='localhost', port=8000)  # Default interface
    scenario = Scenario(
        weather='EXTRASUNNY',
        vehicle='blista',
        time=[12, 0],
        drivingMode=-1,
        location=[-2583.6708984375, 3501.88232421875, 12.7711820602417])
    client.sendMessage(Start(scenario=scenario, dataset=dataset))
    print("load deepGTAV successfully! \nbegin")

    # load yolo v3
    classes = yolo_util.read_coco_names('./files/coco/coco.names')
    num_classes = len(classes)
    input_tensor, output_tensors = yolo_util.read_pb_return_tensors(
        tf.get_default_graph(), "./files/trained_models/yolov3.pb",
        ["Placeholder:0", "concat_9:0", "mul_6:0"])
    print("load yolo v3 successfully!")

    with tf.Session() as sess:
        model = load_model("files/trained_models/main_model.h5")
        print("load main_model successfully!")
        while True:
            fo = open(config_position, "r")  # 配置1
            txt = fo.read()
            fo.close()
            if txt == '0':
                set_gamepad(-1, -1, 0)
                time.sleep(0.7)
                print('=====================end=====================')
                exit(0)
            elif txt == '1':
                message = client.recvMessage()
                frame = frame2numpy(message['frame'], (CAP_IMG_W, CAP_IMG_H))
                image_obj = Image.fromarray(frame)

                speed = message['speed']

                boxes, scores = sess.run(output_tensors,
                                         feed_dict={
                                             input_tensor:
                                             np.expand_dims(
                                                 yolo_img_process(frame),
                                                 axis=0)
                                         })
                boxes, scores, labels = yolo_util.cpu_nms(boxes,
                                                          scores,
                                                          num_classes,
                                                          score_thresh=0.4,
                                                          iou_thresh=0.1)
                image, warning = yolo_util.draw_boxes(image_obj,
                                                      boxes,
                                                      scores,
                                                      labels,
                                                      classes,
                                                      (IMAGE_H, IMAGE_W),
                                                      show=False)

                control, throttle, breakk = drive(model=model,
                                                  image=frame,
                                                  speed=speed,
                                                  warning=warning)

                print(warning)

                set_gamepad(control, throttle, breakk)