How to use the airsim.client.CarClient 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 / ManualQuadcopterUnrealEnvironment.py View on Github external
# Throttle up, throttle down, increase brake, decrease break, left_steer, right_steer, No action
        self.count_car_actions = 7 
        
        # Initialize the current inertial state to zero
        self.current_inertial_state = np.array(np.zeros(self.count_inertial_state_variables))

        # Initialize the IMAGE variables -- We Take in Front Center, Right, Left
        self.images_rgb = None
        self.images_rgba = None
        self.image_mask_rgb = np.array([ [0+3*i,1+3*i,2+3*i] for m, i in zip(image_mask_FC_FR_FL, range(3)) if m]).reshape(-1)
        self.image_mask_rgba = np.array([ [0+4*i,1+4*i,2+4*i] for m, i in zip(image_mask_FC_FR_FL, range(3)) if m]).reshape(-1)
        self.image_mask_FC_FR_FL = image_mask_FC_FR_FL
        
        # 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!')
        
        print("Setting Camera Views")
        orien = Vector3r(0, 0, 0)
        self.client.simSetCameraOrientation("0", orien) #radians
        orien = Vector3r(0, .12, -np.pi/9)
        self.client.simSetCameraOrientation("1", orien)
        orien = Vector3r(0, .12, np.pi/9)
        self.client.simSetCameraOrientation("2", orien)
        # Reset Collion Flags
        print("Setting Camera Views DONE!")

        # Set up GUI Video Feeder
        self.gui_data = {'obs': None, 'state': None, 'meta': None}
github nesl / UnrealAirSimDRL / Deep_Reinforcement_Learning / Library / ClientAirSimEnvironments / AutoCarsUnrealEnvironment.py View on Github external
# Initialize the current inertial state to zero
        self.current_inertial_states = dict.fromkeys(self.vehicle_names, np.array(np.zeros(self.count_inertial_state_variables)))

        # Initialize the IMAGE variables -- We Take in Front Center, Right, Left
        self.images_rgb = dict.fromkeys(self.vehicle_names, 0)
        self.images_rgba = dict.fromkeys(self.vehicle_names, 0)
        self.image_mask_rgb = np.array([ [0+3*i,1+3*i,2+3*i] for m, i in zip(image_mask_FC_FR_FL, range(3)) if m]).reshape(-1)
        self.image_mask_rgba = np.array([ [0+4*i,1+4*i,2+4*i] for m, i in zip(image_mask_FC_FR_FL, range(3)) if m]).reshape(-1)
        self.image_mask_FC_FR_FL = image_mask_FC_FR_FL
        
        self.initial_position = dict.fromkeys(self.vehicle_names, 0)
        self.initial_velocity = dict.fromkeys(self.vehicle_names, 0)
        
        # Connect to the AirSim simulator and begin:
        print('Initializing Car Client')
        self.client = client.CarClient()
        self.client.confirmConnection()
        for vn in self.vehicle_names:
            self.client.enableApiControl(True, vn)
            orien = Vector3r(0, 0, 0)
            self.client.simSetCameraOrientation(0, orien.to_Quaternionr(), vehicle_name = vn) #radians
            orien = Vector3r(0, .12, -np.pi/9)
            self.client.simSetCameraOrientation(1, orien, vehicle_name = vn)
            orien = Vector3r(0, .12, np.pi/9)
            self.client.simSetCameraOrientation(2, orien, vehicle_name = vn)
        # Reset Collion Flags
        print('Initialization Complete!')
        # Timing Operations Initialize
        self.dt = 0
        self.tic = 0
        self.toc = 0
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!')
github nesl / UnrealAirSimDRL / Deep_Reinforcement_Learning / Library / ClientAirSimEnvironments / AutoCarUnrealEnvironment.py View on Github external
# Throttle up, throttle down, increase brake, decrease break, left_steer, right_steer, No action
        self.count_car_actions = 7 
        
        # Initialize the current inertial state to zero
        self.current_inertial_state = np.array(np.zeros(self.count_inertial_state_variables))

        # Initialize the IMAGE variables -- We Take in Front Center, Right, Left
        self.images_rgb = None
        self.images_rgba = None
        self.image_mask_rgb = np.array([ [0+3*i,1+3*i,2+3*i] for m, i in zip(image_mask_FC_FR_FL, range(3)) if m]).reshape(-1)
        self.image_mask_rgba = np.array([ [0+4*i,1+4*i,2+4*i] for m, i in zip(image_mask_FC_FR_FL, range(3)) if m]).reshape(-1)
        self.image_mask_FC_FR_FL = image_mask_FC_FR_FL
        
        # 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!')
        
        print("Setting Camera Views")
        orien = Vector3r(0, 0, 0)
        self.client.simSetCameraOrientation(0, orien) #radians
        orien = Vector3r(0, .12, -np.pi/9)
        self.client.simSetCameraOrientation(1, orien)
        orien = Vector3r(0, .12, np.pi/9)
        self.client.simSetCameraOrientation(2, orien)
        # Reset Collion Flags
        print("Setting Camera Views DONE!")

        # Set up GUI Video Feeder
        self.gui_data = {'obs': None, 'state': None, 'meta': None}
github nesl / UnrealAirSimDRL / Deep_Reinforcement_Learning / Library / ClientAirSimEnvironments / ManualCarUnrealEnvironment.py View on Github external
# Throttle up, throttle down, increase brake, decrease break, left_steer, right_steer, No action
        self.count_car_actions = 7 
        
        # Initialize the current inertial state to zero
        self.current_inertial_state = np.array(np.zeros(self.count_inertial_state_variables))

        # Initialize the IMAGE variables -- We Take in Front Center, Right, Left
        self.images_rgb = None
        self.images_rgba = None
        self.image_mask_rgb = np.array([ [0+3*i,1+3*i,2+3*i] for m, i in zip(image_mask_FC_FR_FL, range(3)) if m]).reshape(-1)
        self.image_mask_rgba = np.array([ [0+4*i,1+4*i,2+4*i] for m, i in zip(image_mask_FC_FR_FL, range(3)) if m]).reshape(-1)
        self.image_mask_FC_FR_FL = image_mask_FC_FR_FL
        
        # 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!')
        
        print("Setting Camera Views")
        orien = Vector3r(0, 0, 0)
        self.client.simSetCameraOrientation("0", orien) #radians
        orien = Vector3r(0, .12, -np.pi/9)
        self.client.simSetCameraOrientation("1", orien)
        orien = Vector3r(0, .12, np.pi/9)
        self.client.simSetCameraOrientation("2", orien)
        # Reset Collion Flags
        print("Setting Camera Views DONE!")

        # Set up GUI Video Feeder
        self.gui_data = {'obs': None, 'state': None, 'meta': None}