How to use the airsim.client function in airsim

To help you get started, we’ve selected a few airsim examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github nesl / UnrealAirSimDRL / Deep_Reinforcement_Learning / Library / ClientAirSimEnvironments / ManualCarUnrealEnvironment.py View on Github external
def get_new_images(self):
        # Construct the Images State Vector
        # Order is Front Center, Front Right, Front Left
        tic = time.time()
        self.client.simPause(True)
        if (self.image_mask_FC_FR_FL[0] and  self.image_mask_FC_FR_FL[1] and  self.image_mask_FC_FR_FL[2]): 
            images = self.client.simGetImages([client.ImageRequest("0", client.ImageType.Scene, False, False), # Front Center
            client.ImageRequest("1", client.ImageType.Scene, False, False), # Front Right
            client.ImageRequest("2", client.ImageType.Scene, False, False)]) # Front Left
            img1d_FC = np.fromstring(images[0].image_data_uint8, dtype=np.uint8) 
            img_rgba_FC = np.array(img1d_FC.reshape(images[0].height, images[0].width, 4), dtype = np.uint8)
            img_rgb_FC = img_rgba_FC[:,:,0:3]
            
            img1d_FR = np.fromstring(images[1].image_data_uint8, dtype=np.uint8) 
            img_rgba_FR = np.array(img1d_FR.reshape(images[1].height, images[1].width, 4), dtype = np.uint8)
            img_rgb_FR = img_rgba_FR[:,:,0:3]
            
            img1d_FL = np.fromstring(images[2].image_data_uint8, dtype=np.uint8) 
            img_rgba_FL = np.array(img1d_FL.reshape(images[2].height, images[2].width, 4), dtype = np.uint8)
            img_rgb_FL = img_rgba_FL[:,:,0:3]
            
            # Can either use the RGBA images or the RGB Images
            self.images_rgba = np.dstack((img_rgba_FC,img_rgba_FR,img_rgba_FL))
            self.images_rgb = np.dstack((img_rgb_FC,img_rgb_FR,img_rgb_FL))
            self.time_to_grab_images = time.time() - tic
github nesl / UnrealAirSimDRL / Deep_Reinforcement_Learning / Library / ClientAirSimEnvironments / ManualCarUnrealEnvironment.py View on Github external
def initialize_vehicle_type(self):
        if self.isDrone is False:
            # Connect to the AirSim simulator and begin:
            print('Initializing Car Client')
            self.client = client.CarClient()
            self.client.confirmConnection()
            self.client.enableApiControl(True)
            print('Initialization DONE!')
        else:
            print('Initializing Drone Client')
            self.client = client.MultirotorClient()
            self.client.confirmConnection()
            self.client.enableApiControl(True)
            print('Initialization DONE!')