How to use the airsim.client.CarControls 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 / AutoCarUnrealEnvironment.py View on Github external
def do_action(self, action):
        tic = time.time()
        # Returns the increment or decrement (AKA the DQN's Action choice)
        throttle_cmd, breaking_cmd, steering_cmd, _ = self.get_RC_action(act_num = action)
        
        #print("thr " + throttle_cmd + "Bra " + breaking_cmd + "str " + steering_cmd )
        self.brake = self.brake + breaking_cmd
        self.steering = self.steering + steering_cmd
        self.throttle = self.throttle + throttle_cmd
        #print("Desired Steering Commands (TBS): ", self.throttle, self.brake, self.steering)
        
        car_controls = client.CarControls()
        car_controls.throttle = self.throttle
        car_controls.steering = self.steering
        car_controls.brake = self.brake
        self.client.setCarControls(car_controls) # Send off to the simulator!
        time.sleep(self.action_duration)
        self.time_to_do_action = time.time() - tic
        print('Time to do action: ', self.time_to_do_action)
github nesl / UnrealAirSimDRL / Deep_Reinforcement_Learning / Library / ClientAirSimEnvironments / ManualCarUnrealEnvironment.py View on Github external
def do_action(self, action):
        tic = time.time()
        #print("thr " + throttle_cmd + "Bra " + breaking_cmd + "str " + steering_cmd )
        self.brake = action['brake']
        self.steering = action['steering']
        self.throttle = action['throttle']
        #print("Desired Steering Commands (TBS): ", self.throttle, self.brake, self.steering)
        
        car_controls = client.CarControls()
        car_controls.throttle = self.throttle
        car_controls.steering = self.steering
        car_controls.brake = self.brake
        self.client.setCarControls(car_controls) # Send off to the simulator!
        time.sleep(self.action_duration)
        self.time_to_do_action = time.time() - tic
        print('Time to do action: ', self.time_to_do_action)
github nesl / UnrealAirSimDRL / Deep_Reinforcement_Learning / Library / ClientAirSimEnvironments / ManualQuadcopterUnrealEnvironment.py View on Github external
def do_action(self, action):
        tic = time.time()
        #print("thr " + throttle_cmd + "Bra " + breaking_cmd + "str " + steering_cmd )
        self.brake = action['brake']
        self.steering = action['steering']
        self.throttle = action['throttle']
        #print("Desired Steering Commands (TBS): ", self.throttle, self.brake, self.steering)
        
        car_controls = client.CarControls()
        car_controls.throttle = self.throttle
        car_controls.steering = self.steering
        car_controls.brake = self.brake
        self.client.setCarControls(car_controls) # Send off to the simulator!
        time.sleep(self.action_duration)
        self.time_to_do_action = time.time() - tic
        print('Time to do action: ', self.time_to_do_action)
github nesl / UnrealAirSimDRL / Deep_Reinforcement_Learning / Library / ClientAirSimEnvironments / AutoCarsUnrealEnvironment.py View on Github external
def do_actions(self, actions):
        
        # Returns the increment or decrement (AKA the DQN's Action choice)
        for vn, act in zip(self.vehicle_names, actions):
            throttle_cmd, breaking_cmd, steering_cmd, _ = self.get_RC_action(act_num = act)
            
            #print("thr " + throttle_cmd + "Bra " + breaking_cmd + "str " + steering_cmd )
            self.set_brake(vn, self.get_brake(vn) + breaking_cmd)
            self.set_steering(vn, self.get_steering(vn) + steering_cmd)
            self.set_throttle(vn, self.get_throttle(vn) + throttle_cmd)
            #print("Desired Steering Commands (TBS): ", self.throttle, self.brake, self.steering)
            
            car_controls = client.CarControls()
            car_controls.throttle = self.get_throttle(vn)
            car_controls.steering = self.get_steering(vn)
            car_controls.brake = self.get_brake(vn)
            self.client.setCarControls(car_controls, vehicle_name = vn) # Send off to the simulator!
        time.sleep(.08)
    # The reward function is broken into an intervention signal and non intervention signal, as the actions have different