1 from .registry
import converts_from_numpy, converts_to_numpy
2 from geometry_msgs.msg
import Transform, Vector3, Quaternion, Point, Pose
12 return np.array([msg.x, msg.y, msg.z, 0])
14 return np.array([msg.x, msg.y, msg.z])
18 if arr.shape[-1] == 4:
19 assert np.all(arr[...,-1] == 0)
22 if len(arr.shape) == 1:
25 return np.apply_along_axis(
lambda v: Vector3(*v), axis=-1, arr=arr)
30 return np.array([msg.x, msg.y, msg.z, 1])
32 return np.array([msg.x, msg.y, msg.z])
36 if arr.shape[-1] == 4:
37 arr = arr[...,:-1] / arr[...,-1]
39 if len(arr.shape) == 1:
42 return np.apply_along_axis(
lambda v: Point(*v), axis=-1, arr=arr)
46 return np.array([msg.x, msg.y, msg.z, msg.w])
50 assert arr.shape[-1] == 4
52 if len(arr.shape) == 1:
53 return Quaternion(*arr)
55 return np.apply_along_axis(
lambda v: Quaternion(*v), axis=-1, arr=arr)
63 from tf
import transformations
66 transformations.translation_matrix(
numpify(msg.translation)),
67 transformations.quaternion_matrix(
numpify(msg.rotation))
72 from tf
import transformations
74 shape, rest = arr.shape[:-2], arr.shape[-2:]
78 trans = transformations.translation_from_matrix(arr)
79 quat = transformations.quaternion_from_matrix(arr)
82 translation=Vector3(*trans),
83 rotation=Quaternion(*quat)
86 res = np.empty(shape, dtype=np.object_)
87 for idx
in np.ndindex(shape):
89 translation=Vector3(*transformations.translation_from_matrix(arr[idx])),
90 rotation=Quaternion(*transformations.quaternion_from_matrix(arr[idx]))
95 from tf
import transformations
98 transformations.translation_matrix(
numpify(msg.position)),
99 transformations.quaternion_matrix(
numpify(msg.orientation))
104 from tf
import transformations
106 shape, rest = arr.shape[:-2], arr.shape[-2:]
110 trans = transformations.translation_from_matrix(arr)
111 quat = transformations.quaternion_from_matrix(arr)
114 position=Vector3(*trans),
115 orientation=Quaternion(*quat)
118 res = np.empty(shape, dtype=np.object_)
119 for idx
in np.ndindex(shape):
121 position=Vector3(*transformations.translation_from_matrix(arr[idx])),
122 orientation=Quaternion(*transformations.quaternion_from_matrix(arr[idx]))
def numpify(msg, args, kwargs)
def converts_from_numpy(msgtype, plural=False)
def converts_to_numpy(msgtype, plural=False)
def numpy_to_vector3(arr)
def numpy_to_transform(arr)
def vector3_to_numpy(msg, hom=False)
def point_to_numpy(msg, hom=False)
def transform_to_numpy(msg)