def __init__(self, client, max_episode_steps): #self.client = xp.XPlaneConnect(clientAddr,xpHost,xpPort,clientPort,timeout ,max_episode_steps) self.client = client #print(parameters) envSpace = envSpaces.xplane_space() self.ControlParameters = parameters.getParameters() self.action_space = envSpace._action_space() self.observation_space = envSpace._observation_space() self.episode_steps = self.ControlParameters.episodeStep self.max_episode_steps = max_episode_steps
def __init__(self, xpHost, xpPort, timeout): XplaneEnv.CLIENT = None envSpace = envSpaces.xplane_space() self.ControlParameters = parameters.getParameters() self.action_space = envSpace._action_space() self.observation_space = envSpace._observation_space() self.ControlParameters.episodeStep = 0 self.max_episode_steps = 1000 self.statelength = 10 self.actions = [0, 0, 0, 0, 0] self.test = False try: XplaneEnv.CLIENT = initial.connect(xpHost='127.0.0.1', xpPort=49009, timeout=1000) except: print("connection error. Check your paramters") print('I am client', XplaneEnv.CLIENT)
def __init__(self,clientAddr, xpHost, xpPort , clientPort, timeout=3000 ,max_episode_steps=303,test=False): #CLIENT = client XplaneEnv.CLIENT = None #print(parameters) envSpace = envSpaces.xplane_space() self.ControlParameters = parameters.getParameters() self.action_space = envSpace._action_space() self.observation_space = envSpace._observation_space() #self.episode_steps = 0 self.ControlParameters.episodeStep =0 self.max_episode_steps = max_episode_steps self.statelength = 10 self.actions = [0,0,0,0] self.test=test try: XplaneEnv.CLIENT = initial.connect(clientAddr,xpHost,xpPort,clientPort,timeout ,max_episode_steps) except: print("connection error. Check your paramters") print('I am client', XplaneEnv.CLIENT )
def __init__(self, clientAddr, xpHost, xpPort, clientPort, timeout=3000, max_episode_steps=5000, test=False): XplaneENV.CLIENT = None EnvSpace = envSpaces.xplane_space() self.ControlParameters = parameters.getParameters() # self.action_space = spaces.Box(np.array([-1, -1, -1, -1 / 4]), np.array([1, 1, 1, 1])) self.action_space = spaces.Box(np.array([-1, -1, -1, -1, 0, 0, -0.5]), np.array([1, 1, 1, 1, 1, 1, 1.5])) # self.action_space = spaces.Box(np.array([0, 0, 0, 0, 0, 0, -0.5]), np.array([1, 1, 1, 1, 1, 1, 1.5])) # self.action_space = spaces.Dict({"Latitudinal_Stick": spaces.Box(low=-1, high=1, shape=()), # "Longitudinal_Stick": spaces.Box(low=-1, high=1, shape=()), # "Rudder_Pedals": spaces.Box(low=-1, high=1, shape=()), # "Throttle": spaces.Box(low=-1, high=1, shape=()), # "Gear": spaces.Discrete(2), # "Flaps": spaces.Box(low=0, high=1, shape=()), # "Speedbrakes": spaces.Box(low=-0.5, high=1.5, shape=())}) # self.observation_space = spaces.Box( # np.array([-360, -360, 0, -290, -100, -360, -360, -1000, -1300, -1000, -1000]), # np.array([360, 360, 8500, 290, 100, 360, 360, 1000, 1300, 1000, 1000])) self.observation_space = spaces.Dict({ "Latitude": spaces.Box(low=0, high=360, shape=()), "Longitude": spaces.Box(low=0, high=360, shape=()), "Altitude": spaces.Box(low=0, high=8500, shape=()), "Pitch": spaces.Box(low=-290, high=290, shape=()), "Roll": spaces.Box(low=-100, high=100, shape=()), "Heading": spaces.Box(low=0, high=360, shape=()), "gear": spaces.Discrete(2), "speed": spaces.Box(low=-2205, high=2205, shape=()), "waypoint_lat": spaces.Box(low=0, high=360, shape=()), "waypoint_lon": spaces.Box(low=0, high=360, shape=()), "waypoint_alt": spaces.Box(low=0, high=8500, shape=()) }) # "yoke_pitch_ratio": spaces.Box(low=-2.5, high=2.5, shape=()), # "yoke_roll_ratio": spaces.Box(low=-300, high=300, shape=()), # "yoke_heading_ratio": spaces.Box(low=-180, high=180, shape=()), # "alpha": spaces.Box(low=-100, high=100, shape=()), # "wing_sweep_ratio": spaces.Box(low=-100, high=100, shape=()), # "flap_ratio": spaces.Box(low=-100, high=100, shape=())) # "speed": spaces.Box(low=-2205, high=2205, shape=())}) self.ControlParameters.episodeStep = 0 self.max_episode_steps = max_episode_steps self.stateLength = 10 self.actions = [0, 0, 0, 0] self.test = test self.waypoints = [] self.last_waypoints = [] self.waypoint_goal = 1 try: XplaneENV.CLIENT = Initial.connect(clientAddr, xpHost, xpPort, clientPort, timeout, max_episode_steps) except: print("connection error, check if xplane is running") raise Exception("connection error, check if xplane is running") print("I am client: ", XplaneENV.CLIENT) # Increase simulation speed XplaneENV.CLIENT.sendDREF('sim/time/sim_speed', 500) # Get starting position self.start_position = XplaneENV.CLIENT.getPOSI() self.ControlParameters.stateAircraftPosition = list( XplaneENV.CLIENT.getPOSI()) self.previous_position = self.start_position