def __init__(self): self.simage = np.zeros((20, 100), dtype=np.uint8) self.svelocity = np.zeros((3, ), dtype=np.float32) self.sdistance = np.zeros((3, ), dtype=np.float32) self.sgeofence = np.zeros((6, ), dtype=np.float32) self.stotalvelocity = np.zeros((12, ), dtype=np.float32) self.stotaldistance = np.zeros((12, ), dtype=np.float32) self.stotalgeofence = np.zeros((24, ), dtype=np.float32) self.action_space = spaces.Discrete(6) self.goal = [137.5, -48.7] self.distance = np.sqrt( np.power((self.goal[0]), 2) + np.power((self.goal[1]), 2)) self.episodeN = 0 self.stepN = 0 ''' Additional log info self.allLogs = { 'reward':[0] } self.allLogs['distance'] = [self.distance] self.allLogs['track'] = [-2] self.allLogs['action'] = [1] self.allLogs['svelocity'] = self.svelocity self.allLogs['sdistance'] = self.sdistance self.allLogs['sgeofence'] = self.sgeofence ''' self._seed() global airgym airgym = myAirSimClient()
def __init__(self): #self.cum_reward = 0.0 #self.discount = 0.8 #check others self.simage = np.zeros((20, 100), dtype=np.uint8) self.svelocity = np.zeros((2, ), dtype=np.float32) self.sdistance = np.zeros((3, ), dtype=np.float32) self.sgeofence = np.zeros((4, ), dtype=np.float32) self.sAE = np.zeros((2, ), dtype=np.float32) self.action_space = spaces.Discrete(5) self.goal = [112, 10] self.episodeN = 0 self.stepN = 0 self.allLogs = {'reward': [0]} self.allLogs['track'] = [-2] self.allLogs['action'] = [1] self.seed() global airgym airgym = myAirSimClient()
def __init__(self): global airgym airgym = myAirSimClient() self.drone1_vehicle_name = "Drone1" self.target1_vehicle_name = "Target1" self.target_thershold=2.5 self.simage = np.zeros((90, 256,1), dtype=np.uint8) self.rgbimage = np.zeros((90, 256,3), dtype=np.uint8) self.svelocity = np.zeros((3,), dtype=np.float32) self.sdistance = np.zeros((3,), dtype=np.float32) self.sgeofence = np.zeros((6,), dtype=np.float32) self.stotalvelocity = np.zeros((12,), dtype=np.float32) self.stotaldistance = np.zeros((12,), dtype=np.float32) self.stotalgeofence = np.zeros((24,), dtype=np.float32) self.action_space = spaces.Discrete(6) #self.drone = trackgym.simGetGroundTruthKinematics(self.drone1_vehicle_name).position self.init_goal = airgym.simGetGroundTruthKinematics(self.target1_vehicle_name).position #[137.5, -48.7,-4] self.goal={'x_val':self.init_goal.x_val+offset.x_val, 'y_val':self.init_goal.y_val+offset.y_val,'z_val':self.init_goal.z_val} self.goal = dotdict(self.goal) self.distance = np.sqrt(np.power((self.goal.x_val),2) + np.power((self.goal.y_val),2) + np.power((self.goal.z_val),2)) self.episodeN = 0 self.stepN = 0 #Additional log info self.allLogs = { 'reward':[0] } self.allLogs['distance'] = [self.distance] self.allLogs['track'] = [-2] self.allLogs['action'] = [1] self.allLogs['svelocity'] = self.svelocity self.allLogs['sdistance'] = self.sdistance self.allLogs['sgeofence'] = self.sgeofence self.seed()
def __init__(self): # left depth, center depth, right depth, yaw self.observation_space = spaces.Box(low=0, high=255, shape=(30, 100)) self.state = np.zeros((30, 100), dtype=np.uint8) self.action_space = spaces.Discrete(3) self.goal = [221.0, -9.0] # global xy coordinates self.episodeN = 0 self.stepN = 0 self.allLogs = {'reward': [0]} self.allLogs['distance'] = [221] self.allLogs['track'] = [-2] self.allLogs['action'] = [1] self._seed() global airgym airgym = myAirSimClient()
import logging import numpy as np import random import gym from gym import spaces from gym.utils import seeding from gym.spaces import Tuple, Box, Discrete, MultiDiscrete, Dict from gym.spaces.box import Box from gym_airsim.envs.myAirSimClient import * from airsim.client import * logger = logging.getLogger(__name__) global airgym airgym = myAirSimClient() class AirSimEnv(gym.Env): airgym = None def __init__(self): # left depth, center depth, right depth, yaw self.observation_space = spaces.Box(low=0, high=255, shape=(1,)) self.state = np.zeros((1,), dtype=np.uint8) self.action_space = spaces.Discrete(3) self.goal = [221.0, -9.0] # global xy coordinates self.episodeN = 0 self.stepN = 0
import gym from gym import spaces from gym.utils import seeding from gym_airsim.envs.myAirSimClient import * from airsim.client import * import random logger = logging.getLogger(__name__) airSimClient = myAirSimClient() class AirSimEnv(gym.Env): def __init__(self): # x_pos, y_pos, direction to goal, distance to goal, distance_sensor.front self.observation_space = spaces.Box(low=-500, high=500, shape=(5, )) self.state = np.zeros((5, ), dtype=np.uint8) self.action_space = spaces.Discrete(3) # self.obstacle_list = [[0.0, -7.0], [0.0, 5.0], [10.0, -7.0], [10.0, -1.0], [10.0, 5.0], [5, -3.0], [5.0, 3.0]] # index = np.random.randint(0, len(self.goal_list) - 1) # self.goal = self.goal_list[index] # global xy coordinates self.x_goal = random.uniform(-2, 16) self.y_goal = random.uniform(-10, 8) self.goal = [self.x_goal, self.y_goal] self.episodeN = 0 self.stepN = 0 self.dis = np.sqrt( np.power((self.goal[0] - airSimClient.home_pos.x_val), 2) + np.power((self.goal[1] - airSimClient.home_pos.y_val), 2)) self.allLogs = { 'reward': [0],