mani_skill.envs.utils.randomization =================================== .. py:module:: mani_skill.envs.utils.randomization Submodules ---------- .. toctree:: :maxdepth: 1 /api/mani_skill/envs/utils/randomization/batched_rng/index /api/mani_skill/envs/utils/randomization/camera/index /api/mani_skill/envs/utils/randomization/common/index /api/mani_skill/envs/utils/randomization/pose/index /api/mani_skill/envs/utils/randomization/samplers/index Attributes ---------- .. autoapisummary:: mani_skill.envs.utils.randomization.Device mani_skill.envs.utils.randomization.Device mani_skill.envs.utils.randomization.Device Classes ------- .. autoapisummary:: mani_skill.envs.utils.randomization.UniformPlacementSampler Functions --------- .. autoapisummary:: mani_skill.envs.utils.randomization.euler_angles_to_matrix mani_skill.envs.utils.randomization.matrix_to_quaternion mani_skill.envs.utils.randomization.random_quaternions mani_skill.envs.utils.randomization.uniform Package Contents ---------------- .. py:class:: UniformPlacementSampler(bounds, batch_size, device = None) Uniform placement sampler that lets you sequentially sample data such that the data is within given bounds and not too close to previously sampled data. This sampler is also batched so you can use this easily for GPU simulated tasks :param bounds: ((low1, low2, ...), (high1, high2, ...)) :param batch_size: The number of points to sample with each call to sample(...) :type batch_size: int .. py:method:: sample(radius, max_trials, append=True, verbose=False) Sample a position. :param radius: collision radius. :type radius: float :param max_trials: maximal trials to sample. :type max_trials: int :param append: whether to append the new sample to fixtures. Defaults to True. :type append: bool, optional :param verbose: whether to print verbosely. Defaults to False. :type verbose: bool, optional :returns: a sampled position. :rtype: torch.Tensor .. py:attribute:: _bounds .. py:attribute:: _ranges .. py:attribute:: batch_size .. py:attribute:: fixture_positions :value: None .. py:attribute:: fixtures_radii :value: None .. py:function:: euler_angles_to_matrix(euler_angles, convention) Convert rotations given as Euler angles in radians to rotation matrices. :param euler_angles: Euler angles in radians as tensor of shape (..., 3). :param convention: Convention string of three uppercase letters from {"X", "Y", and "Z"}. :returns: Rotation matrices as tensor of shape (..., 3, 3). .. py:function:: matrix_to_quaternion(matrix) Convert rotations given as rotation matrices to quaternions. :param matrix: Rotation matrices as tensor of shape (..., 3, 3). :returns: quaternions with real part first, as tensor of shape (..., 4). .. py:function:: random_quaternions(n, device = None, lock_x = False, lock_y = False, lock_z = False, bounds=(0, np.pi * 2)) Generates random quaternions by generating random euler angles uniformly, with each of the X, Y, Z angles ranging from bounds[0] to bounds[1] radians. Can optionally choose to fix X, Y, and/or Z euler angles to 0 via lock_x, lock_y, lock_z arguments .. py:function:: uniform(low, high, size, device = None) .. py:data:: Device .. py:data:: Device .. py:data:: Device The transformation matrices returned from the functions in this file assume the points on which the transformation will be applied are column vectors. i.e. the R matrix is structured as R = [ [Rxx, Rxy, Rxz], [Ryx, Ryy, Ryz], [Rzx, Rzy, Rzz], ] # (3, 3) This matrix can be applied to column vectors by post multiplication by the points e.g. points = [[0], [1], [2]] # (3 x 1) xyz coordinates of a point transformed_points = R * points To apply the same matrix to points which are row vectors, the R matrix can be transposed and pre multiplied by the points: e.g. points = [[0, 1, 2]] # (1 x 3) xyz coordinates of a point transformed_points = points * R.transpose(1, 0)