def __init__(self,
                 min_radius,
                 max_radius,
                 min_elev,
                 max_elev,
                 min_az=0,
                 max_az=2 * np.pi,
                 min_roll=0,
                 max_roll=2 * np.pi,
                 num_prealloc_samples=1):
        """Initialize a ViewsphereDiscretizer.

        Parameters
        ----------
        min_radius : float
            Minimum radius for viewing sphere.
        max_radius : float
            Maximum radius for viewing sphere.
        min_elev : float
            Minimum elevation (angle from z-axis) for camera position.
        max_elev : float
            Maximum elevation for camera position.
        min_az : float
            Minimum azimuth (angle from x-axis) for camera position.
        max_az : float
            Maximum azimuth for camera position.
        min_roll : float
            Minimum roll (rotation of camera about axis generated by azimuth and
            elevation) for camera.
        max_roll : float
            Maximum roll for camera.
        num_prealloc_samples : int
            Number of preallocated samples.
        """
        # read params
        self.min_radius = min_radius
        self.max_radius = max_radius
        self.min_az = min_az * np.pi
        self.max_az = max_az * np.pi
        self.min_elev = min_elev * np.pi
        self.max_elev = max_elev * np.pi
        self.min_roll = min_roll * np.pi
        self.max_roll = max_roll * np.pi
        self.num_prealloc_samples = num_prealloc_samples

        # setup random variables
        self.rad_rv = ss.uniform(loc=self.min_radius,
                                 scale=self.max_radius - self.min_radius)
        self.elev_rv = ss.uniform(loc=self.min_elev,
                                  scale=self.max_elev - self.min_elev)
        self.az_rv = ss.uniform(loc=self.min_az,
                                scale=self.max_az - self.min_az)
        self.roll_rv = ss.uniform(loc=self.min_roll,
                                  scale=self.max_roll - self.min_roll)

        RandomVariable.__init__(self, self.num_prealloc_samples)
示例#2
0
    def __init__(self, params, u_config):
        if not isinstance(params, GraspQualityConfig):
            raise ValueError('Must provide GraspQualityConfig')
        self.params_ = params
        self._parse_config(u_config)

        self.rvs_ = {}
        for param_name, param_rv in self.sigmas_.iteritems():
            self.rvs_[param_name] = scipy.stats.multivariate_normal(param_rv[0], param_rv[1])
        RandomVariable.__init__(self, self.num_prealloc_samples_)
示例#3
0
    def __init__(self, grasp, config):
        self.grasp_ = grasp
        self._parse_config(config)

        center_sigma = self.R_sample_sigma_.T.dot(grasp.center)
        self.t_rv_ = scipy.stats.multivariate_normal(center_sigma, self.sigma_trans_**2)
        self.r_xi_rv_ = scipy.stats.multivariate_normal(np.zeros(3), self.sigma_rot_**2)
        self.open_width_rv_ = scipy.stats.norm(grasp.open_width, self.sigma_open_width_**2)
        self.close_width_rv_ = scipy.stats.norm(grasp.close_width, self.sigma_close_width_**2)
        self.approach_rv_ = scipy.stats.norm(grasp.approach_angle, self.sigma_approach_**2)

        RandomVariable.__init__(self, self.num_prealloc_samples_)
示例#4
0
    def __init__(self, obj, mean_T_obj_world, config):
        self.obj_ = obj
        self.mean_T_obj_world_ = mean_T_obj_world
        self._parse_config(config)

        # translation in the sampling reference frame
        translation_sigma = self.R_sample_sigma_.T.dot(self.mean_T_obj_world_.translation)

        # setup random variables
        if isinstance(mean_T_obj_world, SimilarityTransform):
            self.s_rv_ = scipy.stats.norm(self.mean_T_obj_world_.scale, self.sigma_scale_**2)
        else:
            self.s_rv_ = scipy.stats.norm(1.0, self.sigma_scale_**2)
        self.t_rv_ = scipy.stats.multivariate_normal(translation_sigma, self.sigma_trans_**2)
        self.r_xi_rv_ = scipy.stats.multivariate_normal(np.zeros(3), self.sigma_rot_**2)
        self.com_rv_ = scipy.stats.multivariate_normal(np.zeros(3), self.sigma_com_**2)

        RandomVariable.__init__(self, self.num_prealloc_samples_)
    def __init__(self,
                 mesh,
                 render_modes,
                 frame,
                 config,
                 stable_pose=None,
                 scene_objs=None,
                 num_prealloc_samples=0):
        """Initialize a ViewsphereDiscretizer.

        Parameters
        ----------
        mesh : :obj:`Mesh3D`
            mesh of the object to render
        render_modes : :obj:`list` of :obj:`perception.RenderMode`
            render modes to use
        frame: :obj:`str`
            string name of the camera frame
        config : :obj:`autolab_core.YamlConfig`
            configuration containing parameters of random variable
        stable_pose : :obj:`StablePose`
            stable pose for the mesh to rest in
        scene_objs : :obj:`dict` mapping :obj:`str` to :obj:`SceneObject`
            objects to render statically in the scene
        num_prealloc_samples : int
            Number of preallocated samples.

        Notes
        -----
        Required parameters of config are specified in Other Parameters

        Other Parameters
        ----------
        min_f : float
            Minimum focal length of camera
        max_f : float
            Maximum focal length of camera
        min_cx : float
            Minimum camera optical center in x
        max_cx : float
            Maximum camera optical center in x
        min_cy : float
            Minimum camera optical center in y
        max_cy : float
            Maximum camera optical center in y
        im_height : int
            Height of camera image
        im_width : int
            Width of camera image
        min_radius : float
            Minimum radius for viewing sphere.
        max_radius : float
            Maximum radius for viewing sphere.
        min_elev : float
            Minimum elevation (angle from z-axis) for camera position.
        max_elev : float
            Maximum elevation for camera position.
        min_az : float
            Minimum azimuth (angle from x-axis) for camera position.
        max_az : float
            Maximum azimuth for camera position.
        min_roll : float
            Minimum roll (rotation of camera about axis generated by azimuth and
            elevation) for camera.
        max_roll : float
            Maximum roll for camera.
        min_x : float
            Minimum x translation of object on table
        max_x : float
            Maximum x translation of object on table
        min_y : float
            Minimum y translation of object on table
        max_y : float
            Maximum y translation of object on table
        """
        # read params
        self.mesh = mesh
        self.render_modes = render_modes
        self.frame = frame
        self.config = config
        self.stable_pose = stable_pose
        self.scene_objs = scene_objs
        self.num_prealloc_samples = num_prealloc_samples

        # init random variables
        self.ws_rv = UniformPlanarWorksurfaceRandomVariable(
            self.frame,
            self.config,
            num_prealloc_samples=self.num_prealloc_samples)

        RandomVariable.__init__(self, self.num_prealloc_samples)
    def __init__(self, frame, config, num_prealloc_samples=1):
        """Initialize a ViewsphereDiscretizer.

        Parameters
        ----------
        frame: :obj:`str`
            string name of the camera frame
        config : :obj:`autolab_core.YamlConfig`
            configuration containing parameters of random variable
        num_prealloc_samples : int
            Number of preallocated samples.

        Notes
        -----
        Required parameters of config are specified in Other Parameters

        Other Parameters
        ----------
        min_f : float
            Minimum focal length of camera
        max_f : float
            Maximum focal length of camera
        min_cx : float
            Minimum camera optical center in x
        max_cx : float
            Maximum camera optical center in x
        min_cy : float
            Minimum camera optical center in y
        max_cy : float
            Maximum camera optical center in y
        im_height : int
            Height of camera image
        im_width : int
            Width of camera image
        min_radius : float
            Minimum radius for viewing sphere.
        max_radius : float
            Maximum radius for viewing sphere.
        min_elev : float
            Minimum elevation (angle from z-axis), in degrees, for camera position.
        max_elev : float
            Maximum elevation for camera position, in degrees.
        min_az : float
            Minimum azimuth (angle from x-axis), in degrees, for camera position.
        max_az : float
            Maximum azimuth, in degrees, for camera position.
        min_roll : float
            Minimum roll (rotation of camera about axis generated by azimuth and
            elevation), in degrees, for camera.
        max_roll : float
            Maximum roll, in degrees, for camera.
        min_x : float
            Minimum x translation of object on table
        max_x : float
            Maximum x translation of object on table
        min_y : float
            Minimum y translation of object on table
        max_y : float
            Maximum y translation of object on table
        """
        # read params
        self.frame = frame
        self.config = config
        self.num_prealloc_samples = num_prealloc_samples

        self._parse_config(config)

        # setup random variables

        # camera
        self.focal_rv = ss.uniform(loc=self.min_f,
                                   scale=self.max_f - self.min_f)
        self.cx_rv = ss.uniform(loc=self.min_cx,
                                scale=self.max_cx - self.min_cx)
        self.cy_rv = ss.uniform(loc=self.min_cy,
                                scale=self.max_cy - self.min_cy)

        # viewsphere
        self.rad_rv = ss.uniform(loc=self.min_radius,
                                 scale=self.max_radius - self.min_radius)
        self.elev_rv = ss.uniform(loc=self.min_elev,
                                  scale=self.max_elev - self.min_elev)
        self.az_rv = ss.uniform(loc=self.min_az,
                                scale=self.max_az - self.min_az)
        self.roll_rv = ss.uniform(loc=self.min_roll,
                                  scale=self.max_roll - self.min_roll)

        # table translation
        self.tx_rv = ss.uniform(loc=self.min_x, scale=self.max_x - self.min_x)
        self.ty_rv = ss.uniform(loc=self.min_y, scale=self.max_y - self.min_y)

        RandomVariable.__init__(self, self.num_prealloc_samples)
