skrobot.sdf.GridSDF
- class skrobot.sdf.GridSDF(sdf_data, origin, resolution, fill_value=inf, use_abs=False)[source]
SDF using precopmuted signed distances for gridded points.
Methods
- __call__(points_world)[source]
Compute signed distances of input points to the implicit surface.
- Parameters:
points_world (numpy.ndarray[float](n_point, 3)) – 2 dim point array w.r.t. world flame.
- Returns:
signed_distances – 1 dim (n_point,) array of signed distance.
- Return type:
- T()[source]
Return 4x4 homogeneous transformation matrix.
- Returns:
matrix – homogeneous transformation matrix shape of (4, 4)
- Return type:
Examples
>>> from numpy import pi >>> from skrobot.coordinates import make_coords >>> c = make_coords() >>> c.T() array([[1., 0., 0., 0.], [0., 1., 0., 0.], [0., 0., 1., 0.], [0., 0., 0., 1.]]) >>> c.translate([0.1, 0.2, 0.3]) >>> c.rotate(pi / 2.0, 'y') array([[ 2.22044605e-16, 0.00000000e+00, 1.00000000e+00, 1.00000000e-01], [ 0.00000000e+00, 1.00000000e+00, 0.00000000e+00, 2.00000000e-01], [-1.00000000e+00, 0.00000000e+00, 2.22044605e-16, 3.00000000e-01], [ 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 1.00000000e+00]])
- align_axis_to_direction(direction, axis='z', wrt='world', eps=0.005)[source]
Align the specified axis of this coordinate to point in the given direction.
Rotates this coordinate system so that the specified axis points in the direction of the given vector.
- Parameters:
direction (list or numpy.ndarray) – Target direction vector [x, y, z]. The axis will be aligned to point in this direction.
axis (str or list or numpy.ndarray, optional) – The axis to align. Can be ‘x’, ‘y’, ‘z’, or a custom axis vector. Default is ‘z’.
wrt (str or skrobot.coordinates.Coordinates, optional) – Reference frame for the direction vector. ‘world’: direction is in world frame (default) ‘local’: direction is in this coordinate’s local frame Coordinates: direction is in the given coordinate’s frame
eps (float, optional) – Tolerance for detecting parallel/anti-parallel cases. Default is 0.005.
- Returns:
self – Returns self for method chaining.
- Return type:
Examples
>>> import numpy as np >>> from skrobot.coordinates import Coordinates >>> c = Coordinates() >>> c.align_axis_to_direction([1, 0, 0]) # Align z-axis to x direction >>> c.z_axis array([1., 0., 0.], dtype=float32)
>>> c = Coordinates() >>> c.align_axis_to_direction([0, 1, 0], axis='x') # Align x-axis to y direction >>> c.x_axis array([0., 1., 0.], dtype=float32)
>>> c = Coordinates().rotate(np.pi / 2, 'z') >>> c.align_axis_to_direction([1, 0, 0], wrt='local') # Direction in local frame
- assoc(child, relative_coords='world', force=False, **kwargs)[source]
Associate child coords to this coordinate system.
If relative_coords is None or ‘world’, the translation and rotation of childcoords in the world coordinate system do not change. If relative_coords is specified, childcoords is assoced at translation and rotation of relative_coords. By default, if child is already assoced to some other coords, raise an exception. But if force is True, you can overwrite the existing assoc relation.
- Parameters:
child (CascadedCoords) – child coordinates.
relative_coords (None or Coordinates or str) – child coordinates’ relative coordinates.
force (bool) – predicate for overwriting the existing assoc-relation
- Returns:
child – assoced child.
- Return type:
Examples
>>> from skrobot.coordinates import CascadedCoords >>> parent_coords = CascadedCoords(pos=[1, 0, 0]) >>> child_coords = CascadedCoords(pos=[1, 1, 0]) >>> parent_coords.assoc(child_coords) #<CascadedCoords 0x7f1d30e29510 1.000 1.000 0.000 / 0.0 -0.0 0.0> >>> child_coords.worldpos() array([1., 1., 0.]) >>> child_coords.translation array([0., 1., 0.])
None and ‘world’ have the same meaning.
>>> parent_coords = CascadedCoords(pos=[1, 0, 0]) >>> child_coords = CascadedCoords(pos=[1, 1, 0]) >>> parent_coords.assoc(child_coords, relative_coords='world') #<CascadedCoords 0x7f1d30e29510 1.000 1.000 0.000 / 0.0 -0.0 0.0> >>> child_coords.worldpos() array([1., 1., 0.])
If relative_coords is ‘local’, child is associated at world translation and world rotation of child from this coordinate system.
>>> parent_coords = CascadedCoords(pos=[1, 0, 0]) >>> child_coords = CascadedCoords(pos=[1, 1, 0]) >>> parent_coords.assoc(child_coords, relative_coords='local') >>> child_coords.worldpos() array([2., 1., 0.]) >>> child_coords.translation array([1., 1., 0.])
- changed()[source]
Return False
This is used for CascadedCoords compatibility
- Returns:
False – always return False
- Return type:
- difference_position(coords, position_mask=True, **kwargs)[source]
Return differences in position of given coords.
- Parameters:
coords (skrobot.coordinates.Coordinates) – given coordinates
position_mask (str, bool, list, or numpy.ndarray) – Specifies which axes to CONSTRAIN. - True: constrain all axes (default) - False/None: no constraint - ‘z’: constrain z-axis only - ‘xy’: constrain x,y axes - [1, 1, 0]: direct specification (constrain x,y)
- Returns:
dif_pos – difference position of self coordinates and coords considering position_mask.
- Return type:
Examples
>>> from skrobot.coordinates import Coordinates >>> from numpy import pi >>> c1 = Coordinates().translate([0.1, 0.2, 0.3]).rotate( ... pi / 3.0, 'x') >>> c2 = Coordinates().translate([0.3, -0.3, 0.1]).rotate( ... pi / 2.0, 'y') >>> c1.difference_position(c2) array([ 0.2 , -0.42320508, 0.3330127 ]) >>> c1 = Coordinates().translate([0.1, 0.2, 0.3]).rotate(0, 'x') >>> c2 = Coordinates().translate([0.3, -0.3, 0.1]).rotate( ... pi / 3.0, 'x') >>> c1.difference_position(c2) array([ 0.2, -0.5, -0.2]) >>> c1.difference_position(c2, position_mask='z') array([ 0. , 0. , -0.2])
- difference_rotation(coords, rotation_mask=True, rotation_mirror=None, **kwargs)[source]
Return differences in rotation of given coords.
- Parameters:
coords (skrobot.coordinates.Coordinates) – given coordinates
rotation_mask (str, bool, list, or numpy.ndarray) – Specifies which rotation axes to CONSTRAIN. - True: constrain all axes (default) - False/None: no constraint - ‘z’: constrain z-axis only - ‘xy’: constrain x,y axes - [1, 1, 0]: direct specification (constrain x,y)
rotation_mirror (str or None) – Mirror axis (‘x’, ‘y’, ‘z’) for allowing 180-degree rotations around the specified axis.
- Returns:
dif_rot – difference rotation of self coordinates and coords considering rotation_mask.
- Return type:
Examples
>>> from numpy import pi >>> from skrobot.coordinates import Coordinates >>> from skrobot.coordinates.math import rpy_matrix >>> coord1 = Coordinates() >>> coord2 = Coordinates(rot=rpy_matrix(pi / 2.0, pi / 3.0, pi / 5.0)) >>> coord1.difference_rotation(coord2) array([-0.32855112, 1.17434985, 1.05738936]) >>> coord1.difference_rotation(coord2, rotation_mask=False) array([0, 0, 0]) >>> coord1.difference_rotation(coord2, rotation_mask='yz') array([ 0. , 1.17434985, 1.05738936])
Using mirror option:
>>> coord1 = Coordinates() >>> coord2 = Coordinates().rotate(pi, 'x') >>> coord1.difference_rotation(coord2, rotation_mask=True, ... rotation_mirror='x') array([-2.99951957e-32, 0.00000000e+00, 0.00000000e+00])
- static from_file(filepath, **kwargs)[source]
Return GridSDF instance from a .sdf file.
- Parameters:
filepath (str or pathlib.Path) – path of .sdf file
- Returns:
sdf_instance – instance of sdf
- Return type:
skrobot.esdf.GridSDF
- static from_objfile(obj_filepath, dim_grid=100, padding_grid=5, **kwargs)[source]
Return GridSDF instance from an .obj file.
In the initial call of this method for an .obj file, the pre-process takes some time to converting it to a .sdf file. However, because a cache of .sdf file is created in the initial call, there is no overhead from the next call for the same .obj file.
- Parameters:
obj_filepath (str or pathlib.Path) – path of objfile
dim_grid (int) – dim of sdf
padding_grid (int) – number of padding
- Returns:
sdf_instance – instance of sdf
- Return type:
- get_transform()[source]
Return Transform object
- Returns:
transform – corresponding Transform to this coordinates
- Return type:
skrobot.coordinates.base.Transform
- interpolate(other, ratio)[source]
Interpolate between this coordinate and another coordinate.
This is an alias for
slerp(). Returns a new coordinate that is interpolated between this coordinate and the other coordinate using spherical linear interpolation (SLERP).- Parameters:
other (skrobot.coordinates.Coordinates) – The target coordinate to interpolate towards.
ratio (float) – Interpolation ratio in [0, 1]. 0.0 returns this coordinate, 1.0 returns the other coordinate, 0.5 returns the midpoint.
- Returns:
interpolated – A new coordinate interpolated between self and other.
- Return type:
Examples
>>> from skrobot.coordinates import Coordinates >>> c1 = Coordinates() >>> c2 = Coordinates(pos=[1, 0, 0]) >>> c_mid = c1.interpolate(c2, 0.5) >>> c_mid.translation array([0.5, 0. , 0. ])
>>> c_quarter = c1.interpolate(c2, 0.25) >>> c_quarter.translation array([0.25, 0. , 0. ])
- inverse_transform_vector(v)[source]
Transform vector in world coordinates to local coordinates
- Parameters:
vec (numpy.ndarray) – 3d vector. We can take batch of vector like (batch_size, 3)
- Returns:
transformed_point – transformed point
- Return type:
- inverse_transformation(dest=None)[source]
Return a invese transformation of this coordinate system.
Create a new coordinate with inverse transformation of this coordinate system.
\[\begin{split}\left( \begin{array}{ccc} R^{-1} & - R^{-1} p \\ 0 & 1 \end{array} \right)\end{split}\]- Parameters:
dest (None or skrobot.coordinates.Coordinates) – If dest is given, the result of transformation is in-placed to dest.
- Returns:
dest – result of inverse transformation.
- Return type:
- is_out_of_bounds(points_world)[source]
check if the the input points is out of bounds
This method checks if the the input points is out of bounds of RegularGridInterpolator.
- Parameters:
points_world (numpy.ndarray[float](n_points, 3)) – points w.r.t. world to be checked.
- Returns:
is_out_arr – If points is out of the interpolator’s boundary, the corresponding element of is_out_arr is True
- Return type:
numpy.ndarray[bool](n_points,)
- lerp(other, ratio)[source]
Linear interpolation between this coordinate and another.
Performs linear interpolation (LERP) between this coordinate and another coordinate. LERP is faster than SLERP but does not provide constant angular velocity for rotation.
- Parameters:
other (skrobot.coordinates.Coordinates) – The target coordinate to interpolate towards.
ratio (float) – Interpolation ratio in [0, 1]. 0.0 returns this coordinate, 1.0 returns the other coordinate, 0.5 returns the midpoint.
- Returns:
interpolated – A new coordinate interpolated between self and other using LERP.
- Return type:
Examples
>>> from skrobot.coordinates import Coordinates >>> c1 = Coordinates() >>> c2 = Coordinates(pos=[2, 2, 2]) >>> c_mid = c1.lerp(c2, 0.5) >>> c_mid.translation array([1., 1., 1.])
See also
slerpSpherical linear interpolation (constant angular velocity)
interpolateAlias for slerp
- move_coords(target_coords, local_coords)[source]
Transform this coordinate so that local_coords to target_coords.
- Parameters:
target_coords (skrobot.coordinates.Coordinates) – target coords.
local_coords (skrobot.coordinates.Coordinates) – local coords to be aligned.
- Returns:
self.worldcoords() – world coordinates.
- Return type:
- newcoords(target, pos=None, check_validity=True, relative_coords='local')[source]
Update this coordinate system with a new coordinate value.
This method updates the coordinates while maintaining the parent-child relationship. The key difference from Coordinates.newcoords is that this method handles the parent-child transformation automatically.
- Parameters:
target (skrobot.coordinates.Coordinates or numpy.ndarray) – If pos is None, target represents a Coordinates instance that describes the new desired coordinate. If pos is provided, target represents a rotation matrix.
pos (numpy.ndarray or None) – The new translation vector.
check_validity (bool) – Whether to validate the inputs.
relative_coords (str or skrobot.coordinates.Coordinates, default 'local') –
Specifies the coordinate frame in which the target coordinates are expressed.
’local’ (default): The target represents coordinates in the local frame (relative to parent if it exists). This is the default for backward compatibility. Example: child.newcoords(c) directly sets child’s local transformation to c. For a child with parent, this means: child = parent * c (in world frame)
Note: If you want to set world coordinates, you have two options:
Manual conversion (complex): child.newcoords(parent.worldcoords().inverse_transformation() * world_target)
Use relative_coords=’world’ (recommended): child.newcoords(world_target, relative_coords=’world’)
’world’: The target represents desired world coordinates. For child coordinates, the target is automatically converted to the parent’s local frame to maintain the correct world position. Example: child.newcoords(c, relative_coords=’world’) sets child such that child.worldcoords() equals c.
’local’: the target is already expressed in the child’s local frame.
’parent’: the target is given relative to the parent coordinate.
Alternatively, a Coordinates instance can be provided as the reference frame.
- Returns:
self
- Return type:
Examples
>>> from skrobot.coordinates import make_cascoords >>> parent = make_cascoords(pos=[10, 0, 0]) >>> child = make_cascoords(pos=[0, 5, 0]) >>> parent.assoc(child) >>> >>> # Setting world coordinates >>> target_world = make_cascoords(pos=[15, 15, 15]) >>> child.newcoords(target_world, relative_coords='world') >>> child.worldpos() array([15., 15., 15.]) >>> child.translation # Local position relative to parent array([5., 15., 15.]) >>> >>> # Setting local coordinates >>> target_local = make_cascoords(pos=[2, 2, 2]) >>> child.newcoords(target_local, relative_coords='local') >>> child.translation array([2., 2., 2.]) >>> child.worldpos() # World position is parent + local array([12., 2., 2.]) >>> >>> # Manual world coordinate setting using inverse_transformation >>> world_target = make_cascoords(pos=[20, 20, 20]) >>> local_target = parent.worldcoords().inverse_transformation() * world_target >>> child.newcoords(local_target) # Default is 'local' >>> child.worldpos() array([20., 20., 20.])
- on_surface(points_world)[source]
Check if points are on the surface.
- Parameters:
points_world (numpy.ndarray[float](n_point, 3)) – 2 dim point array w.r.t. the world frame.
- Returns:
logicals (numpy.ndarray[bool](n_point,)) – boolean vector of the on-surface predicate for points_world.
sd_vals (numpy.ndarray[float](n_point,)) – signed distances corresponding to logicals.
- orient_with_matrix(rotation_matrix, wrt='world')[source]
Force update this coordinate system’s rotation.
- Parameters:
rotation_matrix (numpy.ndarray) – 3x3 rotation matrix.
wrt (str or skrobot.coordinates.Coordinates) – reference coordinates.
- rotate(theta, axis, wrt='local', skip_normalization=False)[source]
Rotate this coordinate.
Rotate this coordinate relative to axis by theta radians with respect to wrt.
- Parameters:
theta (float) – radian
axis (str or numpy.ndarray) – ‘x’, ‘y’, ‘z’ or vector
wrt (str or Coordinates)
skip_normalization (bool) – if True, skip normalization for axis.
- Return type:
self
- rotate_vector(v)[source]
Rotate 3-dimensional vector using rotation of this coordinate
- Parameters:
v (numpy.ndarray) – vector shape of (3,)
- Returns:
np.matmul(self._rotation, v) – rotated vector
- Return type:
Examples
>>> from skrobot.coordinates import Coordinates >>> from numpy import pi >>> c = Coordinates().rotate(pi, 'z') >>> c.rotate_vector([1, 2, 3]) array([-1., -2., 3.])
- rotate_with_matrix(matrix, wrt)[source]
Rotate this coordinate by given rotation matrix.
This is a subroutine of self.rotate function.
- Parameters:
mat (numpy.ndarray) – rotation matrix shape of (3, 3)
wrt (str or skrobot.coordinates.Coordinates) – with respect to.
- Returns:
self
- Return type:
- rpy_angle()[source]
Return a pair of rpy angles of this coordinates.
Deprecated since version This: method is deprecated and confusing. Use matrix2ypr() or matrix2rpy() instead.
- Returns:
rpy_angle(self._rotation) – a pair of rpy angles. See also skrobot.coordinates.math.rpy_angle
- Return type:
Examples
>>> import numpy as np >>> from skrobot.coordinates import Coordinates >>> c = Coordinates().rotate(np.pi / 2.0, 'x').rotate(np.pi / 3.0, 'z') >>> r.rpy_angle() (array([ 3.84592537e-16, -1.04719755e+00, 1.57079633e+00]), array([ 3.14159265, -2.0943951 , -1.57079633]))
- slerp(other, ratio)[source]
Spherical linear interpolation between this coordinate and another.
Performs spherical linear interpolation (SLERP) between this coordinate and another coordinate. SLERP provides constant angular velocity rotation interpolation.
- Parameters:
other (skrobot.coordinates.Coordinates) – The target coordinate to interpolate towards.
ratio (float) – Interpolation ratio in [0, 1]. 0.0 returns this coordinate, 1.0 returns the other coordinate, 0.5 returns the midpoint.
- Returns:
interpolated – A new coordinate interpolated between self and other using SLERP.
- Return type:
Examples
>>> from skrobot.coordinates import Coordinates >>> import numpy as np >>> c1 = Coordinates() >>> c2 = Coordinates(pos=[1, 0, 0]).rotate(np.pi / 2, 'z') >>> c_mid = c1.slerp(c2, 0.5) >>> c_mid.translation array([0.5, 0. , 0. ])
See also
lerpLinear interpolation (faster but non-constant angular velocity)
interpolateAlias for slerp
- surface_points(n_sample=1000)[source]
Sample points from the implicit surface of the sdf.
- Parameters:
n_sample (int) – number of sample points.
- Returns:
points_world (numpy.ndarray[float](n_point, 3)) – sampled points w.r.t the world frame.
dists (numpy.ndarray[float](n_point,)) – signed distances corresponding to points_world.
- transform(c, wrt='local', out=None)[source]
Transform this coordinates
- Parameters:
c (skrobot.coordinates.Coordinates) – coordinates
wrt (str or skrobot.coordinates.Coordinates) – transform this coordinates with respect to wrt. If wrt is ‘local’ or self, multiply c from the right. If wrt is ‘parent’ or self.parent, transform c with respect to parentcoords. (multiply c from the left.) If wrt is Coordinates, transform c with respect to c.
out (None or skrobot.coordinates.Coordinates) – If the out is specified, set new coordinates to out. Note that if the out is given, these coordinates don’t change.
- Returns:
self – return self
- Return type:
- transform_vector(v)[source]
“Return vector represented at world frame.
Vector v given in the local coords is converted to world representation.
- Parameters:
v (numpy.ndarray) – 3d vector. We can take batch of vector like (batch_size, 3)
- Returns:
transformed_point – transformed point
- Return type:
- translate(vec, wrt='local')[source]
Translate this coordinates.
Note that this function changes this coordinates self. So if you don’t want to change this class, use copy_worldcoords()
- Parameters:
vec (list or numpy.ndarray) – shape of (3,) translation vector. unit is [m] order.
wrt (str or Coordinates (optional)) – translate with respect to wrt.
Examples
>>> import numpy as np >>> from skrobot.coordinates import Coordinates >>> c = Coordinates() >>> c.translation array([0., 0., 0.], dtype=float32) >>> c.translate([0.1, 0.2, 0.3]) >>> c.translation array([0.1, 0.2, 0.3], dtype=float32)
>>> c = Coordinates() >>> c.copy_worldcoords().translate([0.1, 0.2, 0.3]) >>> c.translation array([0., 0., 0.], dtype=float32)
>>> c = Coordinates().rotate(np.pi / 2.0, 'y') >>> c.translate([0.1, 0.2, 0.3]) >>> c.translation array([ 0.3, 0.2, -0.1]) >>> c = Coordinates().rotate(np.pi / 2.0, 'y') >>> c.translate([0.1, 0.2, 0.3], 'world') >>> c.translation array([0.1, 0.2, 0.3])
- world_position_quaternion_wxyz()[source]
Return world position and quaternion (wxyz).
This is a convenience method for getting both world position and world quaternion.
- Returns:
position (numpy.ndarray) – [x, y, z] world position.
quaternion (numpy.ndarray) – [w, x, y, z] world quaternion.
Examples
>>> from skrobot.coordinates import make_coords >>> c = make_coords(pos=[1, 2, 3]) >>> pos, quat = c.world_position_quaternion_wxyz() >>> pos array([1., 2., 3.]) >>> quat array([1., 0., 0., 0.])
- world_position_quaternion_xyzw()[source]
Return world position and quaternion (xyzw).
This is a convenience method for getting both world position and world quaternion in a format commonly used for 3D transforms (e.g., Three.js, ROS geometry_msgs).
- Returns:
position (numpy.ndarray) – [x, y, z] world position.
quaternion (numpy.ndarray) – [x, y, z, w] world quaternion.
Examples
>>> from skrobot.coordinates import make_coords >>> c = make_coords(pos=[1, 2, 3]) >>> pos, quat = c.world_position_quaternion_xyzw() >>> pos array([1., 2., 3.]) >>> quat array([0., 0., 0., 1.])
- world_quaternion_wxyz()[source]
Return world quaternion in [w, x, y, z] format.
- Returns:
q – [w, x, y, z] quaternion representing world rotation.
- Return type:
Examples
>>> from skrobot.coordinates import make_coords >>> c = make_coords() >>> c.world_quaternion_wxyz() array([1., 0., 0., 0.])
- world_quaternion_xyzw()[source]
Return world quaternion in [x, y, z, w] format.
- Returns:
q – [x, y, z, w] quaternion representing world rotation.
- Return type:
Examples
>>> from skrobot.coordinates import make_coords >>> c = make_coords() >>> c.world_quaternion_xyzw() array([0., 0., 0., 1.])
- worldpos()[source]
Return translation of this coordinate
See also skrobot.coordinates.Coordinates.translation
- Returns:
self.translation – translation of this coordinate
- Return type:
- worldrot()[source]
Return rotation of this coordinate
See also skrobot.coordinates.Coordinates.rotation
- Returns:
self._rotation – rotation matrix of this coordinate
- Return type:
- __eq__(value, /)
Return self==value.
- __ne__(value, /)
Return self!=value.
- __lt__(value, /)
Return self<value.
- __le__(value, /)
Return self<=value.
- __gt__(value, /)
Return self>value.
- __ge__(value, /)
Return self>=value.
- __mul__(other_c)[source]
Return Transformed Coordinates.
Note that this function creates new Coordinates and does not change translation and rotation, unlike transform function.
- Parameters:
other_c (skrobot.coordinates.Coordinates) – input coordinates.
- Returns:
out – transformed coordinates multiplied other_c from the right. T = T_{self} T_{other_c}.
- Return type:
- __pow__(exponent)[source]
Return exponential homogeneous matrix.
If exponent equals -1, return inverse transformation of this coords.
- Parameters:
exponent (numbers.Number) – exponent value. If exponent equals -1, return inverse transformation of this coords. In current, support only -1 case.
- Returns:
out – output.
- Return type:
Attributes
- descendants
- dimension
Return dimension of this coordinate
- Returns:
len(self.translation) – dimension of this coordinate
- Return type:
- parent
- quaternion
Property of quaternion in [w, x, y, z] format
- Returns:
q – [w, x, y, z] quaternion
- Return type:
Examples
>>> from numpy import pi >>> from skrobot.coordinates import make_coords >>> c = make_coords() >>> c.quaternion array([1., 0., 0., 0.]) >>> c.rotate(pi / 3, 'y').rotate(pi / 5, 'z') >>> c.quaternion array([0.8236391 , 0.1545085 , 0.47552826, 0.26761657])
- quaternion_wxyz
Property of quaternion in [w, x, y, z] format
- Returns:
q – [w, x, y, z] quaternion
- Return type:
- quaternion_xyzw
Property of quaternion in [x, y, z, w] format
- Returns:
q – [x, y, z, w] quaternion
- Return type:
Examples
>>> from numpy import pi >>> from skrobot.coordinates import make_coords >>> c = make_coords() >>> c.quaternion_xyzw array([0., 0., 0., 1.]) >>> c.rotate(pi / 3, 'y').rotate(pi / 5, 'z') >>> c.quaternion_xyzw array([0.1545085 , 0.47552826, 0.26761657, 0.8236391 ])
- rotation
Return rotation matrix of this coordinates.
- Returns:
self._rotation – 3x3 rotation matrix
- Return type:
Examples
>>> import numpy as np >>> from skrobot.coordinates import Coordinates >>> c = Coordinates() >>> c.rotation array([[1., 0., 0.], [0., 1., 0.], [0., 0., 1.]]) >>> c.rotate(np.pi / 2.0, 'y') >>> c.rotation array([[ 2.22044605e-16, 0.00000000e+00, 1.00000000e+00], [ 0.00000000e+00, 1.00000000e+00, 0.00000000e+00], [-1.00000000e+00, 0.00000000e+00, 2.22044605e-16]])
- rotation_matrix
Alias for rotation property for better clarity.
Using rotation_matrix makes it more explicit that this returns a 3x3 rotation matrix, not angles or quaternions.
- Returns:
3x3 rotation matrix
- Return type:
See also
rotationThe original property (same as rotation_matrix)
- translation
Return translation of this coordinates.
- Returns:
self._translation – vector shape of (3, ). unit is [m]
- Return type:
Examples
>>> from skrobot.coordinates import Coordinates >>> c = Coordinates() >>> c.translation array([0., 0., 0.]) >>> c.translate([0.1, 0.2, 0.3]) >>> c.translation array([0.1, 0.2, 0.3])
- translation_vector
Alias for translation property for better clarity.
Using translation_vector makes it more explicit that this returns a 3D translation vector, providing consistency with rotation_matrix.
- Returns:
3D translation vector [x, y, z] in meters
- Return type:
See also
translationThe original property (same as translation_vector)
- x_axis
Return x axis vector of this coordinates.
- Returns:
axis – x axis.
- Return type:
- y_axis
Return y axis vector of this coordinates.
- Returns:
axis – y axis.
- Return type:
- z_axis
Return z axis vector of this coordinates.
- Returns:
axis – z axis.
- Return type: