Skip to content

Instantly share code, notes, and snippets.

@ajeetraina
Created October 1, 2021 08:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ajeetraina/98ba6e541a6eb91a71905878de788955 to your computer and use it in GitHub Desktop.
Save ajeetraina/98ba6e541a6eb91a71905878de788955 to your computer and use it in GitHub Desktop.
Import AirSim
import airsimimport argparsefrom flyDroneService import FlyDroneServiceimport time
if __name__ == '__main__':
    parser = argparse.ArgumentParser()    parser.add_argument('-u', '--level', help='Game Level', type=int, default=1)    args = parser.parse_args()        # connect to the AirSim simulator    client = airsim.MultirotorClient()    FlyDroneService.initializeAirSimClient(client)
    gameLevel = args.level    print(gameLevel)    # set the coordinates to set up the path for drone to travel    if gameLevel == 3:        print('Level 3')        client.simEnableWeather(True)        FlyDroneService.setFlyingCoordsForDroneAtThirdLevel(client)    elif gameLevel == 2:        print('Level 2')        client.simEnableWeather(True)        FlyDroneService.setFlyingCoordsForDroneAtSecondLevel(client)    else:        print('Level 1')        client.simEnableWeather(True)        client.simSetWeatherParameter(airsim.WeatherParameter.Rain, 1)        FlyDroneService.setFlyingCoordsForDroneAtFirstLevel(client)            #stop and return the simulator to initial state    FlyDroneService.resetAirSimClient(client)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment