def __init__(self, obs_noise=0., x_actions=[0.,0.5,3.], y_actions=[0,1], driver_sigma = 0., control_cost=0.01, collision_cost=2., survive_reward=0.01, goal_reward=2., road=Road([RoadSegment([(-100.,0.),(100.,0.),(100.,8.),(-100.,8.)])]), left_bound = -30., right_bound = 30., gap_min = 8., gap_max = 12., max_veh_num = 12, num_updates=1, dt=0.1, **kwargs): self.obs_noise = obs_noise self.x_actions = x_actions self.y_actions = y_actions # we use target value instead of target change so system is Markovian self.rl_actions = list(itertools.product(x_actions,y_actions)) self.num_updates = num_updates self.control_cost = control_cost self.collision_cost = collision_cost self.survive_reward = survive_reward self.goal_reward = goal_reward self.left_bound = left_bound self.right_bound = right_bound self.gap_min = gap_min self.gap_max = gap_max self.max_veh_num = max_veh_num self.label_dim = 2 self.label_num = self.max_veh_num self._collision = False self._goal = False self._intentions = [] self._lower_lane_next_idx = 1 self._upper_lane_next_idx = int(self.max_veh_num/2.)+1 self.car_length = 5.0 self.car_width = 2.0 self.car_max_accel = 5.0 self.car_max_speed = 5.0 self.car_max_rotation = 0. self.car_expose_level = 4 self.driver_sigma = driver_sigma self.min_front_x = 6. self.min_back_x = 6. super(HighWay, self).__init__( road=road, cars=[], drivers=[], dt=dt, **kwargs,)
def __init__(self, yld=0.5, vs_actions=[0.,0.5,3.], t_actions=[-1.5,0.,1.5], desire_speed=3., speed_cost=0.01, t_cost=0.01, control_cost=0.01, collision_cost=1., outroad_cost=1., goal_reward=1., road=Road([RoadSegment([(-100.,0.),(100.,0.),(100.,8.),(-100.,8.)]), RoadSegment([(-2,-10.),(2,-10.),(2,0.),(-2,0.)])]), n_cars=3, num_updates=1, dt=0.1, **kwargs): self.yld = yld self.vs_actions = vs_actions self.t_actions = t_actions # we use target value instead of target change so system is Markovian self.rl_actions = list(itertools.product(vs_actions,t_actions)) self.num_updates = num_updates self.desire_speed = desire_speed self.speed_cost = speed_cost self.t_cost = t_cost self.control_cost = control_cost self.collision_cost = collision_cost self.outroad_cost = outroad_cost self.goal_reward = goal_reward self._collision = False self._outroad = False self._goal = False self._intentions = [] car_length=5.0 car_width=2.0 car_max_accel=10.0 car_max_speed=40.0 car_expose_level=4 cars = [Car(idx=cid, length=car_length, width=car_width, color=random.choice(BLUE_COLORS), max_accel=car_max_accel, max_speed=car_max_speed, expose_level=car_expose_level) for cid in range(n_cars) ] driver_sigma = 0.0 s_min = 2.0 min_overlap = 1.0 drivers = [] drivers.append(EgoDriver(trajectory=EgoTrajectory(),idx=0,car=cars[0],dt=dt)) for did in range(1,n_cars): driver = TwoTDriver(idx=did, car=cars[did], dt=dt, x_driver=IDMDriver(idx=did, car=cars[did], sigma=driver_sigma, s_min=s_min, axis=0, min_overlap=min_overlap, dt=dt), y_driver=PDDriver(idx=did, car=cars[did], sigma=driver_sigma, axis=1, dt=dt)) drivers.append(driver) super(TIntersection, self).__init__( road=road, cars=cars, drivers=drivers, dt=dt, **kwargs,)
def __init__(self, yld=0.5, obs_noise=0., v_noise=0., vs_actions=[0., 0.5, 3.], t_actions=[0.], desire_speed=3., driver_sigma=0., speed_cost=0.01, t_cost=0.01, control_cost=0.01, collision_cost=2., outroad_cost=2., survive_reward=0.01, goal_reward=2., road=Road([ RoadSegment([(-100., 0.), (100., 0.), (100., 8.), (-100., 8.)]), RoadSegment([(-2, -10.), (2, -10.), (2, 0.), (-2, 0.)]) ]), left_bound=-20., right_bound=20., gap_min=3., gap_max=10., max_veh_num=12, num_updates=1, dt=0.1, des_front_gap_difference=0.1, des_front_gap_interval=0.3, **kwargs): self.yld = yld self.obs_noise = obs_noise self.v_noise = v_noise self.vs_actions = vs_actions self.t_actions = t_actions # we use target value instead of target change so system is Markovian self.rl_actions = list(itertools.product(vs_actions, t_actions)) self.num_updates = num_updates self.des_front_gap_difference = des_front_gap_difference self.des_front_gap_interval = des_front_gap_interval self.desire_speed = desire_speed self.speed_cost = speed_cost self.t_cost = t_cost self.control_cost = control_cost self.collision_cost = collision_cost self.outroad_cost = outroad_cost self.survive_reward = survive_reward self.goal_reward = goal_reward self.left_bound = left_bound self.right_bound = right_bound self.gap_min = gap_min self.gap_max = gap_max self.max_veh_num = max_veh_num self.label_dim = 2 self.label_num = self.max_veh_num self._collision = False self._outroad = False self._goal = False self._intentions = [] self._lower_lane_next_idx = 1 self._upper_lane_next_idx = int(self.max_veh_num / 2.) + 1 self.car_length = 5.0 self.car_width = 2.0 self.car_max_accel = 10.0 self.car_max_speed = 40.0 self.car_max_rotation = np.pi / 18. self.car_expose_level = 4 self.driver_sigma = driver_sigma self.s_des = 3.0 self.s_min = 3.0 self.min_overlap = 1.0 super(TIntersectionLSTM, self).__init__( road=road, cars=[], drivers=[], dt=dt, **kwargs, )
def __init__(self, obs_noise=0., x_actions=[-5, -1., 0., 1., 5.], y_actions=[0, 1], driver_sigma=0., x_cost=0.01, y_cost=0.01, control_cost=0.01, collision_cost=2., survive_reward=0.01, goal_reward=2., road=Road([ RoadSegment([(-100., 0.), (100., 0.), (100., 12.), (-100., 12.)]) ]), num_updates=1, dt=0.1, **kwargs): self.obs_noise = obs_noise self.x_actions = x_actions self.y_actions = y_actions # we use target value instead of target change so system is Markovian self.rl_actions = list(itertools.product(x_actions, y_actions)) self.num_updates = num_updates self.x_cost = x_cost self.y_cost = y_cost self.control_cost = control_cost self.collision_cost = collision_cost self.survive_reward = survive_reward self.goal_reward = goal_reward self.left_bound = -30. self.right_bound = 30. self.x_start = -20. self.x_goal = 20. self.lane_start = 0 self.lane_goal = 1 self.gap_min = 6. # 8. self.gap_max = 10. # 12. self.max_veh_num = 12 #18 self.label_dim = 2 self.label_num = self.max_veh_num self._collision = False self._block = False self._goal = False self._terminal = False self._intentions = [] self._empty_indices = list(range(1, self.max_veh_num + 1)) self.car_length = 5.0 self.car_width = 2.0 self.car_max_accel = 5.0 self.car_max_speed = 1.0 self.ego_max_speed = 2.0 self.car_max_rotation = 0. self.car_expose_level = 4 self.driver_sigma = driver_sigma self.min_x = 6. self.min_y = 3. self.ego_min_x = 6. self.ego_min_y = 3. super(HighWay, self).__init__( road=road, cars=[], drivers=[], dt=dt, **kwargs, )
car.update_render(camera_center) self.update_extra_render(extra_input) return self.viewer.render(return_rgb_array=mode == 'rgb_array') def close(self): if hasattr(self, 'viewer') and self.viewer: self.viewer.close() self.viewer = None if __name__ == '__main__': import time road = Road( [RoadSegment([(-20., -1.5), (100, -1.5), (100, 7.5), (-20, 7.5)])]) dt = 0.1 n_cars = 2 car_class = Car driver_class = XYSeperateDriver x_driver_class = IDMDriver y_driver_class = PDDriver driver_sigma = 0.0 car_length = 5.0 car_width = 2.0 car_max_accel = 10.0 car_max_speed = 40.0 car_expose_level = 4 cars = [ car_class(idx=cid, length=car_length,
def __init__(self, yld=0.5, observe_mode='full', label_mode='full', normalize_obs=False, vs_actions=[0., 0.5, 3.], t_actions=[0.], desire_speed=3., driver_sigma=0., speed_cost=0.0, t_cost=0.0, control_cost=0.0, collision_cost=1., outroad_cost=1., survive_reward=0.0, goal_reward=1., road=Road([ RoadSegment([(-100., 0.), (100., 0.), (100., 8.), (-100., 8.)]), RoadSegment([(-2, -10.), (2, -10.), (2, 0.), (-2, 0.)]) ]), left_bound=-20., right_bound=20., gap_min=3., gap_max=10., max_veh_num=12, num_updates=1, dt=0.1, **kwargs): self.yld = yld self.observe_mode = observe_mode self.label_mode = label_mode self.normalize_obs = normalize_obs self.vs_actions = vs_actions self.t_actions = t_actions # we use target value instead of target change so system is Markovian self.rl_actions = list(itertools.product(vs_actions, t_actions)) self.num_updates = num_updates self.desire_speed = desire_speed self.speed_cost = speed_cost self.t_cost = t_cost self.control_cost = control_cost self.collision_cost = collision_cost self.outroad_cost = outroad_cost self.survive_reward = survive_reward self.goal_reward = goal_reward self._collision = False self._outroad = False self._goal = False self._intentions = [] self.left_bound = left_bound self.right_bound = right_bound self.gap_min = gap_min self.gap_max = gap_max self.max_veh_num = max_veh_num self.label_dim = 2 if self.label_mode == 'full': if observe_mode == 'full': self.label_num = self.max_veh_num else: self.label_num = int(self.max_veh_num / 2) + 1 self.car_length = 5.0 self.car_width = 2.0 self.car_max_accel = 10.0 self.car_max_speed = 40.0 self.car_expose_level = 4 self.driver_sigma = driver_sigma self.s_des = 3.0 self.s_min = 3.0 self.min_overlap = 1.0 super(TIntersectionExtreme, self).__init__( road=road, cars=[], drivers=[], dt=dt, **kwargs, )