Exemplo n.º 1
0
 def set_trajectory(self,
                    distance,
                    tilt_speed_deg,
                    pan_speed_deg,
                    preinit=False):
     self.distance = distance
     tilt_speed = rad(tilt_speed_deg)
     pan_speed = rad(pan_speed_deg)
     self.speed = np.sqrt(tilt_speed**2 + pan_speed**2)
     if self.speed > 0:
         self.direction = np.arccos(pan_speed / self.speed)
     else:
         self.direction = 0.0
     if tilt_speed < 0:
         self.direction = -self.direction
     self.set_episode_iteration(-1 if preinit else 0)
Exemplo n.º 2
0
 def set_delta_vergence_position(self, delta, joint_limit_type=None):
     rad_delta = rad(delta)
     left, right = self._check_pan_limit(
         self.pan_left.get_joint_position() + rad_delta / 2,
         self.pan_right.get_joint_position() - rad_delta / 2,
         joint_limit_type)
     self.pan_left.set_joint_position(left)
     self.pan_right.set_joint_position(right)
Exemplo n.º 3
0
 def set_delta_pan_speed(self, delta, joint_limit_type=None):
     self._pan_speed += rad(delta)
     left, right = self._check_pan_limit(
         self.pan_left.get_joint_position() + self._pan_speed,
         self.pan_right.get_joint_position() + self._pan_speed,
         joint_limit_type)
     self.pan_left.set_joint_position(left)
     self.pan_right.set_joint_position(right)
Exemplo n.º 4
0
 def set_pan_position(self, alpha, joint_limit_type=None):
     rad_alpha = rad(alpha)
     vergence = self.pan_left.get_joint_position(
     ) - self.pan_right.get_joint_position()
     left, right = self._check_pan_limit((vergence / 2) + rad_alpha,
                                         -(vergence / 2) + rad_alpha,
                                         joint_limit_type)
     self.pan_left.set_joint_position(left)
     self.pan_right.set_joint_position(right)
Exemplo n.º 5
0
 def set_vergence_position(self, alpha, joint_limit_type=None):
     rad_alpha = rad(alpha)
     mean = (self.pan_right.get_joint_position() +
             self.pan_left.get_joint_position()) / 2
     left, right = self._check_pan_limit(mean + rad_alpha / 2,
                                         mean - rad_alpha / 2,
                                         joint_limit_type)
     self.pan_left.set_joint_position(left)
     self.pan_right.set_joint_position(right)
Exemplo n.º 6
0
 def __init__(self,
              min_distance,
              max_distance,
              default_joint_limit_type="none"):
     self.cam_left = VisionSensor("vs_cam_left#")
     self.cam_right = VisionSensor("vs_cam_right#")
     self.tilt_left = Joint("vs_eye_tilt_left#")
     self.tilt_right = Joint("vs_eye_tilt_right#")
     self.pan_left = Joint("vs_eye_pan_left#")
     self.pan_right = Joint("vs_eye_pan_right#")
     self.min_distance = min_distance
     self.max_distance = max_distance
     self.default_joint_limit_type = default_joint_limit_type
     self._pan_max = rad(10)
     self._tilt_max = rad(10)
     self._tilt_speed = 0
     self._pan_speed = 0
     self.episode_reset()
Exemplo n.º 7
0
 def set_delta_tilt_speed(self, delta, joint_limit_type=None):
     self._tilt_speed += rad(delta)
     left, right = self._check_tilt_limit(
         self.tilt_left.get_joint_position() -
         self._tilt_speed,  # minus to get natural upward movement
         self.tilt_right.get_joint_position() -
         self._tilt_speed,  # minus to get natural upward movement
         joint_limit_type)
     self.tilt_left.set_joint_position(left)
     self.tilt_right.set_joint_position(right)
Exemplo n.º 8
0
 def episode_reset(self):
     ### reset joints position / speeds
     self.reset_speed()
     self.tilt_right.set_joint_position(0)
     self.tilt_left.set_joint_position(0)
     fixation_distance = np.random.uniform(self.min_distance,
                                           self.max_distance)
     random_vergence = rad(to_angle(fixation_distance))
     self.pan_left.set_joint_position(random_vergence / 2)
     self.pan_right.set_joint_position(-random_vergence / 2)
Exemplo n.º 9
0
 def __init__(self, min_distance, max_distance, max_speed_in_deg,
              textures_list):
     shape = Shape("vs_screen#")
     self._handle = shape.get_handle()
     self.size = 1.5
     self.textures_list = textures_list
     self.min_distance = min_distance
     self.max_distance = max_distance
     self.max_speed = rad(max_speed_in_deg)
     self.episode_reset()
Exemplo n.º 10
0
 def episode_reset(self, preinit=False):
     self.distance = np.random.uniform(self.min_distance, self.max_distance)
     self.speed = np.random.uniform(rad(0.0), rad(1.125))
     self.direction = np.random.uniform(0, 2 * np.pi)
     self.set_texture()
     self.set_episode_iteration(-1 if preinit else 0)
Exemplo n.º 11
0
 def set_tilt_position(self, alpha, joint_limit_type=None):
     rad_alpha = rad(alpha)
     left, right = self._check_tilt_limit(rad_alpha, rad_alpha,
                                          joint_limit_type)
     self.tilt_left.set_joint_position(left)
     self.tilt_right.set_joint_position(right)