def get(self,
frame_to,
frame_from = None):
'''
Get the transform from one frame to another, assuming they are connected
in the transform tree.
If the frames are not connected a NetworkXNoPath error will be raised.
Arguments
---------
frame_from: hashable object, usually a string (eg 'world').
If left as None it will be set to self.base_frame
frame_to: hashable object, usually a string (eg 'mesh_0')
Returns
---------
transform: (4,4) homogenous transformation matrix
'''
if frame_from is None:
frame_from = self.base_frame
transform = np.eye(4)
path = self._get_path(frame_from, frame_to)
for i in range(len(path) - 1):
data, direction = self.transforms.get_edge_data_direction(path[i],
path[i+1])
matrix = data['matrix']
if direction < 0:
matrix = np.linalg.inv(matrix)
transform = np.dot(transform, matrix)
return transform
评论列表
文章目录