timor.task.Tolerance ==================== .. py:module:: timor.task.Tolerance Attributes ---------- .. autoapisummary:: timor.task.Tolerance.DEFAULT_SPATIAL Classes ------- .. autoapisummary:: timor.task.Tolerance.Abs6dPoseTolerance timor.task.Tolerance.AlwaysValidTolerance timor.task.Tolerance.Cartesian timor.task.Tolerance.CartesianCylindrical timor.task.Tolerance.CartesianSpheric timor.task.Tolerance.CartesianXYZ timor.task.Tolerance.Composed timor.task.Tolerance.Rotation timor.task.Tolerance.RotationAbsolute timor.task.Tolerance.RotationAxis timor.task.Tolerance.Spatial timor.task.Tolerance.ToleranceBase timor.task.Tolerance.VectorDistance Module Contents --------------- .. py:class:: Abs6dPoseTolerance(abs_tolerance) .. autoapi-inheritance-diagram:: timor.task.Tolerance.Abs6dPoseTolerance :parts: 1 :private-bases: An absolute 6d-Vector Tolerance Tolerance on the absolute difference between spatial and angular velocities or accelerations. (6D vector) This makes no distinction between (d)dx, (d)dy, (d)dz and (d)d_alpha, (d)d_beta, (d)d_gamma - so use with care! A tolerance for a vector valued array :param abs_tolerance: The tolerance value (symmetric) .. py:method:: __add__(other) Combine tolerances (logical AND operation) Adding two tolerances always yields a stronger constraint than either of the summands .. py:method:: __eq__(other) Two absolute pose tolerances are equal if they have the same tolerance values .. py:method:: __hash__() The tolerance value fully determines this class .. py:attribute:: __slots__ :value: () .. py:method:: _add_same(other) Add two tolerances together. .. py:method:: _stratify(v) Make sure the array is 1-dimensional. .. py:attribute:: _visual_color :value: 65280 .. py:property:: _visual_geometry :type: (meshcat.geometry.Geometry, timor.utilities.transformation.Transformation) The geometry representing the tolerance in a visualization and the relative offset to the nominal position .. py:attribute:: _visual_material .. py:method:: default() :classmethod: A default absolute tolerance of 0.001. .. py:method:: from_projection(projection, values, frame = NOMINAL_FRAME) :staticmethod: Creates a tolerance from a projection descriptor and an absolute tolerance value. :param projection: The projection descriptor. Valid values: {"x", "y", "z", "r_cyl", "r_sph", "theta", "phi", "R", "P", "Y", "Alpha", "Beta", "Gamma", "N_x", "N_y", "N_z", "Theta_R", "A", "B", "C", "D"} :param values: The lower and upper bound for the tolerance :param frame: The frame in which the tolerance is defined. Defaults to the world frame. :return: The tolerance class instance .. py:method:: to_projection() :abstractmethod: There is no tolerance projection for this tolerance yet .. py:attribute:: tolerance .. py:method:: valid(desired, real) Is valid if the absolute difference between the desired and real is within the tolerance. .. py:method:: visualize(viz, transform, name = None, custom_material = None) Visualize the tolerance in a MeshcatVisualizer :param viz: A meshcat visualizer instance to display the tolerance in. :param transform: The nominal position for which the tolerance is specified :param name: A display name for the tolerance. Will be set to a random name if not given. :param custom_material: Tolerances are displayed in transparent green -- a custom material can change the default appearance .. py:class:: AlwaysValidTolerance .. autoapi-inheritance-diagram:: timor.task.Tolerance.AlwaysValidTolerance :parts: 1 :private-bases: A tolerance that always evaluates to true .. py:method:: __add__(other) AlwaysValidTolerance is always weaker than any other tolerance .. py:method:: __eq__(other) AlwaysValidTolerance is always equal to itself .. py:method:: __hash__() There's just one instance of this tolerance .. py:attribute:: __slots__ :value: () .. py:method:: _add_same(other) :abstractmethod: This should not be necessary. Raising because it would be a bug if this method would ever be called .. py:attribute:: _visual_color :value: 65280 .. py:property:: _visual_geometry :type: (meshcat.geometry.Geometry, timor.utilities.transformation.Transformation) The geometry representing the tolerance in a visualization and the relative offset to the nominal position .. py:attribute:: _visual_material .. py:method:: default() :classmethod: AlwaysValidTolerance default is always valid - who would've thought? .. py:method:: from_projection(projection, values, frame = NOMINAL_FRAME) :staticmethod: Creates a tolerance from a projection descriptor and an absolute tolerance value. :param projection: The projection descriptor. Valid values: {"x", "y", "z", "r_cyl", "r_sph", "theta", "phi", "R", "P", "Y", "Alpha", "Beta", "Gamma", "N_x", "N_y", "N_z", "Theta_R", "A", "B", "C", "D"} :param values: The lower and upper bound for the tolerance :param frame: The frame in which the tolerance is defined. Defaults to the world frame. :return: The tolerance class instance .. py:method:: to_projection() AlwaysValidTolerance is always valid, so no description is needed .. py:method:: valid(desired, real) You don't say .. py:method:: visualize(viz, transform, name = None, custom_material = None) AlwaysValidTolerance is always valid, so no visualization is needed .. py:class:: Cartesian(a, b, c, frame = NOMINAL_FRAME) .. autoapi-inheritance-diagram:: timor.task.Tolerance.Cartesian :parts: 1 :private-bases: Cartesian Space Tolerances (on positions) Tolerance is valid if all proj(desired-real) is in the interval [tolerances[:, 0], tolerances[:, 1]] .. py:attribute:: CorrespondingVolumeType :type: Type[timor.Volume] :value: None .. py:method:: __add__(other) Combine tolerances (logical AND operation) Adding two tolerances always yields a stronger constraint than either of the summands .. py:method:: __eq__(other) Two cartesian tolerances are equal if they have the same tolerance values and dtype .. py:method:: __hash__() The class is defined by the tolerance bounds that can be hashed .. py:attribute:: __slots__ :value: () .. py:method:: _add_same(other) Combine two pose tolerances .. py:attribute:: _frame .. py:method:: _inv_projection(projected) :abstractmethod: Inverse to _projection Maps a projected element from the tolerances projection space to a placement, being offset from the origin by the values defined in the projection space. .. py:attribute:: _max_possible .. py:property:: _pose_projection_data :type: Dict[str, Union[Tuple[str], numpy.ndarray]] :abstractmethod: Generate a projection that can be used to describe a tolerance. To be implemented by children - returns the data for the projection of the pose. The tolerance values should be np arrays though, not lists. .. py:method:: _projection(nominal) :abstractmethod: Maps a placement to the projection space of the tolerance .. py:attribute:: _rounding_error :type: float :value: 1e-12 .. py:attribute:: _visual_color :value: 65280 .. py:property:: _visual_geometry :type: (meshcat.geometry.Geometry, timor.utilities.transformation.Transformation) The geometry representing the tolerance in a visualization and the relative offset to the nominal position .. py:attribute:: _visual_material .. py:method:: default() :classmethod: :abstractmethod: Default tolerance, e.g. for a cartesian tolerance that is 0.001 for all dimensions .. py:method:: enclosing_volume(limits, offset = Transformation.neutral()) Returns an internal representation of a volume object, described by limits and offsets. :param limits: The limits of the volume, as a 3x2 array. For each row, the first column represents the lower limit, and the second column represents the upper limit. :param offset: An optional transformation that is applied to the volume to adjust its position and orientation. :return: An internal representation of the volume. .. py:method:: from_projection(projection, values, frame = NOMINAL_FRAME) :staticmethod: Creates a tolerance from a projection descriptor and an absolute tolerance value. :param projection: The projection descriptor. Valid values: {"x", "y", "z", "r_cyl", "r_sph", "theta", "phi", "R", "P", "Y", "Alpha", "Beta", "Gamma", "N_x", "N_y", "N_z", "Theta_R", "A", "B", "C", "D"} :param values: The lower and upper bound for the tolerance :param frame: The frame in which the tolerance is defined. Defaults to the world frame. :return: The tolerance class instance .. py:property:: stacked :type: numpy.ndarray The tolerances stacked in a 3x2 array .. py:method:: to_projection() A dictionary that can be used to specify this tolerance as a tolerated pose projection. Format: Dictionary with * projection: (proj_0, ..., proj_n) <>, * tolerance: (tol_0, ..., tol_n) <> .. py:method:: valid(desired, real) For cartesian tolerance, we can check if the tolerance is within the enclosing Volume .. py:property:: valid_random_deviation :type: timor.utilities.transformation.Transformation Used to generate a random but still valid transformation. Returns a random deviation/distortion that would still satisfy the tolerance, distributed uniformly in the solution space. Useful for sampling valid positions. Always returns a Transformation. .. py:method:: visualize(viz, transform, name = None, custom_material = None) Visualize the tolerance in a MeshcatVisualizer :param viz: A meshcat visualizer instance to display the tolerance in. :param transform: The nominal position for which the tolerance is specified :param name: A display name for the tolerance. Will be set to a random name if not given. :param custom_material: Tolerances are displayed in transparent green -- a custom material can change the default appearance .. py:class:: CartesianCylindrical(r, phi_cyl = (-np.pi, np.pi), z = (-np.inf, np.inf), frame = NOMINAL_FRAME) .. autoapi-inheritance-diagram:: timor.task.Tolerance.CartesianCylindrical :parts: 1 :private-bases: Cylindrical space tolerances (on positions). The desired placement must be within a space defined by cylinder coordinates r, z and phi. https://en.wikipedia.org/wiki/Cylindrical_coordinate_system Defines a (partial) cylinder as tolerance. :param r: Lower and upper tolerance for the radius. :param phi_cyl: Lower and upper tolerance for angle of cylinder coordinates between -pi and pi (radian) :param z: lower and upper tolerance for the cylinder z coordinates. .. py:attribute:: CorrespondingVolumeType .. py:method:: __add__(other) Custom add method to deal with cartesian/cylinder combinations Overwrite behavior if the other class is a cartesian with a z-tolerance only: Then it can be seen as cylindrical as well. .. py:method:: __eq__(other) Two cartesian tolerances are equal if they have the same tolerance values and dtype .. py:method:: __hash__() The class is defined by the tolerance bounds that can be hashed .. py:attribute:: __slots__ :value: () .. py:method:: _add_same(other) Combine two pose tolerances .. py:attribute:: _frame .. py:method:: _inv_projection(projected) Map cylindrical to cartesian coordinates .. py:attribute:: _max_possible .. py:property:: _pose_projection_data :type: Dict[str, Union[Tuple[str], numpy.ndarray]] Generate a projection that can be used to describe a tolerance. To be implemented by children - returns the data for the projection of the pose. The tolerance values should be np arrays though, not lists. .. py:method:: _projection(nominal) Map cartesian to cylindrical coordinates .. py:attribute:: _rounding_error :type: float :value: 1e-12 .. py:attribute:: _visual_color :value: 65280 .. py:property:: _visual_geometry :type: (meshcat.geometry.Geometry, timor.utilities.transformation.Transformation) Visualize (partial) cylinder .. py:attribute:: _visual_material .. py:method:: default() :classmethod: Returns a CartesianCylindrical with default tolerances .. py:method:: enclosing_volume(limits, offset = Transformation.neutral()) Returns a cylinder volume object. .. py:method:: from_projection(projection, values, frame = NOMINAL_FRAME) :staticmethod: Creates a tolerance from a projection descriptor and an absolute tolerance value. :param projection: The projection descriptor. Valid values: {"x", "y", "z", "r_cyl", "r_sph", "theta", "phi", "R", "P", "Y", "Alpha", "Beta", "Gamma", "N_x", "N_y", "N_z", "Theta_R", "A", "B", "C", "D"} :param values: The lower and upper bound for the tolerance :param frame: The frame in which the tolerance is defined. Defaults to the world frame. :return: The tolerance class instance .. py:property:: stacked :type: numpy.ndarray The tolerances stacked in a 3x2 array .. py:method:: to_projection() A dictionary that can be used to specify this tolerance as a tolerated pose projection. Format: Dictionary with * projection: (proj_0, ..., proj_n) <>, * tolerance: (tol_0, ..., tol_n) <> .. py:method:: valid(desired, real) For cartesian tolerance, we can check if the tolerance is within the enclosing Volume .. py:property:: valid_random_deviation :type: timor.utilities.transformation.Transformation Used to generate a random but still valid transformation. Returns a random deviation/distortion that would still satisfy the tolerance, distributed uniformly in the solution space. Useful for sampling valid positions. Always returns a Transformation. .. py:method:: visualize(viz, transform, name = None, custom_material = None) Visualize the tolerance in a MeshcatVisualizer :param viz: A meshcat visualizer instance to display the tolerance in. :param transform: The nominal position for which the tolerance is specified :param name: A display name for the tolerance. Will be set to a random name if not given. :param custom_material: Tolerances are displayed in transparent green -- a custom material can change the default appearance .. py:class:: CartesianSpheric(r, theta = (0, np.pi), phi_sph = (-np.pi, np.pi), frame = NOMINAL_FRAME) .. autoapi-inheritance-diagram:: timor.task.Tolerance.CartesianSpheric :parts: 1 :private-bases: https://en.wikipedia.org/wiki/Spherical_coordinate_system Defines a potentially cut out spherical-shaped tolerance :param r: Lower and upper tolerance for the radius. :param theta: lower and upper tolerance for the inclination angle theta between 0 and 180 degree (in radian). :param phi_sph: Lower and upper tolerance for the polar angle phi between -180 and 180 degrees (in radian). .. py:attribute:: CorrespondingVolumeType .. py:method:: __add__(other) Combine tolerances (logical AND operation) Adding two tolerances always yields a stronger constraint than either of the summands .. py:method:: __eq__(other) Two cartesian tolerances are equal if they have the same tolerance values and dtype .. py:method:: __hash__() The class is defined by the tolerance bounds that can be hashed .. py:attribute:: __slots__ :value: () .. py:method:: _add_same(other) Combine two pose tolerances .. py:attribute:: _frame .. py:method:: _inv_projection(projected) Map spherical to cartesian coordinates .. py:attribute:: _max_possible .. py:property:: _pose_projection_data :type: Dict[str, Union[Tuple[str], numpy.ndarray]] Generate a projection that can be used to describe a tolerance. To be implemented by children - returns the data for the projection of the pose. The tolerance values should be np arrays though, not lists. .. py:method:: _projection(nominal) Map cartesian to spherical coordinates .. py:attribute:: _rounding_error :type: float :value: 1e-12 .. py:attribute:: _visual_color :value: 65280 .. py:property:: _visual_geometry :type: (meshcat.geometry.Geometry, timor.utilities.transformation.Transformation) Visualize a (partial) sphere. Meshcat has no support for this, so we use a Mesh to realize it .. py:attribute:: _visual_material .. py:method:: default() :classmethod: Returns a CartesianSpheric with default tolerances .. py:method:: enclosing_volume(limits, offset = Transformation.neutral()) Returns an internal representation of a volume object, described by limits and offsets. :param limits: The limits of the volume, as a 3x2 array. For each row, the first column represents the lower limit, and the second column represents the upper limit. :param offset: An optional transformation that is applied to the volume to adjust its position and orientation. :return: An internal representation of the volume. .. py:method:: from_projection(projection, values, frame = NOMINAL_FRAME) :staticmethod: Creates a tolerance from a projection descriptor and an absolute tolerance value. :param projection: The projection descriptor. Valid values: {"x", "y", "z", "r_cyl", "r_sph", "theta", "phi", "R", "P", "Y", "Alpha", "Beta", "Gamma", "N_x", "N_y", "N_z", "Theta_R", "A", "B", "C", "D"} :param values: The lower and upper bound for the tolerance :param frame: The frame in which the tolerance is defined. Defaults to the world frame. :return: The tolerance class instance .. py:property:: stacked :type: numpy.ndarray The tolerances stacked in a 3x2 array .. py:method:: to_projection() A dictionary that can be used to specify this tolerance as a tolerated pose projection. Format: Dictionary with * projection: (proj_0, ..., proj_n) <>, * tolerance: (tol_0, ..., tol_n) <> .. py:method:: valid(desired, real) For cartesian tolerance, we can check if the tolerance is within the enclosing Volume .. py:property:: valid_random_deviation :type: timor.utilities.transformation.Transformation Used to generate a random but still valid transformation. Returns a random deviation/distortion that would still satisfy the tolerance, distributed uniformly in the solution space. Useful for sampling valid positions. Always returns a Transformation. .. py:method:: visualize(viz, transform, name = None, custom_material = None) Visualize the tolerance in a MeshcatVisualizer :param viz: A meshcat visualizer instance to display the tolerance in. :param transform: The nominal position for which the tolerance is specified :param name: A display name for the tolerance. Will be set to a random name if not given. :param custom_material: Tolerances are displayed in transparent green -- a custom material can change the default appearance .. py:class:: CartesianXYZ(x, y, z, frame = NOMINAL_FRAME) .. autoapi-inheritance-diagram:: timor.task.Tolerance.CartesianXYZ :parts: 1 :private-bases: Axis-aligned cartesian tolerance. Defines a box-shaped tolerance :param x: Tolerances for x. Usually expected to be of format [negative, positive] :param y: Tolerances for y. Usually expected to be of format [negative, positive] :param z: Tolerances for z. Usually expected to be of format [negative, positive] .. py:attribute:: CorrespondingVolumeType .. py:method:: __add__(other) Custom add method to deal with cartesian/cylinder combinations Overwrite behavior if the other class is a cartesian with a z-tolerance only: Then it can be seen as cylindrical as well. .. py:method:: __eq__(other) Two cartesian tolerances are equal if they have the same tolerance values and dtype .. py:method:: __hash__() The class is defined by the tolerance bounds that can be hashed .. py:attribute:: __slots__ :value: () .. py:method:: _add_same(other) Combine two pose tolerances .. py:attribute:: _frame .. py:method:: _inv_projection(projected) CartesianXYZ works in default cartesian coordinates .. py:attribute:: _max_possible .. py:property:: _pose_projection_data :type: Dict[str, Union[Tuple[str], numpy.ndarray]] Generate a projection that can be used to describe a tolerance. To be implemented by children - returns the data for the projection of the pose. The tolerance values should be np arrays though, not lists. .. py:method:: _projection(nominal) CartesianXYZ works in default cartesian coordinates .. py:attribute:: _rounding_error :type: float :value: 1e-12 .. py:attribute:: _visual_color :value: 65280 .. py:property:: _visual_geometry :type: (meshcat.geometry.Geometry, timor.utilities.transformation.Transformation) That's a box .. py:attribute:: _visual_material .. py:method:: default() :classmethod: Returns a CartesianXYZ with default tolerances .. py:method:: enclosing_volume(limits, offset = Transformation.neutral()) Returns an internal representation of a volume object, described by limits and offsets. :param limits: The limits of the volume, as a 3x2 array. For each row, the first column represents the lower limit, and the second column represents the upper limit. :param offset: An optional transformation that is applied to the volume to adjust its position and orientation. :return: An internal representation of the volume. .. py:method:: from_projection(projection, values, frame = NOMINAL_FRAME) :staticmethod: Creates a tolerance from a projection descriptor and an absolute tolerance value. :param projection: The projection descriptor. Valid values: {"x", "y", "z", "r_cyl", "r_sph", "theta", "phi", "R", "P", "Y", "Alpha", "Beta", "Gamma", "N_x", "N_y", "N_z", "Theta_R", "A", "B", "C", "D"} :param values: The lower and upper bound for the tolerance :param frame: The frame in which the tolerance is defined. Defaults to the world frame. :return: The tolerance class instance .. py:property:: stacked :type: numpy.ndarray The tolerances stacked in a 3x2 array .. py:method:: to_projection() A dictionary that can be used to specify this tolerance as a tolerated pose projection. Format: Dictionary with * projection: (proj_0, ..., proj_n) <>, * tolerance: (tol_0, ..., tol_n) <> .. py:method:: valid(desired, real) For cartesian tolerance, we can check if the tolerance is within the enclosing Volume .. py:property:: valid_random_deviation :type: timor.utilities.transformation.Transformation Used to generate a random but still valid transformation. Returns a random deviation/distortion that would still satisfy the tolerance, distributed uniformly in the solution space. Useful for sampling valid positions. Always returns a Transformation. .. py:method:: visualize(viz, transform, name = None, custom_material = None) Visualize the tolerance in a MeshcatVisualizer :param viz: A meshcat visualizer instance to display the tolerance in. :param transform: The nominal position for which the tolerance is specified :param name: A display name for the tolerance. Will be set to a random name if not given. :param custom_material: Tolerances are displayed in transparent green -- a custom material can change the default appearance .. py:class:: Composed(tolerances, sample_time_limits = 10.0, simplify_combinations = True) .. autoapi-inheritance-diagram:: timor.task.Tolerance.Composed :parts: 1 :private-bases: Holds any number of different tolerances and evaluates to true iff all internal tolerances do A tolerance combining multiple tolerances of various types :param tolerances: Any number of tolerance instances :param sample_time_limits: The maximum time to find a random valid sample for the composed tolerance :param simplify_combinations: If true, compatible tolerances (e.g. 2 of the same type) will be merged .. py:method:: __add__(other) Combine tolerances (logical AND operation) Adding two tolerances always yields a stronger constraint than either of the summands .. py:method:: __eq__(other) Two composed tolerances are equal if they contain the same tolerances .. py:method:: __hash__() The class is defined by the tolerance bounds that can be hashed .. py:attribute:: __slots__ :value: () .. py:method:: _add_same(other) Combine two composed tolerances .. py:attribute:: _internal .. py:attribute:: _visual_color :value: 65280 .. py:property:: _visual_geometry :type: (meshcat.geometry.Geometry, timor.utilities.transformation.Transformation) The geometry representing the tolerance in a visualization and the relative offset to the nominal position .. py:attribute:: _visual_material .. py:method:: add(other, simplify_combinations = True) Add a new tolerance to this composed tolerance. Other than tha add operator (+), this changes the instance :param other: The tolerance to add :param simplify_combinations: If true, compatible tolerances (e.g. 2 of the same type) will be merged .. py:method:: default() :classmethod: This cannot be done .. py:method:: from_projection(projection, values, frame = NOMINAL_FRAME) :staticmethod: Creates a tolerance from a projection descriptor and an absolute tolerance value. :param projection: The projection descriptor. Valid values: {"x", "y", "z", "r_cyl", "r_sph", "theta", "phi", "R", "P", "Y", "Alpha", "Beta", "Gamma", "N_x", "N_y", "N_z", "Theta_R", "A", "B", "C", "D"} :param values: The lower and upper bound for the tolerance :param frame: The frame in which the tolerance is defined. Defaults to the world frame. :return: The tolerance class instance .. py:attribute:: time_limit :value: 10.0 .. py:method:: to_projection() Projects all internal tolerances .. py:property:: tolerances :type: Set[ToleranceBase] The internal tolerances .. py:method:: valid(desired, real) Is valid if all internal tolerances are valid .. py:method:: visualize(viz, transform, name = None, custom_material = None) Visualize all internal tolerances, with a slightly different color than the default to distinguish them .. py:data:: DEFAULT_SPATIAL .. py:class:: Rotation(frame = NOMINAL_FRAME, *args) .. autoapi-inheritance-diagram:: timor.task.Tolerance.Rotation :parts: 1 :private-bases: Rotation tolerances based on projections of a 4x4 transformation - implements projections. This class does not provide much functionality on its own, but it's useful to have a rotation super-class. .. py:attribute:: CorrespondingVolumeType :type: Type[timor.Volume] :value: None .. py:method:: __add__(other) Combine tolerances (logical AND operation) Adding two tolerances always yields a stronger constraint than either of the summands .. py:method:: __eq__(other) Two cartesian tolerances are equal if they have the same tolerance values and dtype .. py:method:: __hash__() The class is defined by the tolerance bounds that can be hashed .. py:attribute:: __slots__ :value: () .. py:method:: _add_same(other) Combine two pose tolerances .. py:attribute:: _frame .. py:method:: _inv_projection(projected) :abstractmethod: Inverse to _projection Maps a projected element from the tolerances projection space to a placement, being offset from the origin by the values defined in the projection space. .. py:attribute:: _max_possible :type: numpy.ndarray .. py:property:: _pose_projection_data :type: Dict[str, Union[Tuple[str], numpy.ndarray]] :abstractmethod: Generate a projection that can be used to describe a tolerance. To be implemented by children - returns the data for the projection of the pose. The tolerance values should be np arrays though, not lists. .. py:method:: _projection(nominal) :abstractmethod: Maps a placement to the projection space of the tolerance .. py:attribute:: _rounding_error :type: float :value: 1e-12 .. py:attribute:: _visual_color :value: 65280 .. py:property:: _visual_geometry :type: (meshcat.geometry.Geometry, timor.utilities.transformation.Transformation) The geometry representing the tolerance in a visualization and the relative offset to the nominal position .. py:attribute:: _visual_material .. py:method:: default() :classmethod: :abstractmethod: Default tolerance, e.g. for a cartesian tolerance that is 0.001 for all dimensions .. py:method:: enclosing_volume(limits, offset = Transformation.neutral()) Returns an internal representation of a volume object, described by limits and offsets. :param limits: The limits of the volume, as a 3x2 array. For each row, the first column represents the lower limit, and the second column represents the upper limit. :param offset: An optional transformation that is applied to the volume to adjust its position and orientation. :return: An internal representation of the volume. .. py:method:: from_projection(projection, values, frame = NOMINAL_FRAME) :staticmethod: Creates a tolerance from a projection descriptor and an absolute tolerance value. :param projection: The projection descriptor. Valid values: {"x", "y", "z", "r_cyl", "r_sph", "theta", "phi", "R", "P", "Y", "Alpha", "Beta", "Gamma", "N_x", "N_y", "N_z", "Theta_R", "A", "B", "C", "D"} :param values: The lower and upper bound for the tolerance :param frame: The frame in which the tolerance is defined. Defaults to the world frame. :return: The tolerance class instance .. py:property:: stacked :type: numpy.ndarray :abstractmethod: The tolerances stacked in an array of dimensions (num_projections, 2) .. py:method:: to_projection() A dictionary that can be used to specify this tolerance as a tolerated pose projection. Format: Dictionary with * projection: (proj_0, ..., proj_n) <>, * tolerance: (tol_0, ..., tol_n) <> .. py:method:: valid(desired, real) Public interface, makes sure child classes only work on (3,) shaped points .. py:property:: valid_random_deviation :type: timor.utilities.transformation.Transformation Used to generate a random but still valid transformation. Returns a random deviation/distortion that would still satisfy the tolerance, distributed uniformly in the solution space. Useful for sampling valid positions. Always returns a Transformation. .. py:method:: visualize(viz, transform, name = None, custom_material = None) Visualize the tolerance in a MeshcatVisualizer :param viz: A meshcat visualizer instance to display the tolerance in. :param transform: The nominal position for which the tolerance is specified :param name: A display name for the tolerance. Will be set to a random name if not given. :param custom_material: Tolerances are displayed in transparent green -- a custom material can change the default appearance .. py:class:: RotationAbsolute(theta, frame = NOMINAL_FRAME) .. autoapi-inheritance-diagram:: timor.task.Tolerance.RotationAbsolute :parts: 1 :private-bases: Constrains the norm of all valid rotations in axis-angles (defines the maximum allowed absolute rotation). Any rotation can be expressed by exactly one axis and one angle. This tolerance class constrains the angle, irrespective of the axis. In the space of 3D-axis angle rotations $R \in \mathbb{R}^3$, this tolerance defines a sphere of radius theta around the origin. All rotations with an axis-angle representation within this sphere are valid. :ref: https://en.wikipedia.org/wiki/Axis%E2%80%93angle_representation Defines a maximum absolute rotation tolerance. :param theta: The maximum allowed absolute rotation in radians. Theoretically, one could define this tolerance with a lower/upper limit structure to also define a minimum rotation needed. This is barely useful though, so other than the other tolerances, this one is defined by a single value. .. py:attribute:: CorrespondingVolumeType :type: Type[timor.Volume] :value: None .. py:method:: __add__(other) Combine tolerances (logical AND operation) Adding two tolerances always yields a stronger constraint than either of the summands .. py:method:: __eq__(other) Two cartesian tolerances are equal if they have the same tolerance values and dtype .. py:method:: __hash__() The class is defined by the tolerance bounds that can be hashed .. py:attribute:: __slots__ :value: () .. py:method:: _add_same(other) Combine two pose tolerances .. py:attribute:: _frame .. py:method:: _inv_projection(projected) The projection is not injective, so we this inverse is not a true inverse but includes randomness. .. py:attribute:: _max_possible .. py:property:: _pose_projection_data :type: Dict[str, Union[Tuple[str], numpy.ndarray]] Generate a projection that can be used to describe a tolerance. To be implemented by children - returns the data for the projection of the pose. The tolerance values should be np arrays though, not lists. .. py:method:: _projection(nominal) We project any transformation to its axis angle. .. py:attribute:: _rounding_error :type: float :value: 1e-12 .. py:attribute:: _theta :type: numpy.ndarray .. py:attribute:: _visual_color :value: 65280 .. py:property:: _visual_geometry :type: (meshcat.geometry.Geometry, timor.utilities.transformation.Transformation) The geometry representing the tolerance in a visualization and the relative offset to the nominal position .. py:attribute:: _visual_material .. py:method:: default() :classmethod: Default absolute rotation tolerance, allows a deviation of at most 1/2 degree. .. py:method:: enclosing_volume(limits, offset = Transformation.neutral()) It does not make sense to obtain a spatial volume from a rotation representation from here. The rotation tolerance does not actually represent a volume in the spatial sense, but rather a range of possible rotations. Hence, we cannot obtain a typical volume defined in the representation through a direct conversion. .. py:method:: from_projection(projection, values, frame = NOMINAL_FRAME) :staticmethod: Creates a tolerance from a projection descriptor and an absolute tolerance value. :param projection: The projection descriptor. Valid values: {"x", "y", "z", "r_cyl", "r_sph", "theta", "phi", "R", "P", "Y", "Alpha", "Beta", "Gamma", "N_x", "N_y", "N_z", "Theta_R", "A", "B", "C", "D"} :param values: The lower and upper bound for the tolerance :param frame: The frame in which the tolerance is defined. Defaults to the world frame. :return: The tolerance class instance .. py:property:: stacked :type: numpy.ndarray Just theta .. py:method:: to_projection() A dictionary that can be used to specify this tolerance as a tolerated pose projection. Format: Dictionary with * projection: (proj_0, ..., proj_n) <>, * tolerance: (tol_0, ..., tol_n) <> .. py:method:: valid(desired, real) Public interface, makes sure child classes only work on (3,) shaped points .. py:property:: valid_random_deviation :type: timor.utilities.transformation.Transformation Used to generate a random but still valid transformation. Returns a random deviation/distortion that would still satisfy the tolerance, distributed uniformly in the solution space. Useful for sampling valid positions. Always returns a Transformation. .. py:method:: visualize(viz, transform, name = None, custom_material = None) Visualize the tolerance in a MeshcatVisualizer :param viz: A meshcat visualizer instance to display the tolerance in. :param transform: The nominal position for which the tolerance is specified :param name: A display name for the tolerance. Will be set to a random name if not given. :param custom_material: Tolerances are displayed in transparent green -- a custom material can change the default appearance .. py:class:: RotationAxis(n_x, n_y, n_z, frame = NOMINAL_FRAME) .. autoapi-inheritance-diagram:: timor.task.Tolerance.RotationAxis :parts: 1 :private-bases: Constrains the maximum rotation around an interval of user-defined axes. Any rotation can be expressed by exactly one axis and one angle. This tolerance class constrains the dot direction and extend of a relative rotation between an intended and a real orientation. In the space of 3D-axis angle rotations $R \in \mathbb{R}^3$, this tolerance defines a hyper-rectangle centered in the origin. All rotations with an axis-angle representation within this rectangle are valid. :ref: https://en.wikipedia.org/wiki/Axis%E2%80%93angle_representation Defines the interval of allowed axis angle rotations. If the relative rotation between desired and real pose is represented by the axis-angle representation :math:`v = a_x, a_y, a_z`, where :math:`\norm{v} = \theta` is the angle of rotation, then this tolerance constrains the scaled elements of :math:`v` to be within the given intervals. The axis angle tolerance is defined by three parameters: :param n_x: Lower and upper tolerance for the x-part of the scaled rotation axis. :param n_y: Lower and upper tolerance for the y-part of the scaled rotation axis. :param n_z: Lower and upper tolerance for the z-part of the scaled rotation axis. .. py:attribute:: CorrespondingVolumeType :type: Type[timor.Volume] :value: None .. py:method:: __add__(other) Combine tolerances (logical AND operation) Adding two tolerances always yields a stronger constraint than either of the summands .. py:method:: __eq__(other) Two cartesian tolerances are equal if they have the same tolerance values and dtype .. py:method:: __hash__() The class is defined by the tolerance bounds that can be hashed .. py:attribute:: __slots__ :value: () .. py:method:: _add_same(other) Combine two pose tolerances .. py:attribute:: _frame .. py:method:: _inv_projection(projected) 4x1 axis-angle representation -> placement. .. py:attribute:: _max_possible .. py:attribute:: _n_x :type: numpy.ndarray .. py:attribute:: _n_y :type: numpy.ndarray .. py:attribute:: _n_z :type: numpy.ndarray .. py:property:: _pose_projection_data :type: Dict[str, Union[Tuple[str], numpy.ndarray]] Generate a projection that can be used to describe a tolerance. To be implemented by children - returns the data for the projection of the pose. The tolerance values should be np arrays though, not lists. .. py:method:: _projection(nominal) 4x1 axis-angle representation. .. py:attribute:: _rounding_error :type: float :value: 1e-12 .. py:attribute:: _visual_color :value: 65280 .. py:property:: _visual_geometry :type: (meshcat.geometry.Geometry, timor.utilities.transformation.Transformation) The geometry representing the tolerance in a visualization and the relative offset to the nominal position .. py:attribute:: _visual_material .. py:method:: default() :classmethod: Default axis-angle tolerance, allows a deviation of at most 1/2 degree around each axis. Note that, opposed to RotationAbsolute, this tolerance can lead to rotations larger than the half degree around an axis, as long as neither of the individual rotation around x, y, z-axis exceeds the threshold. .. py:method:: enclosing_volume(limits, offset = Transformation.neutral()) Returns an internal representation of a volume object, described by limits and offsets. :param limits: The limits of the volume, as a 3x2 array. For each row, the first column represents the lower limit, and the second column represents the upper limit. :param offset: An optional transformation that is applied to the volume to adjust its position and orientation. :return: An internal representation of the volume. .. py:method:: from_projection(projection, values, frame = NOMINAL_FRAME) :staticmethod: Creates a tolerance from a projection descriptor and an absolute tolerance value. :param projection: The projection descriptor. Valid values: {"x", "y", "z", "r_cyl", "r_sph", "theta", "phi", "R", "P", "Y", "Alpha", "Beta", "Gamma", "N_x", "N_y", "N_z", "Theta_R", "A", "B", "C", "D"} :param values: The lower and upper bound for the tolerance :param frame: The frame in which the tolerance is defined. Defaults to the world frame. :return: The tolerance class instance .. py:property:: stacked :type: numpy.ndarray Lower and upper bounds for axis angles. .. py:method:: to_projection() A dictionary that can be used to specify this tolerance as a tolerated pose projection. Format: Dictionary with * projection: (proj_0, ..., proj_n) <>, * tolerance: (tol_0, ..., tol_n) <> .. py:method:: valid(desired, real) Public interface, makes sure child classes only work on (3,) shaped points .. py:property:: valid_random_deviation :type: timor.utilities.transformation.Transformation Used to generate a random but still valid transformation. Returns a random deviation/distortion that would still satisfy the tolerance, distributed uniformly in the solution space. Useful for sampling valid positions. Always returns a Transformation. .. py:method:: visualize(viz, transform, name = None, custom_material = None) Visualize the tolerance in a MeshcatVisualizer :param viz: A meshcat visualizer instance to display the tolerance in. :param transform: The nominal position for which the tolerance is specified :param name: A display name for the tolerance. Will be set to a random name if not given. :param custom_material: Tolerances are displayed in transparent green -- a custom material can change the default appearance .. py:class:: Spatial(frame = NOMINAL_FRAME, *args) .. autoapi-inheritance-diagram:: timor.task.Tolerance.Spatial :parts: 1 :private-bases: Any tolerance that tolerates spatial attributes (placements). Sanity checks .. py:attribute:: CorrespondingVolumeType :type: Type[timor.Volume] :value: None .. py:method:: __add__(other) Combine tolerances (logical AND operation) Adding two tolerances always yields a stronger constraint than either of the summands .. py:method:: __eq__(other) Two cartesian tolerances are equal if they have the same tolerance values and dtype .. py:method:: __hash__() The class is defined by the tolerance bounds that can be hashed .. py:attribute:: __slots__ :value: () .. py:method:: _add_same(other) Combine two pose tolerances .. py:attribute:: _frame .. py:method:: _inv_projection(projected) :abstractmethod: Inverse to _projection Maps a projected element from the tolerances projection space to a placement, being offset from the origin by the values defined in the projection space. .. py:attribute:: _max_possible :type: numpy.ndarray .. py:property:: _pose_projection_data :type: Dict[str, Union[Tuple[str], numpy.ndarray]] :abstractmethod: Generate a projection that can be used to describe a tolerance. To be implemented by children - returns the data for the projection of the pose. The tolerance values should be np arrays though, not lists. .. py:method:: _projection(nominal) :abstractmethod: Maps a placement to the projection space of the tolerance .. py:attribute:: _rounding_error :type: float :value: 1e-12 .. py:attribute:: _visual_color :value: 65280 .. py:property:: _visual_geometry :type: (meshcat.geometry.Geometry, timor.utilities.transformation.Transformation) The geometry representing the tolerance in a visualization and the relative offset to the nominal position .. py:attribute:: _visual_material .. py:method:: default() :classmethod: :abstractmethod: Default tolerance, e.g. for a cartesian tolerance that is 0.001 for all dimensions .. py:method:: enclosing_volume(limits, offset = Transformation.neutral()) Returns an internal representation of a volume object, described by limits and offsets. :param limits: The limits of the volume, as a 3x2 array. For each row, the first column represents the lower limit, and the second column represents the upper limit. :param offset: An optional transformation that is applied to the volume to adjust its position and orientation. :return: An internal representation of the volume. .. py:method:: from_projection(projection, values, frame = NOMINAL_FRAME) :staticmethod: Creates a tolerance from a projection descriptor and an absolute tolerance value. :param projection: The projection descriptor. Valid values: {"x", "y", "z", "r_cyl", "r_sph", "theta", "phi", "R", "P", "Y", "Alpha", "Beta", "Gamma", "N_x", "N_y", "N_z", "Theta_R", "A", "B", "C", "D"} :param values: The lower and upper bound for the tolerance :param frame: The frame in which the tolerance is defined. Defaults to the world frame. :return: The tolerance class instance .. py:property:: stacked :type: numpy.ndarray :abstractmethod: The tolerances stacked in an array of dimensions (num_projections, 2) .. py:method:: to_projection() A dictionary that can be used to specify this tolerance as a tolerated pose projection. Format: Dictionary with * projection: (proj_0, ..., proj_n) <>, * tolerance: (tol_0, ..., tol_n) <> .. py:method:: valid(desired, real) Public interface, makes sure child classes only work on (3,) shaped points .. py:property:: valid_random_deviation :type: timor.utilities.transformation.Transformation Used to generate a random but still valid transformation. Returns a random deviation/distortion that would still satisfy the tolerance, distributed uniformly in the solution space. Useful for sampling valid positions. Always returns a Transformation. .. py:method:: visualize(viz, transform, name = None, custom_material = None) Visualize the tolerance in a MeshcatVisualizer :param viz: A meshcat visualizer instance to display the tolerance in. :param transform: The nominal position for which the tolerance is specified :param name: A display name for the tolerance. Will be set to a random name if not given. :param custom_material: Tolerances are displayed in transparent green -- a custom material can change the default appearance .. py:class:: ToleranceBase .. autoapi-inheritance-diagram:: timor.task.Tolerance.ToleranceBase :parts: 1 :private-bases: An interface on numeric tolerances between goals and states that can be expressed as np-arrays .. py:method:: __add__(other) Combine tolerances (logical AND operation) Adding two tolerances always yields a stronger constraint than either of the summands .. py:method:: __eq__(other) :abstractmethod: Explicitly fail if not implemented .. py:method:: __hash__() :abstractmethod: Explicitly fail if not implemented .. py:attribute:: __slots__ :value: () .. py:method:: _add_same(other) :abstractmethod: Used when two tolerances of the same class are used together. Interface to add a tolerance of the same class to this tolerance. This method is to be called by __add__ and can simplify the combination of multiple tolerances. .. py:attribute:: _visual_color :value: 65280 .. py:property:: _visual_geometry :type: (meshcat.geometry.Geometry, timor.utilities.transformation.Transformation) The geometry representing the tolerance in a visualization and the relative offset to the nominal position .. py:attribute:: _visual_material .. py:method:: default() :classmethod: :abstractmethod: Default tolerance, e.g. for a cartesian tolerance that is 0.001 for all dimensions .. py:method:: from_projection(projection, values, frame = NOMINAL_FRAME) :staticmethod: Creates a tolerance from a projection descriptor and an absolute tolerance value. :param projection: The projection descriptor. Valid values: {"x", "y", "z", "r_cyl", "r_sph", "theta", "phi", "R", "P", "Y", "Alpha", "Beta", "Gamma", "N_x", "N_y", "N_z", "Theta_R", "A", "B", "C", "D"} :param values: The lower and upper bound for the tolerance :param frame: The frame in which the tolerance is defined. Defaults to the world frame. :return: The tolerance class instance .. py:method:: to_projection() :abstractmethod: Describe a tolerance as a projection dictionary Returns a dictionary that can be dumped in a json to describe the tolerance Inverse operation to from_projection .. py:method:: valid(desired, real) :abstractmethod: Returns true if is within 's tolerance (defined by self) .. py:method:: visualize(viz, transform, name = None, custom_material = None) Visualize the tolerance in a MeshcatVisualizer :param viz: A meshcat visualizer instance to display the tolerance in. :param transform: The nominal position for which the tolerance is specified :param name: A display name for the tolerance. Will be set to a random name if not given. :param custom_material: Tolerances are displayed in transparent green -- a custom material can change the default appearance .. py:class:: VectorDistance(tolerance, order = 2) .. autoapi-inheritance-diagram:: timor.task.Tolerance.VectorDistance :parts: 1 :private-bases: A tolerance of the LN-Distance between two vectors. Default: L2 / Cartesian distance Create tolerance limiting the distance between two vectors :param tolerance: Allowed distance between vectors under given norm :param order: Which order of norm to use (default 2 for Cartesian / L2 distance, see "ord" in numpy.linalg.norm) .. py:method:: __add__(other) Combine tolerances (logical AND operation) Adding two tolerances always yields a stronger constraint than either of the summands .. py:method:: __eq__(other) Two Vector distances are equal if they use the same norm and acceptable tolerance :param other: The other Tolerance to compare to .. py:method:: __hash__() Vector distance is unique due to order of norm and acceptable tolerance .. py:attribute:: __slots__ :value: () .. py:method:: _add_same(other) Used when two tolerances of the same class are used together. Interface to add a tolerance of the same class to this tolerance. This method is to be called by __add__ and can simplify the combination of multiple tolerances. .. py:attribute:: _visual_color :value: 65280 .. py:property:: _visual_geometry :type: (meshcat.geometry.Geometry, timor.utilities.transformation.Transformation) The geometry representing the tolerance in a visualization and the relative offset to the nominal position .. py:attribute:: _visual_material .. py:method:: default() :classmethod: Default is Euclidean / L2 distance with 1e-4 acceptable distance .. py:method:: from_projection(projection, values, frame = NOMINAL_FRAME) :staticmethod: Creates a tolerance from a projection descriptor and an absolute tolerance value. :param projection: The projection descriptor. Valid values: {"x", "y", "z", "r_cyl", "r_sph", "theta", "phi", "R", "P", "Y", "Alpha", "Beta", "Gamma", "N_x", "N_y", "N_z", "Theta_R", "A", "B", "C", "D"} :param values: The lower and upper bound for the tolerance :param frame: The frame in which the tolerance is defined. Defaults to the world frame. :return: The tolerance class instance .. py:attribute:: order :value: 2 .. py:method:: to_projection() :abstractmethod: Create CoBRA conformant dict describing this constraint .. py:attribute:: tolerance .. py:method:: valid(desired, real) Return whether desired and real are at most tolerance apart. :param desired: Vector to compare to :param real: Vector to judge .. py:method:: visualize(viz, transform, name = None, custom_material = None) Visualize the tolerance in a MeshcatVisualizer :param viz: A meshcat visualizer instance to display the tolerance in. :param transform: The nominal position for which the tolerance is specified :param name: A display name for the tolerance. Will be set to a random name if not given. :param custom_material: Tolerances are displayed in transparent green -- a custom material can change the default appearance