timor.utilities.spatial

Attributes

NO_ROTATION

NO_TRANSLATION

Functions

axis_angle2rot_mat(axis_angle)

Inverse to rot_mat2axis_angle.

axis_angle_rotation(vec, axis_angle)

Rotates a 3x1 vector by a given axis-angle representation.

cartesian2cylindrical(cart)

Takes a (3,) array in cartesian coordinates [x, y, z] and returns the according cylindrical coordinates [r, phi, z].

cartesian2spherical(cart)

Takes a (3,) array in cartesian coordinates [x, y, z] and returns the according spherical coordinates.

clone_collision_object(co)

Deep copy of a hppfcl collision object

cylindrical2cartesian(cyl)

Inverse to cartesian2cylindrical

dh_extended_to_homogeneous([a, alpha, n, p, delta])

Transform extended dh parameters into a homogeneous transformation matrix

euler2mat(rotation, seq)

Wrapper for the scipy euler method

frame2geom(frame_id, geom_model)

Returns all geometry objects where porent frame is frame_id

homogeneous([translation, rotation])

Returns a transformation matrix for translation, then rotation

inv_homogeneous(T)

Efficiently inverses a homogeneous transformation

mat2euler(R[, seq])

Inverse to euler2mat

random_rotation([rng])

Returns a random 3x3 rotation matrix.

rot2D(angle)

Returns the 2D rotation matrix for an angle in radian.

rotX(alpha)

Returns a transformation rotation matrix for a rotation of a vector around the x-axis

rotY(beta)

Returns a transformation rotation matrix for a rotation of a vector around the y-axis

rotZ(gamma)

Returns a transformation rotation matrix for a rotation of a vector around the z-axis

rot_mat2axis_angle(rot_mat)

Takes a rotation matrix and returns the corresponding axis-angle representation

rotation_in_bounds(rot, bounds)

Maps angles to an interval 2pi-agnostically.

skew(vec3)

Returns the skew symmetric matrix of a 3D vector

spherical2cartesian(spher)

Inverse to cartesian2spherical

Module Contents

timor.utilities.spatial.NO_ROTATION
timor.utilities.spatial.NO_TRANSLATION
timor.utilities.spatial.axis_angle2rot_mat(axis_angle)

Inverse to rot_mat2axis_angle.

Parameters:

axis_angle (numpy.ndarray)

Return type:

numpy.ndarray

timor.utilities.spatial.axis_angle_rotation(vec, axis_angle)

Rotates a 3x1 vector by a given axis-angle representation.

Equivalent to spatial.axis_angle2rot_mat(axis_angle) @ vec, but computationally more efficient. :param vec: The vector to be rotated :param axis_angle: The axis-angle representation of the rotation, either 4x1 or 3x1 array :source: https://en.wikipedia.org/wiki/Axis%E2%80%93angle_representation

Parameters:
Return type:

numpy.ndarray

timor.utilities.spatial.cartesian2cylindrical(cart)

Takes a (3,) array in cartesian coordinates [x, y, z] and returns the according cylindrical coordinates [r, phi, z].

Source:

https://en.wikipedia.org/wiki/Polar_coordinate_system

Parameters:

cart (numpy.ndarray)

Return type:

numpy.ndarray

timor.utilities.spatial.cartesian2spherical(cart)

Takes a (3,) array in cartesian coordinates [x, y, z] and returns the according spherical coordinates.

Convention: [r, theta, phi]; r, theta, phi ~ radial, azimuthal, polar. :source: https://en.wikipedia.org/wiki/Spherical_coordinate_system

Parameters:

cart (numpy.ndarray)

Return type:

numpy.ndarray

timor.utilities.spatial.clone_collision_object(co)

Deep copy of a hppfcl collision object

Parameters:

co (hppfcl.CollisionObject)

Return type:

hppfcl.CollisionObject

timor.utilities.spatial.cylindrical2cartesian(cyl)

Inverse to cartesian2cylindrical

Parameters:

cyl (numpy.ndarray)

Return type:

numpy.ndarray

timor.utilities.spatial.dh_extended_to_homogeneous(a=0, alpha=0, n=0, p=0, delta=0)

Transform extended dh parameters into a homogeneous transformation matrix

Describes a transformation similar to dh parameters (from Althoff et al., Sci. Robotics, 2019, Fig. 2) More precisely the transformation from a module input frame to the joint

