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]
Esempio n. 2
0
    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
Esempio n. 4
0
    def __init__(self, mass=1300, wheel_radius=0.04, dt=0.05, collect={"option":0, "path": None}):
        self.mass=1300 #Kg
        self.r=0.04    # 16 inch=40 cm 
        self.dt=0.05   # frequency = 20 Hz 
        self.g= 9.8    # graviataional acceleration (in m/s^2)
        self.j=1       # kg-m^2 (Moment of Intertia of tire)

        self.mu=0.0         # Effective frictional coefficient
        self.bs=0.8         # Set braking value at which it switch fron static to kinetic
        self.distance=0.0  
        self.velocity=0.0 

        self.episode = 0
        self.flag=0
        self.kickspd=0.0
        self.crossing_velocity=0.0
        self.default_friction=0.0
        self.friction_of_patch=0.0
        self.location_of_patch=0.0
        self.size_of_patch=0.0 
        self.collect = collect
        self.reward_total=0.0
        self.rewards = reward_calc(a=1.0,d=1.0,base=1.9)
        self.counter=0