def _setup_spec(self): action_spec = OrderedDict() action_selection_spec = OrderedDict() observation_vec_spec = OrderedDict() action_spec['steer'] = Box(low=-1., high=1.) action_spec['motor'] = Box(low=-1., high=1.) action_space = Box(low=np.array([v.low[0] for k, v in action_spec.items()]), high=np.array([v.high[0] for k, v in action_spec.items()])) action_selection_spec['steer'] = Box(low=-1., high=1.) action_selection_spec['motor'] = Box(low=0.3, high=1.) # min 0.3--> 1.4m/s == 4km/h, need 1km/h to detect collisions action_selection_space = Box(low=np.array([v.low[0] for k, v in action_selection_spec.items()]), high=np.array([v.high[0] for k, v in action_selection_spec.items()])) assert (np.logical_and(action_selection_space.low >= action_space.low, action_selection_space.high <= action_space.high).all()) num_channels = 0 for camera_name in self._params['cameras']: camera_params = self._params[camera_name] assert(camera_params['postprocessing'] is not None) if camera_params['include_in_obs']: if camera_params['postprocessing'] == 'SceneFinal': num_channels += 1 if camera_params.get('grayscale', False) else 3 else: num_channels += 1 observation_im_space = Box(low=0, high=255, shape=list(self._params['camera_size']) + [num_channels]) observation_vec_spec['coll'] = Discrete(1) observation_vec_spec['coll_car'] = Discrete(1) observation_vec_spec['coll_ped'] = Discrete(1) observation_vec_spec['coll_oth'] = Discrete(1) observation_vec_spec['heading'] = Box(low=-180., high=180.) observation_vec_spec['speed'] = Box(low=-30., high=30.) observation_vec_spec['accel_x'] = Box(low=-100., high=100.) observation_vec_spec['accel_y'] = Box(low=-100., high=100.) observation_vec_spec['accel_z'] = Box(low=-100., high=100.) goal_spec = self._setup_goal_spec() self.action_spec, self.action_selection_spec, self.observation_vec_spec, self.goal_spec, \ self.action_space, self.action_selection_space, self.observation_im_space = \ action_spec, action_selection_spec, observation_vec_spec, goal_spec, \ action_space, action_selection_space, observation_im_space self.spec = EnvSpec( observation_im_space=observation_im_space, action_space=action_space, action_selection_space=action_selection_space, observation_vec_spec=observation_vec_spec, action_spec=action_spec, action_selection_spec=action_selection_spec, goal_spec=goal_spec)
def __init__(self, params={}): self._yaw_limits = params['yaw_limits'] self._obs_shape = params['obs_shape'] self._horizon = params['horizon'] self.action_spec = OrderedDict() self.action_selection_spec = OrderedDict() self.observation_vec_spec = OrderedDict() self.goal_spec = OrderedDict() self.action_spec['yaw'] = Box(low=-180, high=180) self.action_space = Box(low=np.array([self.action_spec['yaw'].low[0]]), high=np.array([self.action_spec['yaw'].high[0]])) self.action_selection_spec['yaw'] = Box(low=self._yaw_limits[0], high=self._yaw_limits[1]) self.action_selection_space = Box(low = np.array([self.action_selection_spec['yaw'].low[0]]), high = np.array([self.action_selection_spec['yaw'].high[0]])) self.observation_im_space = Box(low=0, high=255, shape=self._obs_shape) self.observation_vec_spec['coll'] = Discrete(1) self.spec = EnvSpec( observation_im_space=self.observation_im_space, action_space=self.action_space, action_selection_space=self.action_selection_space, observation_vec_spec=self.observation_vec_spec, action_spec=self.action_spec, action_selection_spec=self.action_selection_spec, goal_spec=self.goal_spec )
def _setup_spec(self): self.action_spec = OrderedDict() self.unnormalized_action_spec = OrderedDict() self.observation_vec_spec = OrderedDict() self.goal_spec = OrderedDict() self.action_spec['steer'] = Box(low=-1., high=1.) self.unnormalized_action_spec['steer'] = Box( low=self._steer_limits[0], high=self._steer_limits[1]) if self._use_vel: if self._fixed_speed: self.action_spec['speed'] = Box(low=1., high=1.) self.action_space = Box(low=np.array([-1., 1.]), high=np.array([1., 1.])) else: self.action_spec['speed'] = Box(low=-1., high=1.) self.action_space = Box(low=np.array([-1., -1.]), high=np.array([1., 1.])) self.unnormalized_action_spec['speed'] = Box( low=self._speed_limits[0], high=self._speed_limits[1]) self.unnormalized_action_space = Box( low=np.array([self._steer_limits[0], self._speed_limits[0]]), high=np.array([self._steer_limits[1], self._speed_limits[1]])) else: self.action_spec['motor'] = Box(low=-1., high=1.) self.action_space = Box(low=np.array([-1., -1.]), high=np.array([1., 1.])) self.unnormalized_action_spec['motor'] = Box(low=-self._accelClamp, high=self._accelClamp) self.unnormalized_action_space = Box( low=np.array([self._steer_limits[0], -self._accelClamp]), high=np.array([self._steer_limits[1], self._accelClamp])) self.observation_im_space = Box(low=0, high=255, shape=tuple( self._get_observation()[0].shape)) self.observation_vec_spec['coll'] = Discrete(1) self.observation_vec_spec['heading'] = Box(low=0, high=2 * 3.14) self.observation_vec_spec['speed'] = Box(low=-4.0, high=4.0)
def _setup_spec(self): self.action_spec = OrderedDict() self.action_selection_spec = OrderedDict() self.observation_vec_spec = OrderedDict() self.goal_spec = OrderedDict() self.action_spec['steer'] = Box(low=-1., high=1.) self.action_spec['speed'] = Box(low=-0.3, high=0.3) self.action_space = Box(low=np.array([ self.action_spec['steer'].low[0], self.action_spec['speed'].low[0] ]), high=np.array([ self.action_spec['steer'].high[0], self.action_spec['speed'].high[0] ])) self.action_selection_spec['steer'] = Box(low=self._steer_limits[0], high=self._steer_limits[1]) self.action_selection_spec['speed'] = Box(low=self._speed_limits[0], high=self._speed_limits[1]) self.action_selection_space = Box( low=np.array([ self.action_selection_spec['steer'].low[0], self.action_selection_spec['speed'].low[0] ]), high=np.array([ self.action_selection_spec['steer'].high[0], self.action_selection_spec['speed'].high[0] ])) assert (np.logical_and( self.action_selection_space.low >= self.action_space.low, self.action_selection_space.high <= self.action_space.high).all()) self.observation_im_space = Box(low=0, high=255, shape=self._obs_shape) self.observation_vec_spec['coll'] = Discrete(1) self.observation_vec_spec['heading'] = Box(low=0, high=2 * 3.14) self.observation_vec_spec['speed'] = Box(low=-0.4, high=0.4) self.observation_vec_spec['steer'] = Box(low=-1., high=1.) self.observation_vec_spec['motor'] = Box(low=-1., high=1.)
def _setup_spec(self): self.action_spec = OrderedDict() self.action_selection_spec = OrderedDict() self.observation_vec_spec = OrderedDict() self.goal_spec = OrderedDict() self.action_spec['yaw'] = Box(low=-180, high=180) self.action_space = Box(low=np.array([self.action_spec['yaw'].low[0]]), high=np.array( [self.action_spec['yaw'].high[0]])) self.action_selection_spec['yaw'] = Box(low=self._yaw_limits[0], high=self._yaw_limits[1]) self.action_selection_space = Box( low=np.array([self.action_selection_spec['yaw'].low[0]]), high=np.array([self.action_selection_spec['yaw'].high[0]])) assert (np.logical_and( self.action_selection_space.low >= self.action_space.low, self.action_selection_space.high <= self.action_space.high).all()) self.observation_im_space = Box(low=0, high=255, shape=self._obs_shape) self.observation_vec_spec['coll'] = Discrete(1)
def _setup_spec(self): self.action_spec = OrderedDict() self.action_selection_spec = OrderedDict() self.observation_vec_spec = OrderedDict() self.goal_spec = OrderedDict() self.action_spec['steer'] = Box(low=-45., high=45.) self.action_selection_spec['steer'] = Box(low=self._steer_limits[0], high=self._steer_limits[1]) if self._use_vel: self.action_spec['speed'] = Box(low=-4., high=4.) self.action_space = Box(low=np.array([self.action_spec['steer'].low[0], self.action_spec['speed'].low[0]]), high=np.array([self.action_spec['steer'].high[0], self.action_spec['speed'].high[0]])) self.action_selection_spec['speed'] = Box(low=self._speed_limits[0], high=self._speed_limits[1]) self.action_selection_space = Box(low=np.array([self.action_selection_spec['steer'].low[0], self.action_selection_spec['speed'].low[0]]), high=np.array([self.action_selection_spec['steer'].high[0], self.action_selection_spec['speed'].high[0]])) else: self.action_spec['motor'] = Box(low=-self._accelClamp, high=self._accelClamp) self.action_space = Box(low=np.array([self.action_spec['steer'].low[0], self.action_spec['motor'].low[0]]), high=np.array([self.action_spec['steer'].high[0], self.action_spec['motor'].high[0]])) self.action_selection_spec['motor'] = Box(low=self._motor_limits[0], high=self._motor_limits[1]) self.action_selection_space = Box(low=np.array([self.action_selection_spec['steer'].low[0], self.action_selection_spec['motor'].low[0]]), high=np.array([self.action_selection_spec['steer'].high[0], self.action_selection_spec['motor'].high[0]])) assert (np.logical_and(self.action_selection_space.low >= self.action_space.low - 1e-4, self.action_selection_space.high <= self.action_space.high + 1e-4).all()) self.observation_im_space = Box(low=0, high=255, shape=tuple(self._get_observation()[0].shape)) self.observation_vec_spec['coll'] = Discrete(1) self.observation_vec_spec['heading'] = Box(low=0, high=2 * 3.14) self.observation_vec_spec['speed'] = Box(low=-4.0, high=4.0)