Created
June 22, 2020 19:48
-
-
Save ibraEssam/52265b2c2aec85d6a20a87b2b6aa8c46 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class AirSim: | |
| def download_run_airsim(self): | |
| # Environment variables to run AirSim headless | |
| os.environ["SDL_VIDEODRIVER_VALUE"] = "offscreen" | |
| os.environ['SDL_HINT_CUDA_DEVICE'] = "0" | |
| # AirSim Binaries List | |
| list_env = ["Blocks", "Africa", "Building_99", | |
| "Zhangjiajie", "Neighborhood", "SoccerField", "LandscapeMountains", "TrapCam"] | |
| # Let's get the selected environment from our block properities | |
| self.enviroment = list_env[self.get_property("env")] | |
| # get the settings file path from block properities | |
| self.settings_path = self.get_property("settings") | |
| # Download and run the environment | |
| if self.enviroment == "TrapCam": | |
| download_path = "https://github.com/microsoft/AirSim/releases/download/v1.3.1-linux/TrapCam.zip.001" | |
| self.alert("Downloading the Environment.....", "INFO") | |
| subprocess.call( | |
| "cd /home/airsim && wget {}".format(download_path), shell=True) | |
| download_path = "https://github.com/microsoft/AirSim/releases/download/v1.3.1-linux/TrapCam.zip.002" | |
| self.alert("Downloading the Environment.....", "INFO") | |
| subprocess.call( | |
| "cd /home/airsim && wget {}".format(download_path), shell=True) | |
| subprocess.call( | |
| "cd /home/airsim && cat TrapCam.zip.00* > TrapCam.zip && unzip TrapCam.zip", shell=True) | |
| else: | |
| download_path = "https://github.com/microsoft/AirSim/releases/download/v1.3.1-linux/{}.zip".format( | |
| self.enviroment) | |
| self.alert("Downloading the Environment.....", "INFO") | |
| subprocess.call( | |
| "cd /home/airsim && wget {}".format(download_path), shell=True) | |
| self.alert("Unzip the Downloaded File.....", "INFO") | |
| subprocess.call( | |
| "runuser -l airsim -c'cd /home/airsim/ && unzip {}.zip'".format(self.enviroment), shell=True) | |
| self.alert("Copying settings..", "INFO") | |
| subprocess.call( | |
| "runuser -l airsim -c 'mkdir -p /home/airsim/Documents/AirSim/ && cp {} ~/Documents/AirSim/settings.json'".format(self.settings_path), shell=True) | |
| self.alert("Run AirSim Env......", "INFO") | |
| if self.enviroment == "Africa": | |
| self.pro = subprocess.Popen( | |
| "runuser -l airsim -c 'sh /home/airsim/Africa_001.sh -opengl'", shell=True) | |
| elif self.enviroment == "Zhangjiajie": | |
| self.pro = subprocess.Popen( | |
| "runuser -l airsim -c 'sh /home/airsim/Zhangjiajie.sh -opengl'", shell=True) | |
| elif self.enviroment == "Neighborhood": | |
| self.pro = subprocess.Popen( | |
| "runuser -l airsim -c 'sh /home/airsim/AirSimNH.sh -opengl'", shell=True) | |
| elif self.enviroment == "TrapCam": | |
| self.pro = subprocess.Popen( | |
| "runuser -l airsim -c 'sh /home/airsim/TrapCam.sh -opengl'", shell=True) | |
| else: | |
| self.pro = subprocess.Popen( | |
| "runuser -l airsim -c 'sh /home/airsim/{}/{}.sh -opengl'".format(self.enviroment, self.enviroment), shell=True) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment