From aa5e0707f97aab71184e9c775e9d99d03100e1a8 Mon Sep 17 00:00:00 2001 From: Rishabh Madan Date: Sun, 10 Feb 2019 14:06:09 +0530 Subject: [PATCH 1/2] Added script for downloading CarlaGear server --- tools/download_carla_gear.py | 61 ++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 tools/download_carla_gear.py diff --git a/tools/download_carla_gear.py b/tools/download_carla_gear.py new file mode 100644 index 0000000..12405a1 --- /dev/null +++ b/tools/download_carla_gear.py @@ -0,0 +1,61 @@ +import requests +import os +import sys + +from zipfile import ZipFile + + +def download_file_from_google_drive(id, destination): + URL = "https://docs.google.com/uc?export=download" + session = requests.Session() + response = session.get(URL, params={'id': id}, stream=True) + token = get_confirm_token(response) + + if token: + params = {'id': id, 'confirm': token} + response = session.get(URL, params=params, stream=True) + + save_response_content(response, destination) + + +def get_confirm_token(response): + for key, value in response.cookies.items(): + if key.startswith('download_warning'): + return value + + return None + + +def save_response_content(response, destination): + CHUNK_SIZE = 32768 + total_downloaded = 0 + with open(destination, "wb") as f: + for chunk in response.iter_content(CHUNK_SIZE): + if chunk: # filter out keep-alive new chunks + total_downloaded += CHUNK_SIZE + sys.stdout.write("Downloaded " + str(total_downloaded)) + sys.stdout.flush() + sys.stdout.write("\r") + f.write(chunk) + + +if __name__ == "__main__": + # Download the datasets + file_id = '1X52PXqT0phEi5WEWAISAQYZs-Ivx4VoE' + destination_pack = 'CarlaGear.zip' + + print("Downloading Carla Server (1.6GB total)") + download_file_from_google_drive(file_id, destination_pack) + destination_final = os.path.join("./CarlaServer/",) + if not os.path.exists(destination_final): + os.makedirs(destination_final) + + print("Unpacking the dataset") + + with ZipFile(destination_pack, 'r') as zip: + # extracting all the files + print('Extracting all the files now...') + zip.extractall(destination_final) + print('Done!') + + os.remove("CarlaGear.zip") \ No newline at end of file From 10fc65e33e06892268bab2b0a0178b27a76ed2b9 Mon Sep 17 00:00:00 2001 From: Rishabh Madan Date: Sun, 10 Feb 2019 14:09:12 +0530 Subject: [PATCH 2/2] Update README.md --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 328c013..3afe51d 100644 --- a/README.md +++ b/README.md @@ -54,6 +54,9 @@ the ego-vehicle has a single gear. This problem is discussed in [this issue](https://github.com/carla-simulator/carla/issues/269). The server can be dowloaded with [this link](https://drive.google.com/open?id=1X52PXqT0phEi5WEWAISAQYZs-Ivx4VoE). +Alternatively, you can download it by running: + + python3 tools/download_carla_gear.py It is possible to collect data on a regular CARLA version, however the controller will be less smooth.