示例#7
0
    def __init__(self, object_name, scene, render_modes, frame, config, num_prealloc_samples=0):
        """Initialize a UniformPlanarWorksurfaceImageRandomVariable.

        Parameters
        ----------
        object_name : str
            The name of the object to render views about
        scene : Scene
            The scene to be rendered which contains the target object.
        render_modes : list of perception.RenderMode
            A list of RenderModes that indicate the wrapped images to return.
        frame : str
            The name of the camera's frame of reference.
        config : autolab_core.YamlConfig
            A configuration containing parameters of the random variable.
        num_prealloc_samples : int
            Number of preallocated samples.

        Notes
        -----
        Required parameters of config are specified in Other Parameters.

        Other Parameters
        ----------------
        focal_length :        Focal length of the camera
            min : float
            max : float
        delta_optical_center: Change in optical center from neutral.
            min : float
            max : float
        radius:               Distance from camera to world origin.
            min : float
            max : float
        azimuth:              Azimuth (angle from x-axis) of camera in degrees.
            min : float
            max : float
        elevation:            Elevation (angle from z-axis) of camera in degrees.
            min : float
            max : float
        roll:                 Roll (angle about view direction) of camera in degrees.
            min : float
            max : float
        x:                    Translation of world center in x axis.
            min : float
            max : float
        y:                    Translation of world center in y axis.
            min : float
            max : float
        im_height : float     Height of image in pixels.
        im_width : float      Width of image in pixels.
        """
        # read params
        self.object_name = object_name
        self.scene = scene
        self.render_modes = render_modes
        self.frame = frame
        self.config = config
        self.num_prealloc_samples = num_prealloc_samples

        # init random variables
        self.ws_rv = UniformPlanarWorksurfaceRandomVariable(self.frame, self.config, num_prealloc_samples=self.num_prealloc_samples)

        RandomVariable.__init__(self, self.num_prealloc_samples)
示例#8
0
    def __init__(self, frame, config, num_prealloc_samples=1):
        """Initialize a UniformPlanarWorksurfaceRandomVariable.

        Parameters
        ----------
        frame : str
            string name of the camera frame
        config : autolab_core.YamlConfig
            configuration containing parameters of random variable
        num_prealloc_samples : int
            Number of preallocated samples.

        Notes
        -----
        Required parameters of config are specified in Other Parameters

        Other Parameters
        ----------
        focal_length :        Focal length of the camera
            min : float
            max : float
        delta_optical_center: Change in optical center from neutral.
            min : float
            max : float
        radius:               Distance from camera to world origin.
            min : float
            max : float
        azimuth:              Azimuth (angle from x-axis) of camera in degrees.
            min : float
            max : float
        elevation:            Elevation (angle from z-axis) of camera in degrees.
            min : float
            max : float
        roll:                 Roll (angle about view direction) of camera in degrees.
            min : float
            max : float
        x:                    Translation of world center in x axis.
            min : float
            max : float
        y:                    Translation of world center in y axis.
            min : float
            max : float
        im_height : float     Height of image in pixels.
        im_width : float      Width of image in pixels.
        """
        # read params
        self.frame = frame
        self.config = config
        self.num_prealloc_samples = num_prealloc_samples

        self._parse_config(config)

        # setup random variables

        # camera
        self.focal_rv = ss.uniform(loc=self.min_f, scale=self.max_f-self.min_f)
        self.cx_rv = ss.uniform(loc=self.min_cx, scale=self.max_cx-self.min_cx)
        self.cy_rv = ss.uniform(loc=self.min_cy, scale=self.max_cy-self.min_cy)

        # viewsphere
        self.rad_rv = ss.uniform(loc=self.min_radius, scale=self.max_radius-self.min_radius)
        self.elev_rv = ss.uniform(loc=self.min_elev, scale=self.max_elev-self.min_elev)
        self.az_rv = ss.uniform(loc=self.min_az, scale=self.max_az-self.min_az)
        self.roll_rv = ss.uniform(loc=self.min_roll, scale=self.max_roll-self.min_roll)

        # table translation
        self.tx_rv = ss.uniform(loc=self.min_x, scale=self.max_x-self.min_x)
        self.ty_rv = ss.uniform(loc=self.min_y, scale=self.max_y-self.min_y)

        RandomVariable.__init__(self, self.num_prealloc_samples)