def reset(self, initial_distance, initial_speed): if self.gui and self.display: self.display.stop() # Clean all vehicles before reset the environment for i, _ in enumerate(self.actor): if self.actor[i] is not None: self.actor[i].destroy() self.actor[i] = None self.actor = [] self.spawn_vehicles() self.dist_calc = DistanceCalculation(self.ego_vehicle, self.leading_vehicle, self.perception) self.pid_controller = PID(P=3.0, I=0.0003, D=0.0) if self.gui: self.display = pygameViewer() if self.collect["option"] != 0: self.collect_data = collectData(os.path.join(self.collect["path"], "episode_" + str(self.episode)), self.perception) self.step_count = 0 self.weather = DynamicPrecipitation(initial_precipitation=round(np.random.uniform(0.0,20.0), 2)) self.world.set_weather(self.weather.get_weather_parameters()) S0 = self.reset_episode(initial_distance, initial_speed) self.episode_count += 1 return S0
def reset(self, initial_distance, initial_speed, friction): self.kickspd = initial_speed self.friction_of_patch = friction self.mu = 0.0 self.rewards = reward_calc(a=1.0, d=1.0, base=1.9) self.distance = initial_distance if self.collect["option"] != 0 and self.flag != 1: self.flag = 1 self.episode = 0 self.collect_data = collectData(self.collect["path"]) self.step_count = 0 self.velocity = initial_speed * 4 / 9 # convert velocity is m/s vehicle_stop = self.velocity <= 0.0 return [self.distance, self.velocity, self.mu]
def reset(self, leadcar_loc, initial_speed, friction): self.kickspd_e1 = initial_speed self.friction_of_patch = friction self.mu = 0.0 self.rewards = reward_calc(a=1.0, d=1.0, base=1.9) self.distance = self.geolocation = leadcar_loc #distance means => obstacle distance if self.collect["option"] != 0 and self.flag != 1: self.flag = 1 self.episode = 0 self.collect_data = collectData(self.collect["path"]) self.step_count = 0 self.velocity = initial_speed * 4 / 9 # convert velocity is m/s vehicle_stop = self.velocity <= 0.0 self.episode += 1 self.flagdone1 = 1 return [self.distance, self.velocity, self.mu]
def reset(self, initial_distance, initial_speed, patch_location, friction_value, current_actor): #def reset(self, initial_distance, initial_speed): self.kickspd = initial_speed if self.gui and self.display: self.display.stop() # Clean all vehicles before reset the environment for i, _ in enumerate(self.actor): if self.actor[i] is not None: self.actor[i].destroy() self.actor[i] = None self.actor = [] self.spawn_vehicles(initial_speed) self.spawn_friction(patch_location, friction_value) self.dist_calc = DistanceCalculation(self.ego_vehicle, self.leading_vehicle, self.perception) self.rewards = reward_calc(a=1.0, d=1.0, base=1.9) self.pid_controller = PID(P=1, I=0.0003, D=0.0) if self.gui: self.display = pygameViewer() if self.collect["option"] != 0 and self.flag != current_actor: self.episode = 0 self.flag = current_actor self.collect_data = collectData(self.collect["path"], self.perception, current_actor) self.step_count = 0 self.weather = DynamicPrecipitation( initial_precipitation=round(np.random.uniform(0.0, 20.0), 2)) self.world.set_weather(self.weather.get_weather_parameters()) S0 = self.reset_episode(initial_distance, initial_speed) return S0
def reset(self, initial_distance, initial_speed,friction,friction_patch,size_patch, location_patch): self.kickspd=initial_speed self.default_friction=friction self.friction_of_patch=friction_patch self.size_of_patch=size_patch self.location_of_patch=location_patch self.mu=0.0 self.distance=initial_distance self.reward_total=0.0 #print('in reset') if self.collect["option"] != 0 and self.flag!=1 : #print ('in flag loop') self.flag=1 self.episode=0 self.collect_data = collectData(self.collect["path"]) self.step_count = 0 self.velocity= initial_speed *4/9 # convert velocity is m/s vehicle_stop=self.velocity<=0.0 return [self.distance, self.velocity ,self.mu]