Parameters:
  • a (float) – translate along x’_i [m]

  • alpha (float) – rotate around x_i [rad]

  • delta (float) – rotate around z_im1 [rad], gamma in Fig. 2

  • p (float) – offset of PJ_im1 to o’_i in z’_i direction [m]

  • n (float) – offset along z_i from o_i to PJ_i [m]

timor.utilities.spatial.euler2mat(rotation, seq)

Wrapper for the scipy euler method

Parameters:
  • rotation (Collection[float]) – Rotation angles in radian

  • seq (str) – Any ordering of {xyz}[intrinsic] or {XYZ}[extrinsic] axes.

Returns:

3x3 rotation matrix

timor.utilities.spatial.frame2geom(frame_id, geom_model)

Returns all geometry objects where porent frame is frame_id

Parameters:
  • frame_id (int)

  • geom_model (pinocchio.GeometryModel)

timor.utilities.spatial.homogeneous(translation=NO_TRANSLATION, rotation=NO_ROTATION)

Returns a transformation matrix for translation, then rotation

Parameters:
  • translation (Collection[float]) – Translation in the transformation matrix. 3x1

  • rotation (Collection[Collection[float]]) – 3x3 rotation matrix. Nested List works as well

Returns:

Return type:

numpy.ndarray

timor.utilities.spatial.inv_homogeneous(T)

Efficiently inverses a homogeneous transformation

Parameters:

T (numpy.ndarray)

Return type:

numpy.ndarray

timor.utilities.spatial.mat2euler(R, seq='xyz')

Inverse to euler2mat

Parameters:
  • R (numpy.ndarray) – A 3x3 rotation matrix

  • seq (str) – Any ordering of {xyz}[intrinsic] or {XYZ}[extrinsic] axes. Defaults to roll-pitch-yaw

Returns:

The rotations around the axes specified in seq that lead to R

Return type:

numpy.ndarray

timor.utilities.spatial.random_rotation(rng=None)

Returns a random 3x3 rotation matrix.

Parameters:

rng (Optional[numpy.random.Generator])

Return type:

numpy.ndarray

timor.utilities.spatial.rot2D(angle)

Returns the 2D rotation matrix for an angle in radian.

Parameters:

angle (float) – Angel in radian

Returns:

2D rotation

Return type:

numpy.ndarray

timor.utilities.spatial.rotX(alpha)

Returns a transformation rotation matrix for a rotation of a vector around the x-axis

Parameters:

alpha (float)

Return type:

numpy.ndarray

timor.utilities.spatial.rotY(beta)

Returns a transformation rotation matrix for a rotation of a vector around the y-axis

Parameters:

beta (float)

Return type:

numpy.ndarray

timor.utilities.spatial.rotZ(gamma)

Returns a transformation rotation matrix for a rotation of a vector around the z-axis

Parameters:

gamma (float)

Return type:

numpy.ndarray

timor.utilities.spatial.rot_mat2axis_angle(rot_mat)

Takes a rotation matrix and returns the corresponding axis-angle representation

Parameters:

rot_mat (numpy.ndarray) – 3x3 rotation matrix

Returns:

4x1 array of axis-angle representation (n_x, n_y, n_z, theta_R), where n_x, n_y, n_z ~ unit vector and \(\theta_R\) ~ rotation angle \(\in [0, \pi]\)

Return type:

numpy.ndarray

timor.utilities.spatial.rotation_in_bounds(rot, bounds)

Maps angles to an interval 2pi-agnostically.

Takes an array of rotations in radian and maps them to bounds aka limits if possible by adding/subtracting multiples of 2 pi. If not possible, will return the original input.

Parameters:
  • rot (numpy.ndarray) – A 1xn array of rotations, given in radian.

  • bounds (numpy.ndarray) – A 2xn array of limits, lower limits in first, upper limits in second row of the array. Every column in bounds corresponds to a column in rot.

Returns:

A variant of rot, offset by multiples of 2pi to fit within bounds. If that is not possible, returns rot.

Return type:

numpy.ndarray

timor.utilities.spatial.skew(vec3)

Returns the skew symmetric matrix of a 3D vector

Parameters:

vec3 (numpy.ndarray)

Return type:

numpy.ndarray

timor.utilities.spatial.spherical2cartesian(spher)

Inverse to cartesian2spherical

Parameters:

spher (numpy.ndarray)

Return type:

numpy.ndarray